/** * @file Picture.h * * @author Charles B. Owen * * Class that represents our animation picture */ #pragma once #include "Timeline.h" #include "MachineDrawable.h" class PictureObserver; class Actor; /** * Class that represents our animation picture */ class Picture { private: /// The picture size wxSize mSize = wxSize(1500, 800); /// The observers of this picture std::vector mObservers; /// The actors associated with this picture std::vector> mActors; /// The animation timeline Timeline mTimeline; ///machine drawable 1 std::shared_ptr mMachine1 = nullptr; ///machine drawable 2 std::shared_ptr mMachine2 = nullptr; public: Picture(); /// Copy Constructor (Disabled) Picture(const Picture &) = delete; /// Assignment Operator (Disabled) void operator=(const Picture &) = delete; /** * Destructor */ virtual ~Picture() = default; /** * Get the picture size * @return Picture size in pixels */ wxSize GetSize() {return mSize;} /** * Set the picture size * @param size Picture size in pixels */ void SetSize(wxSize size) {mSize = size;} /** * Get a pointer to the Timeline object * @return Pointer to the Timeline object */ Timeline *GetTimeline() {return &mTimeline;} void AddObserver(PictureObserver *observer); void RemoveObserver(PictureObserver *observer); void UpdateObservers(); void Draw(std::shared_ptr graphics); void AddActor(std::shared_ptr actor); /** Iterator that iterates over the actors in a picture */ class ActorIter { public: /** * Constructor * @param picture Picture we are iterating * @param pos Starting position \ */ ActorIter(Picture *picture, int pos) : mPicture(picture), mPos(pos) {} /** * Test for end of the iterator * @param other Other object to test against * @return True if we this position equals not equal to the other position */ bool operator!=(const ActorIter &other) const { return mPos != other.mPos; } /** * Get value at current position * @return Value at mPos in the collection */ std::shared_ptr operator *() const { return mPicture->mActors[mPos]; } /** Increment the iterator * @return Reference to this iterator */ const ActorIter& operator++() { mPos++; return *this; } private: Picture *mPicture; ///< Picture we are iterating over int mPos; ///< Position in the collection }; /** * Get an iterator for the beginning of the collection * @return Iter object at position 0 */ ActorIter begin() { return ActorIter(this, 0); } /** * Get an iterator for the end of the collection * @return Iter object at position past the end */ ActorIter end() { return ActorIter(this, mActors.size()); } void SetAnimationTime(double time); double GetAnimationTime(); void Load(const wxString& filename); void Save(const wxString& filename); /** * setter for machine drawable 1 * @param drawable */ void SetMachineDrawable1(std::shared_ptr drawable){mMachine1=drawable;} /** * setter for machine drawable 2 * @param drawable */ void SetMachineDrawable2(std::shared_ptr drawable){mMachine2=drawable;} /** * getter for machine 1 * @return */ std::shared_ptr GetMachineDrawable1(){return mMachine1;} /** * getter for machine 2 * @return */ std::shared_ptr GetMachineDrawable2(){return mMachine2;} };