00001 /************************************************************************************ 00002 ** 00003 ** This file is part of the QtOPENCASCADE Toolkit. 00004 ** 00005 ** Copyright (C) 2006, 2007, 2008 QtOCC Team Members 00006 ** Peter Dolbey, Marc Britten, Stephane Routelous 00007 ** Stefan Boeykens, Pawel Dobrolowski, Walter Steffe 00008 ** Álvaro Castro Castilla, Dirk Burski, Fotis Sioutis 00009 ** 00010 ** This library is free software; you can redistribute it and/or 00011 ** modify it under the terms of the GNU Lesser General Public 00012 ** License as published by the Free Software Foundation; either 00013 ** version 2.1 of the License, or (at your option) any later version. 00014 ** 00015 ** This library is distributed in the hope that it will be useful, 00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 ** Lesser General Public License for more details. 00019 ** 00020 ** You should have received a copy of the GNU Lesser General Public 00021 ** License along with this library; if not, write to the Free Software 00022 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00023 ** 00024 ***********************************************************************************/ 00025 00026 /*! 00027 \class QoccCmdPointDlg 00028 \brief This class provides the keyboard entry for the point / vertex command 00029 \author Peter C. Dolbey 00030 */ 00031 #include <QtGui/QAction> 00032 #include <QtGui/QMouseEvent> 00033 00034 #include <qnamespace.h> 00035 #include "commands/qocccmdpoint.h" 00036 #include "qoccinternal.h" 00037 #include "qocc3dwidget.h" 00038 00039 QoccDlgPoint::QoccDlgPoint( ) 00040 { 00041 00042 } 00043 00044 QoccDlgPoint::~QoccDlgPoint( ) 00045 { 00046 } 00047 00048 /*! 00049 \class QoccCmdPoint 00050 \brief This class provides the interactive entry for the circle-centre command 00051 \author Peter C. Dolbey 00052 */ 00053 00054 QoccCmdPoint::QoccCmdPoint( QAction* startingAction, QWidget* parent ) 00055 :QoccCommand( startingAction, parent ) 00056 { 00057 if ( myAction ) 00058 { 00059 myAction->setDisabled(true); 00060 } 00061 } 00062 00063 QoccCmdPoint::~QoccCmdPoint( ) 00064 { 00065 if ( myAction ) 00066 { 00067 myAction->setDisabled(false); 00068 } 00069 } 00070 00071 void QoccCmdPoint::moveEvent( Qocc3dWidget*, QMouseEvent* ) 00072 { 00073 00074 } 00075 00076 void QoccCmdPoint::clickEvent( Qocc3dWidget* widget, QMouseEvent* e ) 00077 { 00078 Q_UNUSED(e) 00079 QoccController* vc = widget->getController(); 00080 QoccDocument* doc = vc->getDocument(); 00081 TopAbs_ShapeEnum lc; 00082 int doc_id = doc->id(); 00083 double x = widget->x(); 00084 double y = widget->y(); 00085 double z = widget->z(); 00086 00087 bool hasLc = vc->hasLocalContext(); 00088 if (hasLc) 00089 { 00090 lc = vc->localContext(); 00091 vc->clearLocalContext(); 00092 } 00093 00094 qGeomApp->basicOps( doc_id )->StartOperation(); 00095 Handle(GEOM_Object) point = qGeomApp->basicOps( doc_id )->MakePointXYZ( x, y, z ); 00096 doc->RegisterPresentation(point); 00097 qGeomApp->basicOps( doc_id )->FinishOperation(); 00098 00099 if (hasLc) 00100 { 00101 vc->setLocalContext(lc); 00102 vc->update(); 00103 } 00104 } 00105