00001 /**************************************************************************** 00002 00003 This file is part of the GLC-lib library. 00004 Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net) 00005 http://glc-lib.sourceforge.net 00006 00007 GLC-lib is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU Lesser General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 GLC-lib is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public License 00018 along with GLC-lib; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 00021 *****************************************************************************/ 00023 00024 #ifndef GLC_3DWIDGET_H_ 00025 #define GLC_3DWIDGET_H_ 00026 #include <QObject> 00027 #include <QList> 00028 #include "../glc_config.h" 00029 #include "../glc_global.h" 00030 #include "glc_3dwidgetmanagerhandle.h" 00031 00032 class GLC_3DViewInstance; 00033 00036 00040 00041 class GLC_LIB_EXPORT GLC_3DWidget : public QObject 00042 { 00043 Q_OBJECT 00044 00045 typedef QList<GLC_uint> InstanceIdList; 00046 00048 00050 00051 public: 00053 GLC_3DWidget(GLC_3DWidgetManagerHandle* pWidgetManagerHandle= NULL); 00054 00056 GLC_3DWidget(const GLC_3DWidget& widget); 00057 00059 virtual ~GLC_3DWidget(); 00061 00063 00065 00066 public: 00068 inline GLC_uint id() const 00069 {return m_Uid;} 00070 00072 bool operator==(const GLC_3DWidget& widget) const; 00073 00075 inline bool instanceBelongTo(GLC_uint id) const 00076 {return m_InstanceIdList.contains(id);} 00077 00079 inline const GLC_3DWidgetManagerHandle* widgetManagerHandle() const 00080 {return m_pWidgetManagerHandle;} 00081 00083 inline bool has3DWidgetManager() const 00084 {return (NULL == m_pWidgetManagerHandle);} 00085 00087 inline bool useOrtho() const 00088 {return m_pWidgetManagerHandle->useOrtho();} 00089 00091 00093 00095 00096 public: 00098 virtual GLC_3DWidget& operator=(const GLC_3DWidget& widget); 00099 00101 void setWidgetManager(GLC_3DWidgetManagerHandle* pWidgetManagerHandle); 00102 00104 virtual void updateWidgetRep(){}; 00105 00107 void setVisible(bool visible); 00109 00111 00113 00114 public: 00115 00117 virtual glc::WidgetEventFlag select(const GLC_Point3d&, GLC_uint id); 00118 00120 virtual glc::WidgetEventFlag unselect(const GLC_Point3d&, GLC_uint id); 00121 00123 virtual glc::WidgetEventFlag mouseOver(const GLC_Point3d&, GLC_uint id); 00124 00126 virtual glc::WidgetEventFlag mousePressed(const GLC_Point3d&, Qt::MouseButton, GLC_uint id); 00127 00129 virtual glc::WidgetEventFlag mouseReleased(Qt::MouseButton); 00130 00132 virtual glc::WidgetEventFlag mouseMove(const GLC_Point3d&, Qt::MouseButtons, GLC_uint id); 00133 00135 00136 signals: 00138 void asChanged(); 00139 00141 // Protected services function 00143 protected: 00145 virtual void create3DviewInstance()= 0; 00146 00148 inline bool isEmpty() const 00149 {return m_InstanceIdList.isEmpty();} 00150 00152 void add3DViewInstance(const GLC_3DViewInstance& instance); 00153 00155 inline GLC_3DViewInstance* instanceHandle(int index) 00156 {return m_pWidgetManagerHandle->instanceHandle(m_InstanceIdList.at(index));} 00157 00159 void remove3DViewInstance(); 00160 00162 void set3DViewInstanceVisibility(int index, bool visibility); 00163 00165 inline int indexOfIntsanceId(GLC_uint id) 00166 {return m_InstanceIdList.indexOf(id);} 00167 00169 virtual void resetViewState()= 0; 00170 00172 // Private services function 00174 private: 00175 00177 // Private Member 00179 private: 00181 00182 GLC_uint m_Uid; 00183 00185 GLC_3DWidgetManagerHandle* m_pWidgetManagerHandle; 00186 00188 QList<GLC_uint> m_InstanceIdList; 00189 00190 }; 00191 00192 #endif /* GLC_3DWIDGET_H_ */