00001 /**************************************************************************** 00002 00003 This file is part of the GLC-lib library. 00004 Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net) 00005 Version 2.0.0 Beta 1, packaged on April 2010. 00006 00007 http://glc-lib.sourceforge.net 00008 00009 GLC-lib is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 2 of the License, or 00012 (at your option) any later version. 00013 00014 GLC-lib is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with GLC-lib; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00022 00023 *****************************************************************************/ 00025 00026 #ifndef GLC_3DWIDGET_H_ 00027 #define GLC_3DWIDGET_H_ 00028 #include <QObject> 00029 #include <QList> 00030 #include "../glc_config.h" 00031 #include "../glc_global.h" 00032 #include "glc_3dwidgetmanagerhandle.h" 00033 00034 class GLC_3DViewInstance; 00035 00038 00042 00043 class GLC_LIB_EXPORT GLC_3DWidget : public QObject 00044 { 00045 Q_OBJECT 00046 00047 typedef QList<GLC_uint> InstanceIdList; 00048 00050 00052 00053 public: 00055 GLC_3DWidget(GLC_3DWidgetManagerHandle* pWidgetManagerHandle= NULL); 00056 00058 GLC_3DWidget(const GLC_3DWidget& widget); 00059 00061 virtual ~GLC_3DWidget(); 00063 00065 00067 00068 public: 00070 inline GLC_uint id() const 00071 {return m_Uid;} 00072 00074 bool operator==(const GLC_3DWidget& widget) const; 00075 00077 inline bool instanceBelongTo(GLC_uint id) const 00078 {return m_InstanceIdList.contains(id);} 00079 00081 inline const GLC_3DWidgetManagerHandle* widgetManagerHandle() const 00082 {return m_pWidgetManagerHandle;} 00083 00085 inline bool has3DWidgetManager() const 00086 {return (NULL == m_pWidgetManagerHandle);} 00087 00089 inline bool useOrtho() const 00090 {return m_pWidgetManagerHandle->useOrtho();} 00091 00093 00095 00097 00098 public: 00100 virtual GLC_3DWidget& operator=(const GLC_3DWidget& widget); 00101 00103 void setWidgetManager(GLC_3DWidgetManagerHandle* pWidgetManagerHandle); 00104 00106 virtual void updateWidgetRep(){}; 00108 00110 00112 00113 public: 00114 00116 virtual glc::WidgetEventFlag select(const GLC_Point3d&, GLC_uint id); 00117 00119 virtual glc::WidgetEventFlag unselect(const GLC_Point3d&, GLC_uint id); 00120 00122 virtual glc::WidgetEventFlag mouseOver(const GLC_Point3d&, GLC_uint id); 00123 00125 virtual glc::WidgetEventFlag mousePressed(const GLC_Point3d&, Qt::MouseButton, GLC_uint id); 00126 00128 virtual glc::WidgetEventFlag mouseReleased(Qt::MouseButton); 00129 00131 virtual glc::WidgetEventFlag mouseMove(const GLC_Point3d&, Qt::MouseButtons, GLC_uint id); 00132 00134 00135 signals: 00137 void asChanged(); 00138 00140 // Protected services function 00142 protected: 00144 virtual void create3DviewInstance()= 0; 00145 00147 inline bool isEmpty() const 00148 {return m_InstanceIdList.isEmpty();} 00149 00151 void add3DViewInstance(const GLC_3DViewInstance& instance); 00152 00154 inline GLC_3DViewInstance* instanceHandle(int index) 00155 {return m_pWidgetManagerHandle->instanceHandle(m_InstanceIdList.at(index));} 00156 00158 void remove3DViewInstance(); 00159 00161 void set3DViewInstanceVisibility(int index, bool visibility); 00162 00164 inline int indexOfIntsanceId(GLC_uint id) 00165 {return m_InstanceIdList.indexOf(id);} 00166 00168 // Private services function 00170 private: 00171 00173 // Private Member 00175 private: 00177 00178 GLC_uint m_Uid; 00179 00181 GLC_3DWidgetManagerHandle* m_pWidgetManagerHandle; 00182 00184 QList<GLC_uint> m_InstanceIdList; 00185 00186 }; 00187 00188 #endif /* GLC_3DWIDGET_H_ */