glc_3dwidget.cpp

Go to the documentation of this file.
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 #include "glc_3dwidget.h"
00027 
00028 
00029 GLC_3DWidget::GLC_3DWidget(GLC_3DWidgetManagerHandle*  pWidgetManagerHandle)
00030 : QObject()
00031 , m_Uid(glc::GLC_Gen3DWidgetID())
00032 , m_pWidgetManagerHandle(pWidgetManagerHandle)
00033 , m_InstanceIdList()
00034 {
00035 
00036 }
00037 
00038 GLC_3DWidget::GLC_3DWidget(const GLC_3DWidget& widget)
00039 : QObject()
00040 , m_Uid(glc::GLC_Gen3DWidgetID())
00041 , m_pWidgetManagerHandle(widget.m_pWidgetManagerHandle)
00042 , m_InstanceIdList()
00043 {
00044         // Copy the 3Dview instance of the widget
00045         const int size= widget.m_InstanceIdList.size();
00046         for (int i= 0; i < size; ++i)
00047         {
00048                 GLC_3DViewInstance newInstance(widget.m_pWidgetManagerHandle->instanceHandle(widget.m_InstanceIdList.at(i))->deepCopy());
00049                 GLC_uint newId= newInstance.id();
00050                 m_InstanceIdList.append(newId);
00051                 m_pWidgetManagerHandle->add3DViewInstance(newInstance, m_Uid);
00052         }
00053 }
00054 
00055 GLC_3DWidget::~GLC_3DWidget()
00056 {
00057         remove3DViewInstance();
00058 }
00059 
00060 bool GLC_3DWidget::operator==(const GLC_3DWidget& widget) const
00061 {
00062         return this == &widget;
00063 }
00064 
00065 GLC_3DWidget& GLC_3DWidget::operator=(const GLC_3DWidget& widget)
00066 {
00067         if (this != &widget)
00068         {
00069                 remove3DViewInstance();
00070 
00071                 m_Uid= widget.m_Uid;
00072                 m_pWidgetManagerHandle= widget.m_pWidgetManagerHandle;
00073                 m_InstanceIdList= widget.m_InstanceIdList;
00074 
00075                 // Copy the 3Dview instance of the widget
00076                 const int size= widget.m_InstanceIdList.size();
00077                 for (int i= 0; i < size; ++i)
00078                 {
00079                         GLC_3DViewInstance newInstance(widget.m_pWidgetManagerHandle->instanceHandle(widget.m_InstanceIdList.at(i))->deepCopy());
00080                         GLC_uint newId= newInstance.id();
00081                         m_InstanceIdList.append(newId);
00082                         m_pWidgetManagerHandle->add3DViewInstance(newInstance, m_Uid);
00083                 }
00084         }
00085         return *this;
00086 }
00087 
00088 void GLC_3DWidget::setWidgetManager(GLC_3DWidgetManagerHandle* pWidgetManagerHandle)
00089 {
00090         if (NULL != m_pWidgetManagerHandle)
00091         {
00092                 m_pWidgetManagerHandle->take(m_Uid);
00093                 remove3DViewInstance();
00094         }
00095         m_pWidgetManagerHandle= pWidgetManagerHandle;
00096 
00097         create3DviewInstance();
00098 }
00099 
00101 // Interaction Functions
00103 glc::WidgetEventFlag GLC_3DWidget::select(const GLC_Point3d&, GLC_uint)
00104 {
00105         return glc::IgnoreEvent;
00106 }
00107 
00108 glc::WidgetEventFlag GLC_3DWidget::unselect(const GLC_Point3d&, GLC_uint)
00109 {
00110         return glc::IgnoreEvent;
00111 }
00112 
00113 glc::WidgetEventFlag GLC_3DWidget::mouseOver(const GLC_Point3d&, GLC_uint)
00114 {
00115         return glc::IgnoreEvent;
00116 }
00117 
00118 glc::WidgetEventFlag GLC_3DWidget::mousePressed(const GLC_Point3d&, Qt::MouseButton, GLC_uint)
00119 {
00120         return glc::IgnoreEvent;
00121 }
00122 
00123 glc::WidgetEventFlag GLC_3DWidget::mouseReleased(Qt::MouseButton)
00124 {
00125         return glc::IgnoreEvent;
00126 }
00127 
00128 glc::WidgetEventFlag GLC_3DWidget::mouseMove(const GLC_Point3d&, Qt::MouseButtons, GLC_uint)
00129 {
00130         return glc::IgnoreEvent;
00131 }
00132 
00133 
00135 // Protected services functions
00137 void GLC_3DWidget::add3DViewInstance(const GLC_3DViewInstance& instance)
00138 {
00139         m_pWidgetManagerHandle->add3DViewInstance(instance, m_Uid);
00140         const GLC_uint instanceId= instance.id();
00141         m_InstanceIdList.append(instanceId);
00142 }
00143 
00144 void GLC_3DWidget::remove3DViewInstance()
00145 {
00146         if (NULL != m_pWidgetManagerHandle)
00147         {
00148                 const int size= m_InstanceIdList.size();
00149                 for (int i= 0; i < size; ++i)
00150                 {
00151                         m_pWidgetManagerHandle->remove3DViewInstance(m_InstanceIdList.at(i));
00152                 }
00153         }
00154 }
00155 
00156 void GLC_3DWidget::set3DViewInstanceVisibility(int index, bool visibility)
00157 {
00158         m_pWidgetManagerHandle->instanceHandle(m_InstanceIdList[index])->setVisibility(visibility);
00159 }
00160 
00161 

SourceForge.net Logo

©2005 Laurent Ribon