Salome HOME
Merge from V6_main 01/04/2013
[modules/geom.git] / src / MeasureGUI / MeasureGUI.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : MeasureGUI.cxx
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
26
27 #include "MeasureGUI.h"
28
29 #include <GeometryGUI.h>
30 #include "GeometryGUI_Operations.h"
31 #include <SUIT_Desktop.h>
32 #include <SalomeApp_Application.h>
33
34 #include "MeasureGUI_PropertiesDlg.h"    // Method PROPERTIES
35 #include "MeasureGUI_CenterMassDlg.h"    // Method CENTER MASS
36 #include "MeasureGUI_NormaleDlg.h"       // Method NORMALE
37 #include "MeasureGUI_InertiaDlg.h"       // Method INERTIA
38 #include "MeasureGUI_BndBoxDlg.h"        // Method BNDBOX
39 #include "MeasureGUI_DistanceDlg.h"      // Method DISTANCE
40 #include "MeasureGUI_AngleDlg.h"         // Method ANGLE
41 #include "MeasureGUI_MaxToleranceDlg.h"  // Method MAXTOLERANCE
42 #include "MeasureGUI_WhatisDlg.h"        // Method WHATIS
43 #include "MeasureGUI_CheckShapeDlg.h"    // Method CHECKSHAPE
44 #include "MeasureGUI_CheckCompoundOfBlocksDlg.h" // Method CHECKCOMPOUND
45 #include "MeasureGUI_GetNonBlocksDlg.h"  // Method GET NON BLOCKS
46 #include "MeasureGUI_CheckSelfIntersectionsDlg.h" // Method CHECK SELF INTERSCTIONS
47 #include "MeasureGUI_PointDlg.h"         // Method POINTCOORDINATES
48
49 #include <QApplication>
50
51 //=======================================================================
52 // function : MeasureGUI()
53 // purpose  : Constructor
54 //=======================================================================
55 MeasureGUI::MeasureGUI( GeometryGUI* parent ) : GEOMGUI( parent )
56 {
57 }
58
59 //=======================================================================
60 // function : ~MeasureGUI()
61 // purpose  : Destructor
62 //=======================================================================
63 MeasureGUI::~MeasureGUI()
64 {
65 }
66
67
68 //=======================================================================
69 // function : OnGUIEvent()
70 // purpose  : 
71 //=======================================================================
72 bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
73 {
74   SalomeApp_Application* app = getGeometryGUI()->getApp();
75   if ( !app ) return false;
76
77   getGeometryGUI()->EmitSignalDeactivateDialog();
78
79   QDialog* dlg = 0;
80   switch ( theCommandID ) {
81   case GEOMOp::OpProperties:
82     dlg = new MeasureGUI_PropertiesDlg( getGeometryGUI(), parent );
83     break; // LENGTH, AREA AND VOLUME
84   case GEOMOp::OpCenterMass:
85     dlg = new MeasureGUI_CenterMassDlg( getGeometryGUI(), parent );
86     break; // CENTER MASS7
87   case GEOMOp::OpInertia:
88     dlg = new MeasureGUI_InertiaDlg( getGeometryGUI(), parent );
89     break; // INERTIA
90   case GEOMOp::OpNormale : 
91     dlg = new MeasureGUI_NormaleDlg( getGeometryGUI(), parent );
92     break; // NORMALE
93   case GEOMOp::OpBoundingBox:
94     dlg = new MeasureGUI_BndBoxDlg( getGeometryGUI(), parent );
95     break; // BOUNDING BOX
96   case GEOMOp::OpMinDistance:
97     dlg = new MeasureGUI_DistanceDlg( getGeometryGUI(), parent );
98     break; // MIN DISTANCE
99   case GEOMOp::OpAngle: 
100     dlg = new MeasureGUI_AngleDlg( getGeometryGUI(), parent );
101     break; // ANGLE
102   case GEOMOp::OpTolerance: 
103     dlg = new MeasureGUI_MaxToleranceDlg( getGeometryGUI(), parent );
104     break; // MAXTOLERANCE
105   case GEOMOp::OpWhatIs:
106     dlg = new MeasureGUI_WhatisDlg( getGeometryGUI(), parent );
107     break; // WHATIS
108   case GEOMOp::OpCheckShape:
109     dlg = new MeasureGUI_CheckShapeDlg( getGeometryGUI(), parent );
110     break; // CHECKSHAPE
111   case GEOMOp::OpCheckCompound:
112     dlg = new MeasureGUI_CheckCompoundOfBlocksDlg( getGeometryGUI(), parent );
113     break; // CHECKCOMPOUND
114   case GEOMOp::OpGetNonBlocks:
115     dlg = new MeasureGUI_GetNonBlocksDlg(getGeometryGUI(), parent);
116     break; // GET NON BLOCKS
117   case GEOMOp::OpCheckSelfInters:
118     dlg = new MeasureGUI_CheckSelfIntersectionsDlg( getGeometryGUI(), parent );
119     break; // CHECK SELF INTERSCTIONS
120   case GEOMOp::OpPointCoordinates:
121     dlg = new MeasureGUI_PointDlg( getGeometryGUI(), parent );
122     break; // POINT COORDINATES
123   default: 
124     app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); 
125     break;
126   }
127   if ( dlg ) {
128     dlg->updateGeometry();
129     dlg->resize( dlg->minimumSizeHint() );
130     dlg->show();
131   }
132   return true;
133 }
134
135
136 //=====================================================================================
137 // EXPORTED METHODS
138 //=====================================================================================
139 extern "C"
140 {
141 #ifdef WIN32
142   __declspec( dllexport )
143 #endif
144   GEOMGUI* GetLibGUI( GeometryGUI* parent )
145   {
146     return new MeasureGUI( parent );
147   }
148 }