AnimationServices.h

Go to the documentation of this file.
00001 /*
00002  * The information in this file is
00003  * Copyright(c) 2007 Ball Aerospace & Technologies Corporation
00004  * and is subject to the terms and conditions of the
00005  * GNU Lesser General Public License Version 2.1
00006  * The license text is available from   
00007  * http://www.gnu.org/licenses/lgpl.html
00008  */
00009 
00010 #ifndef ANIMATIONSERVICES_H
00011 #define ANIMATIONSERVICES_H
00012 
00013 #include "Service.h"
00014 #include "Subject.h"
00015 #include "TypesFile.h"
00016 
00017 #include <string>
00018 #include <vector>
00019 
00020 class AnimationController;
00021 class AnimationFrame;
00022 
00023 /**
00024  *  \ingroup ServiceModule
00025  *  Manages animation controllers within the application.
00026  *
00027  *  This class provides the capability to create and destroy animation
00028  *  controllers.  A pointer to this class can be obtained by creating a
00029  *  Service<AnimationServices> instance.
00030  *
00031  *  This subclass of Subject will notify upon the following conditions:
00032  *  - The following methods are called: createAnimationController() and
00033  *    destroyAnimationController().
00034  *  - Other notifications documented in the Subject class.
00035  *
00036  *  @see     AnimationController
00037  */
00038 class AnimationServices : public Subject
00039 {
00040 public:
00041    /**
00042     *  Emitted with any<AnimationController*> when an animation controller is
00043     *  created.
00044     */
00045    SIGNAL_METHOD(AnimationServices, ControllerCreated)
00046 
00047    /**
00048     *  Emitted with any<AnimationController*> when an animation controller is
00049     *  destroyed.
00050     */
00051    SIGNAL_METHOD(AnimationServices, ControllerDestroyed)
00052 
00053    /**
00054     *  Creates a new animation controller.
00055     *
00056     *  This method creates a new animation controller with the given name and
00057     *  frame type.  The controller name must be unique within the application.
00058     *
00059     *  @param   name
00060     *           The animation controller name.  This name cannot be empty and
00061     *           must be unique for all controllers in the application.
00062     *  @param   frameType
00063     *           The frame type for the animation controller.  Once the
00064     *           controller is created, the frame type cannot be changed.
00065     *
00066     *  @return  A pointer to the new animation controller.  \b NULL is returned
00067     *           if an animation controller of the given name already exists,
00068     *           regardless of the frame type.
00069     *
00070     *  @notify  This method will notify signalControllerCreated() with
00071     *           any<AnimationController*> if the controller is successfully
00072     *           created.
00073     */
00074    virtual AnimationController* createAnimationController(const std::string& name, FrameType frameType) = 0;
00075 
00076    /**
00077     *  Queries whether an animation controller with a given name exists.
00078     *
00079     *  @param   name
00080     *           The controller name.
00081     *
00082     *  @return  Returns \b true if an animation controller with the given name
00083     *           exists, otherwise returns \b false.
00084     */
00085    virtual bool hasAnimationController(const std::string& name) const = 0;
00086 
00087    /**
00088     *  Returns the animation controller with a given name.
00089     *
00090     *  @param   name
00091     *           The controller name.
00092     *
00093     *  @return  A pointer to the existing animation controller with the given
00094     *           name.  \b NULL is returned if no animation controller exists
00095     *           with the given name.
00096     */
00097    virtual AnimationController* getAnimationController(const std::string& name) const = 0;
00098 
00099    /**
00100     *  Retrieves all animation controllers.
00101     *
00102     *  @return  A vector of animation controller pointers.  The returned vector
00103     *           should not be modified.  To change the vector contents, call
00104     *           createAnimationController() and destroyAnimationController()
00105     *           instead.
00106     */
00107    virtual const std::vector<AnimationController*>& getAnimationControllers() const = 0;
00108 
00109    /**
00110     *  Returns the current number of animation controllers.
00111     *
00112     *  This is a convenience method that is identical to
00113     *  getAnimationControllers().size().
00114     *
00115     *  @return  The current number of animation controllers.
00116     */
00117    virtual unsigned int getNumAnimationControllers() const = 0;
00118 
00119    /**
00120     *  Sets the current animation controller on the %Animation toolbar.
00121     *
00122     *  This method is a convenience method that calls
00123     *  AnimationToolBar::setAnimationController() passing in the given
00124     *  controller.
00125     *
00126     *  @param   pController
00127     *           The animation controller to activate on the %Animation toolbar.
00128     *
00129     *  @see     AnimationToolBar::setAnimationController()
00130     */
00131    virtual void setCurrentAnimationController(AnimationController* pController) = 0;
00132 
00133    /**
00134     *  Returns the current animation controller on the %Animation toolbar.
00135     *
00136     *  This method is a convenience method that calls
00137     *  AnimationToolBar::getAnimationController().
00138     *
00139     *  @return  A pointer to the current animation controller on the %Animation
00140     *           toolbar.
00141     *
00142     *  @see     AnimationToolBar::getAnimationController()
00143     */
00144    virtual AnimationController* getCurrentAnimationController() const = 0;
00145 
00146    /**
00147     *  Sets a new name for an animation controller.
00148     *
00149     *  @param   pController
00150     *           The animation controller to rename.
00151     *  @param   newName
00152     *           The new name for the controller.  The name cannot be the same
00153     *           as the name of any existing controller.
00154     *
00155     *  @return  Returns \b true if the controller was successfully renamed.
00156     *           Returns \b false if \em newName is empty or if an existing
00157     *           controller already has this name.
00158     *
00159     *  @notify  This method will notify AnimationController::signalRenamed()
00160     *           with boost::any<std::string> if the name is successfully set on
00161     *           the controller.
00162     */
00163    virtual bool renameAnimationController(AnimationController* pController, const std::string& newName) = 0;
00164 
00165    /**
00166     *  Destroys an existing animation controller.
00167     *
00168     *  This method destroys the given animation controller and all of the
00169     *  animations that it contains.
00170     *
00171     *  @param   pController
00172     *           The animation controller to destroy.
00173     *
00174     *  @notify  This method will notify signalControllerDestroyed() with
00175     *           any<AnimationController*> after the animation controller has
00176     *           removed but before the it is deleted.
00177     *
00178     *  @see     Animation
00179     */
00180    virtual void destroyAnimationController(AnimationController* pController) = 0;
00181 
00182    /**
00183     *  Returns a frame value as a formatted string.
00184     *
00185     *  @param   frame
00186     *           The animation frame containing the value to convert to a string.
00187     *  @param   frameType
00188     *           The frame type that specifies the format of the returned string.
00189     *
00190     *  @return  Returns a formatted string based on the frame type containing
00191     *           the frame value as follows:
00192     *           <table>
00193     *           <tr>
00194     *              <td align="center"><b>Frame Type</b></td>
00195     *              <td align="center"><b>Format</b></td>
00196     *              <td align="center"><b>Description</b></td>
00197     *           </tr>
00198     *           <tr>
00199     *              <td>::FRAME_ID</td>
00200     *              <td>"n"</td>
00201     *              <td>One-based numeric frame number</td>
00202     *           </tr>
00203     *           <tr>
00204     *              <td>::FRAME_TIME</td>
00205     *              <td>"yyyy/MM/dd hh:mm:ss.zzz"</td>
00206     *              <td>Year, month, day, hours, minutes, seconds, and milliseconds</td>
00207     *           </tr>
00208     *           <tr>
00209     *              <td>::FRAME_ELAPSED_TIME</td>
00210     *              <td>"hh:mm:ss.zzz"</td>
00211     *              <td>Hours, minutes, seconds, and milliseconds</td>
00212     *           </tr>
00213     *           </table>
00214     *           An empty string is returned if \e frameType is invalid or if
00215     *           \e frameType  is ::FRAME_TIME or ::FRAME_ELAPSED_TIME and the
00216     *           value has not been set.
00217     */
00218    virtual std::string frameToString(const AnimationFrame& frame, FrameType frameType) const = 0;
00219 
00220 protected:
00221    /**
00222     *  This class will be destroyed during application close.  Plug-ins do not
00223     *  need to destroy it.
00224     */
00225    virtual ~AnimationServices() {}
00226 };
00227 
00228 #endif

Software Development Kit - Opticks 4.9.0 Build 16218