#ifndef _PROJECTION_MODEL_H_ #define _PROJECTION_MODEL_H_ #include #include #include #include #include "Version.h" #include "interfaces.h" namespace projection { class Scene; class Screen; class Channel; class RSync; class Exporter; class GUIControler; //! Default port number. #define DEFAULT_PORT_NO 55555 //! Design mode. enum DESIGN_MODE { DESIGN_MODE_DISTORTIONMAP, //!< Distortion map design mode. DESIGN_MODE_BLENDMAP //!< Blend map design mode. }; /** * Projection model class. It contains all projection settings. */ class ProjectionModel : public QObject { public: /** * Constructor. */ ProjectionModel(); /** * Destructor. */ virtual ~ProjectionModel(); /** * Initialize as a server. * * @param portNo Port number. */ void initServer(int portNo=DEFAULT_PORT_NO); /** * Initialize as a client. * * @param address Client address. * @param portNo Port number. */ void initClient(const QString& address=QString::null, int portNo=DEFAULT_PORT_NO); /** * Add a new channel. * * @return New channel. */ Channel* addChannel(); /** * Retrieve the number of the channels. * * @return The number of the channels. */ unsigned int getNumChannels() const; /** * Retrieve a channel object * * @param index Index of channel to retrieve. * @return Channel object. */ Channel* getChannel(int index) const; /** * Retrieve Index of the specified channel. * * @param pChannel Channel object. * @return Index of the specified channel. */ int getChannelIndex(Channel* pChannel) const; /** * Remove the specified channel. * * @param index Index of the channel to remove. */ void removeChannel(int index); /** * Remove all channels. */ void removeAllChannels(); /** * Select a channel. * * @param pChannel Channel object to select. */ void selectChannel(Channel* pChannel); /** * Retrieve the selected channel object. * * @return Selected channel object. */ Channel* getSelectedChannel() const; /** * Select the previous channel. */ void selectPreviousChannel(); /** * Select the next channel. */ void selectNextChannel(); /** * Check whether any channels with the specified name is existing or not. * * @return True if a channel with the specified name is existing. */ bool hasChannel(const QString& name) const; /** * Create a unique name for specified channel. * * @param name Candidate name of channel. It may not be a unique name. * @param pChannel Channel object to give a name. * @return Unique name for the specified channel. */ QString getUniqueName(const QString& name, Channel* pChannel) const; /** * Create a projection area texture and retrieve its texture object index. * * @return Texture object index of the projection area texture. */ GLuint getProjectorAreaTexture(); /** * Create a view area texture and retrieve its texture object index. * * @return Texture object index of the view area texture. */ GLuint getViewAreaTexture(); /** * Set design mode. * * @param designMode Design mode. */ void setDesignMode(DESIGN_MODE designMode); /** * Retrieve the current design mode. * * @param designMode Design mode. */ DESIGN_MODE getDesignMode() const; /** * Block or unblock to update views. * * @param bBlock True to block updating views. */ void setBlockUpdate(bool bBlock); /** * Check whether blocking or not update views. * * @return True if blocking to update views. */ bool getBlockUpdate() const; /** * Redraw all views (DesignViewWindow and ProjectorWindows). */ void updateViews(); /** * Redraw off-screen buffer of the specified channel, then redraw all views. */ void updateViewAndOffscreens(); /** * Load projection settings from a file. * * @param fileName File name to load. * @return True if successfully loaded. */ bool loadFile(const QString& fileName); /** * Save the current projection settings to a file. * * @param fileName File name to save. * @return True if successfully saved. */ bool saveFile(const QString& fileName); /** * Restart from a new file. * * @return True if everything is ok. */ bool newFile(void); /** * Restore the model from XML data. * * @param element Parent XML element of the model data. */ bool initFromDOMElement(const QDomElement& element); /** * Store the current model as XML data. * * @param name XML node name of the data. * @param doc XML document to store the data. * @return Current screen data as XML data. */ QDomElement domElement(const QString& name, QDomDocument& doc) const; /** * Restore projection settings from xml data. * * @param doc XML document to restore the projection settings from. */ bool restoreSettings(QDomDocument& doc); /** * Store projection settings to xml data. * * @param doc XML document to store the projection settings. */ void storeSettings(QDomDocument& doc); /** * Retrieve the scene object. * * @return Scene object. */ Scene* getScene() const; /** * Retrieve the screen object. * * @return Screen object. */ Screen* getScreen() const; /** * Retrieve the remote state synchronize object. * * @return Remote state synchronize object. */ RSync* getRSync() const; /** * Retrieve the exporter object. * * @return Exporter object. */ Exporter* getExporter() const; /** * Retrieve the GUI controler object. * * @return GUI controler object. */ GUIControler* getGUI() const; /** * Set a GLWidget for the current render context. * * @parma pGLWidget GLWidget of the current render context. */ void setRenderContext(QGLWidget* pGLWidget); /** * Set a P-Buffer for the current render context. * * @parma pPBuffer P-Buffer of the current render context. */ void setRenderContext(QGLPixelBuffer* pPBuffer); /** * Activate the current render context. */ void activateRenderContext(); #ifdef _DEBUG int m_updateViewsCount; int m_updateOffscreenCount; #endif // _DEBUG /// Plugins static QList projector_interfaces; static QList scene_interfaces; static QDir pluginsDir; static QStringList pluginFileNames; protected: Scene* m_pScene; //!< Scene object. Screen* m_pScreen; //!< Screen object. QList m_pChannels; //!< Channel objects. Channel* m_pSelectedChannel; //!< Selected channel object. DESIGN_MODE m_designMode; //!< Design mode. bool m_bBlockUpdate; //!< True if blocking to update views. RSync* m_pRSync; //!< Remote state synchronize object. Exporter* m_pExporter; //!< Exporter object. GUIControler* m_pGUI; //!< GUI controler object. GLuint m_projectorAreaTexIndex; //!< Texture object index of the projection area texture. GLuint m_viewAreaTexIndex; //!< Texture object index of the view area texture. QGLWidget* m_pGLWidget; //!< GLWidget of the current render context. QGLPixelBuffer* m_pPBuffer; //!< GLPixelBuffer of the current render context. private: void loadPlugins(); }; }; // projection #endif // _PROJECTION_MODEL_H_