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