]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMGUI/GeometryGUI_SolidDlg.cxx
Salome HOME
Dcq : Add MakeShell MakeSolid and New GUI Architecture
[modules/geom.git] / src / GEOMGUI / GeometryGUI_SolidDlg.cxx
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : GeometryGUI_SolidDlg.cxx
25 //  Author : Damien COQUERET
26 //  Module : GEOM
27 //  $Header: 
28
29 using namespace std;
30 #include "GeometryGUI_SolidDlg.h"
31
32 #include "GeometryGUI.h"
33 #include "QAD_Desktop.h"
34
35 //=================================================================================
36 // class    : GeometryGUI_SolidDlg()
37 // purpose  : Constructs a GeometryGUI_SolidDlg which is a child of 'parent', with the 
38 //            name 'name' and widget flags set to 'f'.
39 //            The dialog will by default be modeless, unless you set 'modal' to
40 //            TRUE to construct a modal dialog.
41 //=================================================================================
42 GeometryGUI_SolidDlg::GeometryGUI_SolidDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl)
43   :GeometryGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
44 {
45   QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_DLG_BUILD_SOLID")));
46   QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_SELECT")));
47
48   setCaption(tr("GEOM_SOLID_TITLE"));
49     
50   /***************************************************************/
51   GroupConstructors->setTitle(tr("GEOM_SOLID"));
52   RadioButton1->setPixmap(image0);
53   RadioButton2->close(TRUE);
54   RadioButton3->close(TRUE);
55
56   GroupSolid = new GeometryGUI_1Sel_QTD(this, "GroupSolid");
57   GroupSolid->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
58   GroupSolid->TextLabel1->setText(tr("GEOM_OBJECTS"));
59   GroupSolid->PushButton1->setPixmap(image1);
60   
61   Layout1->addWidget(GroupSolid, 1, 0);
62   /***************************************************************/
63
64   /* Initialisations */
65   Init(Sel);
66 }
67
68
69 //=================================================================================
70 // function : ~GeometryGUI_SolidDlg()
71 // purpose  : Destroys the object and frees any allocated resources
72 //=================================================================================
73 GeometryGUI_SolidDlg::~GeometryGUI_SolidDlg()
74 {
75     // no need to delete child widgets, Qt does it all for us
76 }
77
78
79 //=================================================================================
80 // function : Init()
81 // purpose  :
82 //=================================================================================
83 void GeometryGUI_SolidDlg::Init(SALOME_Selection* Sel)
84 {
85   /* init variables */
86   myEditCurrentArgument = GroupSolid->LineEdit1;
87   myOkListShapes = false;
88
89   myShellFilter = new GEOM_ShapeTypeFilter(TopAbs_SHELL, myGeom);
90   /* filter for next selection */
91   mySelection->AddFilter(myShellFilter);
92
93   /* signals and slots connections */
94   connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
95   connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
96
97   connect(GroupSolid->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
98
99   connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
100  
101   /* displays Dialog */
102   GroupSolid->show();
103   this->show();
104
105   return;
106 }
107
108
109 //=================================================================================
110 // function : ClickOnOk()
111 // purpose  :
112 //=================================================================================
113 void GeometryGUI_SolidDlg::ClickOnOk()
114 {
115   this->ClickOnApply();
116   ClickOnCancel();
117   return ;
118 }
119
120 //=================================================================================
121 // function : ClickOnApply()
122 // purpose  :
123 //=================================================================================
124 void GeometryGUI_SolidDlg::ClickOnApply()
125 {
126   myGeomGUI->GetDesktop()->putInfo(tr("")); 
127
128   if(myOkListShapes)  
129     myGeomGUI->MakeSolidAndDisplay(myListShapes);
130
131   return;
132 }
133
134
135 //=================================================================================
136 // function : SelectionIntoArgument()
137 // purpose  : Called when selection as changed or other case
138 //=================================================================================
139 void GeometryGUI_SolidDlg::SelectionIntoArgument()
140 {
141   myEditCurrentArgument->setText("");
142   QString aString = "";
143
144   myOkListShapes = false;
145   int nbSel = mySelection->IObjectCount();
146   if (nbSel == 0) 
147     return;
148
149   aString = tr("%1_objects").arg(nbSel);
150   
151   myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes);
152   myEditCurrentArgument->setText(aString);
153   myOkListShapes = true;
154
155   return ;
156 }
157
158 //=================================================================================
159 // function : SetEditCurrentArgument()
160 // purpose  :
161 //=================================================================================
162 void GeometryGUI_SolidDlg::SetEditCurrentArgument()
163 {
164   QPushButton* send = (QPushButton*)sender();
165   mySelection->ClearFilters() ;
166
167   if(send == GroupSolid->PushButton1) {
168     GroupSolid->LineEdit1->setFocus();
169     myEditCurrentArgument = GroupSolid->LineEdit1;
170     mySelection->AddFilter(myShellFilter);
171   }
172   SelectionIntoArgument();
173
174   return ;
175 }
176
177
178 //=================================================================================
179 // function : ActivateThisDialog()
180 // purpose  :
181 //=================================================================================
182 void GeometryGUI_SolidDlg::ActivateThisDialog()
183 {
184   GeometryGUI_Skeleton::ActivateThisDialog();
185   connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
186   return ;
187 }
188
189
190 //=================================================================================
191 // function : enterEvent()
192 // purpose  :
193 //=================================================================================
194 void GeometryGUI_SolidDlg::enterEvent(QEvent* e)
195 {
196   if (GroupConstructors->isEnabled())
197     return;  
198   this->ActivateThisDialog();
199   return;
200 }