File indexing completed on 2024-05-12 16:23:26
0001 /*************************************************************************** 0002 * Copyright (C) 2013 by Linuxstopmotion contributors; * 0003 * see the AUTHORS file for details. * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 0021 #ifndef SCENEVECTOR_H_ 0022 #define SCENEVECTOR_H_ 0023 0024 #include <vector> 0025 0026 #include "animationimpl.h" 0027 0028 class Scene; 0029 class Frame; 0030 class Sound; 0031 class FileNameVisitor; 0032 class WorkspaceFile; 0033 class AudioDriver; 0034 0035 class SceneVector : public AnimationImpl { 0036 std::vector<Scene*> scenes; 0037 int totalSoundCount; 0038 0039 Scene* getMutableScene(int); 0040 SceneVector(const SceneVector&); 0041 SceneVector& operator=(const SceneVector&); 0042 public: 0043 SceneVector(); 0044 ~SceneVector(); 0045 /** 0046 * Clears the animation so that there are no scenes and no frames. 0047 */ 0048 void clear(); 0049 /** 0050 * Returns the number of scenes in the animation. 0051 * @return The number of scenes. 0052 */ 0053 int sceneCount() const; 0054 /** 0055 * Adds a scene to the animation. 0056 * @param where Where in the sequence of scenes to insert this one. Must be 0057 * between 0 and {@c SceneCount()} inclusive. 0058 * @param newScene The scene to be inserted; ownership is passed. 0059 */ 0060 void addScene(int where, Scene* newScene); 0061 /** 0062 * Adds a fresh empty scene. 0063 * @param where The scene number that this new scene will have. 0064 */ 0065 void addScene(int where); 0066 /** 0067 * Preallocates memory so that AddScene can be called without the risk of 0068 * throwing an exception. 0069 * @param count Number of calls to @ref AddScene required without 0070 * exceptions being thrown. 0071 */ 0072 void preallocateScenes(int count); 0073 /** 0074 * Removes a scene from the animation, together with all its frames. 0075 * @param from The scene to remove. Must be between 0 and @code{.cpp} 0076 * SceneCount() - 1 @endcode inclusive. 0077 * @return The removed scene. Ownership is returned. 0078 */ 0079 Scene* removeScene(int from); 0080 /** 0081 * Moves a scene. 0082 * @param from The scene number to move. Must be between 0 and 0083 * {@c SceneCount()} inclusive. 0084 * @param from The number the scene is to become. Must be between 0 and 0085 * {@c SceneCount()} inclusive. 0086 */ 0087 void moveScene(int from, int to); 0088 /** 0089 * Returns the scene requested, which must not be modified. 0090 * @param which The number of the scene to be returned. 0091 * @return The scene requested. 0092 */ 0093 const Scene* getScene(int which) const; 0094 /** 0095 * Returns the number of frames in scene number @a scene. 0096 * @param scene The number of the scene to query. 0097 * @return The number of frames in scene number @a scene. 0098 */ 0099 int frameCount(int scene) const; 0100 /** 0101 * Adds a frame to the animation. 0102 * @param scene The number of the scene to add the frames to. 0103 * @param where The number of the frame within scene number @a scene to 0104 * add the frame. 0105 * @param frame The frame to add. Ownership is passed. 0106 */ 0107 void addFrame(int scene, int where, Frame* frame); 0108 /** 0109 * Adds frames to the animation. 0110 * @param scene The scene to which the frames will be added. 0111 * @param where The frame number for the first of the added frames. 0112 * @param frames The frames to add. 0113 * @note On failure, no frames will have been added. 0114 */ 0115 void addFrames(int scene, int where, const std::vector<Frame*>& frames); 0116 /** 0117 * Preallocates enough memory for @ref AddFrames to add @a count frames 0118 * to scene number @scene. 0119 */ 0120 void preallocateFrames(int scene, int count); 0121 /** 0122 * Removes a frame from the animation. 0123 * @param scene The scene to remove the frame from. 0124 * @param frame The number of the first frame within scene @a scene 0125 * to remove. 0126 * @return The removed frame; ownership is returned. 0127 * @throws Will not throw. 0128 */ 0129 Frame* removeFrame(int scene, int frame); 0130 /** 0131 * Removes frames from the animation. 0132 * @param scene The scene from which to remove the frames. 0133 * @param frame The first frame to remove. 0134 * @param count The number of frames to remove. 0135 * @param [out] out The removed frames will be added to the end of this 0136 * vector. Ownership is returned. 0137 * @note Upon failure, {@a out} and the animation will both be untouched. 0138 * @pre The scene must have at least @code{.cpp} frame + count @endcode 0139 * frames. 0140 */ 0141 void removeFrames(int scene, int frame, int count, std::vector<Frame*>& out); 0142 /** 0143 * Moves frames. 0144 * @param fromScene The number of the scene from which to move frames. 0145 * @param fromFrame The number of the frame within scene @a fromScene from 0146 * which frames should be moved. 0147 * @param frameCount The number of frames to move. All the frames must be 0148 * from the same scene. 0149 * @param toScene The number of the scene to which to move the frames. 0150 * @param toFrame The number of the frame within scene @a toScene to which 0151 * the frames should be moved. 0152 */ 0153 void moveFrames(int fromScene, int fromFrame, int frameCount, 0154 int toScene, int toFrame); 0155 /** 0156 * Returns the file path of the image of the specified frame. 0157 */ 0158 const char* getImagePath(int scene, int frame) const; 0159 /** 0160 * Replaces the image of the frame at index {@a frameNumber} of scene 0161 * {@a sceneNumber}. 0162 * @param sceneNumber The index of the scene containing the frame to alter. 0163 * @param frameNumber The index of the frame to alter. 0164 * @param [in,out] The image to swap with. On exit, the frame at index 0165 * {@a frameNumber} will have the image formerly held by 0166 * {@a otherImage} and {@a otherImage} will have the image formerly held 0167 * by the frame. 0168 */ 0169 void replaceImage(int sceneNumber, int frameNumber, 0170 WorkspaceFile& otherImage); 0171 /** 0172 * Returns the number of sounds attached to a frame. 0173 * @param scene The number of the scene that contains the frame that you 0174 * need to examine. 0175 * @param frame The number of the frame from @a scene to examine. 0176 * @return The number of sounds attached to frame number @a frame of scene 0177 * @a scene. 0178 */ 0179 int soundCount(int scene, int frame) const; 0180 /** 0181 * Returns the total number of sounds in the animation. 0182 */ 0183 int soundCount() const; 0184 /** 0185 * Adds a sound to a frame of animation. 0186 * @param scene The number of the scene containing the frame to add the 0187 * sound to. 0188 * @param frame The number of the frame within scene number @a scene to 0189 * add the sound to. 0190 * @param soundNumber The position of the sound to add. Must be between 0191 * 0 and @code{.cpp} SoundCount(scene, frame) @endcode inclusive. 0192 * @param sound The name sound to add. Ownership is passed. 0193 */ 0194 void addSound(int scene, int frame, int soundNumber, 0195 Sound* sound); 0196 /** 0197 * changes the name of a sound of a frame. 0198 * @param scene The number of the scene containing the frame to change. 0199 * @param frame The number of the frame within scene number @a scene 0200 * containing the sound to be named. 0201 * @param soundNumber Which sound within frame number @a frame of scene 0202 * number @a scene to be replaced. 0203 * @param soundName The new name of the sound to be added. Ownership 0204 * is passed; must have been created with {@c new char[]}. 0205 * @return The old name of the sound. Ownership is returned; must be 0206 * deleted with {@c delete[]}. 0207 * @throws Nothing. 0208 */ 0209 const char* setSoundName(int scene, int frame, int soundNumber, 0210 const char* soundName); 0211 /** 0212 * Removes a sound of a frame. 0213 * @param scene The number of the scene containing the frame to change. 0214 * @param frame The number of the frame within scene number @a scene 0215 * containing the sound to be changed. 0216 * @param soundNumber Which sound within frame number @a frame of scene 0217 * number @a scene to be removed. 0218 * @return The file name of the sound that is being removed. Ownership 0219 * is returned. 0220 * @throws Nothing. 0221 */ 0222 Sound* removeSound(int scene, int frame, int soundNumber); 0223 /** 0224 * Plays the sounds attached to the specified frame. 0225 * @param scene The number of the scene containing the sounds. 0226 * @param frame The number of the frame within scene number @a scene 0227 * @param audioDriver The audio driver to play the sounds with 0228 */ 0229 void playSounds(int scene, int frame, AudioDriver* audioDriver) const; 0230 void accept(FileNameVisitor& v) const; 0231 }; 0232 0233 #endif /* SCENEVECTOR_H_ */