1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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, or (at your option) any later version.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : GenerationGUI_PipeDlg.cxx
25 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
27 #include "GenerationGUI_PipeDlg.h"
30 #include <GeometryGUI.h>
32 #include <GEOMUtils.hxx>
34 #include <SUIT_Session.h>
35 #include <SUIT_ResourceMgr.h>
36 #include <SalomeApp_Application.h>
37 #include <LightApp_SelectionMgr.h>
39 #include <TopoDS_Shape.hxx>
40 #include <TColStd_MapOfInteger.hxx>
42 #include <GEOMImpl_Types.hxx>
44 //=================================================================================
45 // class : GenerationGUI_PipeDlg()
46 // purpose : Constructs a GenerationGUI_PipeDlg which is a child of 'parent', with the
47 // name 'name' and widget flags set to 'f'.
48 // The dialog will by default be modeless, unless you set 'modal' to
49 // TRUE to construct a modal dialog.
50 //=================================================================================
51 GenerationGUI_PipeDlg::GenerationGUI_PipeDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
52 bool modal, Qt::WindowFlags fl)
53 : GEOMBase_Skeleton (theGeometryGUI, parent, modal, fl),
54 myGenGroupCheckGP (0),
57 myStepByStepCheckGMP (0),
58 myGenGroupCheckGMP (0),
62 QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_PIPE")));
63 QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
64 QPixmap image2 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_PIPE_BINORMAL")));
65 QPixmap image3 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_PIPE_SECTION")));
67 setWindowTitle(tr("GEOM_PIPE_TITLE"));
69 /***************************************************************/
70 mainFrame()->GroupConstructors->setTitle(tr("GEOM_PIPE"));
71 mainFrame()->RadioButton1->setIcon(image0);
72 mainFrame()->RadioButton2->setIcon(image2);
73 mainFrame()->RadioButton3->setIcon(image3);
74 // mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
75 // mainFrame()->RadioButton3->close();
77 GroupPoints = new DlgRef_3Sel1Check(centralWidget());
79 GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
80 GroupPoints->TextLabel1->setText(tr("GEOM_BASE_OBJECT"));
81 GroupPoints->TextLabel2->setText(tr("GEOM_PATH_OBJECT"));
82 GroupPoints->TextLabel3->setText(tr("GEOM_BINORMAL"));
83 GroupPoints->PushButton1->setIcon(image1);
84 GroupPoints->PushButton2->setIcon(image1);
85 GroupPoints->PushButton3->setIcon(image1);
86 GroupPoints->CheckButton1->setText(tr("GEOM_SELECT_UNPUBLISHED_EDGES"));
88 // Add widgets for group generation
89 QGridLayout *aLayoutGP = (QGridLayout *)GroupPoints->GroupBox1->layout();
92 new QCheckBox(tr("GEOM_GENERATE_GROUPS"), GroupPoints->GroupBox1);
94 new QLabel (tr("GEOM_GROUP_NAME_PREFIX"), GroupPoints->GroupBox1);
95 myPrefixEditGP = new QLineEdit(GroupPoints->GroupBox1);
97 aLayoutGP->addWidget(myGenGroupCheckGP, 4, 0, 1, 3);
98 aLayoutGP->addWidget(myPrefixLblGP, 5, 0, 1, 2);
99 aLayoutGP->addWidget(myPrefixEditGP, 5, 2);
101 GroupMakePoints = new DlgRef_3Sel2Check3Spin(centralWidget());
103 GroupMakePoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
104 GroupMakePoints->TextLabel1->setText(tr("GEOM_BASE_OBJECT"));
105 GroupMakePoints->TextLabel2->setText(tr("GEOM_LOCATIONS"));
106 GroupMakePoints->TextLabel3->setText(tr("GEOM_PATH_OBJECT"));
107 GroupMakePoints->PushButton1->setIcon(image1);
108 GroupMakePoints->PushButton2->setIcon(image1);
109 GroupMakePoints->PushButton3->setIcon(image1);
110 GroupMakePoints->CheckBox1->setText(tr("GEOM_WITH_CONTACT"));
111 GroupMakePoints->CheckBox2->setText(tr("GEOM_WITH_CORRECTION"));
112 GroupMakePoints->SpinBox1->setAttribute(Qt::WA_DeleteOnClose);
113 GroupMakePoints->SpinBox2->setAttribute(Qt::WA_DeleteOnClose);
114 GroupMakePoints->SpinBox3->setAttribute(Qt::WA_DeleteOnClose);
115 GroupMakePoints->TextLabel4->setAttribute(Qt::WA_DeleteOnClose);
116 GroupMakePoints->TextLabel5->setAttribute(Qt::WA_DeleteOnClose);
117 GroupMakePoints->TextLabel6->setAttribute(Qt::WA_DeleteOnClose);
118 GroupMakePoints->SpinBox1->close();
119 GroupMakePoints->SpinBox2->close();
120 GroupMakePoints->SpinBox3->close();
121 GroupMakePoints->TextLabel4->close();
122 GroupMakePoints->TextLabel5->close();
123 GroupMakePoints->TextLabel6->close();
125 // Add widgets for group generation
126 QGridLayout *aLayoutGMP = (QGridLayout *)GroupMakePoints->GroupBox1->layout();
128 myStepByStepCheckGMP =
129 new QCheckBox(tr("GEOM_STEP_BY_STEP"), GroupMakePoints->GroupBox1);
131 new QCheckBox(tr("GEOM_GENERATE_GROUPS"), GroupMakePoints->GroupBox1);
133 new QLabel (tr("GEOM_GROUP_NAME_PREFIX"), GroupMakePoints->GroupBox1);
134 myPrefixEditGMP = new QLineEdit(GroupMakePoints->GroupBox1);
136 aLayoutGMP->addWidget(myStepByStepCheckGMP, 8, 0, 1, 3);
137 aLayoutGMP->addWidget(myGenGroupCheckGMP, 9, 0, 1, 3);
138 aLayoutGMP->addWidget(myPrefixLblGMP, 10, 0, 1, 2);
139 aLayoutGMP->addWidget(myPrefixEditGMP, 10, 2);
141 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
142 layout->setMargin(0); layout->setSpacing(6);
143 layout->addWidget(GroupPoints);
144 layout->addWidget(GroupMakePoints);
145 /***************************************************************/
147 setHelpFileName("create_extrusion_alongpath_page.html");
153 //=================================================================================
154 // function : ~GenerationGUI_PipeDlg()
155 // purpose : Destroys the object and frees any allocated resources
156 //=================================================================================
157 GenerationGUI_PipeDlg::~GenerationGUI_PipeDlg()
159 // no need to delete child widgets, Qt does it all for us
162 //=================================================================================
165 //=================================================================================
166 void GenerationGUI_PipeDlg::Init()
169 GroupPoints->LineEdit1->setReadOnly(true);
170 GroupPoints->LineEdit2->setReadOnly(true);
171 GroupPoints->LineEdit3->setReadOnly(true);
173 GroupPoints->LineEdit1->setText("");
174 GroupPoints->LineEdit2->setText("");
175 GroupPoints->LineEdit3->setText("");
179 GroupPoints->CheckButton1->setEnabled(false);
181 GroupMakePoints->LineEdit1->setReadOnly(true);
182 GroupMakePoints->LineEdit2->setReadOnly(true);
183 GroupMakePoints->LineEdit3->setReadOnly(true);
185 GroupMakePoints->LineEdit1->setText("");
186 GroupMakePoints->LineEdit2->setText("");
187 GroupMakePoints->LineEdit3->setText("");
189 showOnlyPreviewControl();
191 // signals and slots connections
192 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
193 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
195 connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
197 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
198 connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
199 connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
201 connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(SelectionTypeButtonClicked()));
203 connect(GroupMakePoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
204 connect(GroupMakePoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
205 connect(GroupMakePoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
206 connect(GroupMakePoints->CheckBox1, SIGNAL(clicked()), this, SLOT(processPreview()));
207 connect(GroupMakePoints->CheckBox2, SIGNAL(clicked()), this, SLOT(processPreview()));
208 connect(myStepByStepCheckGMP, SIGNAL(clicked()), this, SLOT(processPreview()));
209 connect(myGenGroupCheckGP, SIGNAL(toggled(bool)), this, SLOT(GenGroupClicked(bool)));
210 connect(myGenGroupCheckGMP, SIGNAL(toggled(bool)), this, SLOT(GenGroupClicked(bool)));
211 connect(myStepByStepCheckGMP, SIGNAL(toggled(bool)), this, SLOT(StepByStepClicked(bool)));
213 initName(tr("GEOM_PIPE"));
216 GroupPoints->TextLabel3->hide();
217 GroupPoints->PushButton3->hide();
218 GroupPoints->LineEdit3->hide();
219 ConstructorsClicked(0);
221 GroupPoints->PushButton1->click();
222 SelectionIntoArgument();
226 //=================================================================================
227 // function : ConstructorsClicked()
228 // purpose : Radio button management
229 //=================================================================================
230 void GenerationGUI_PipeDlg::ConstructorsClicked( int constructorId )
234 switch (constructorId) {
236 GroupMakePoints->hide();
238 GroupPoints->TextLabel3->hide();
239 GroupPoints->PushButton3->hide();
240 GroupPoints->LineEdit3->hide();
241 GroupPoints->PushButton1->click();
242 myGenGroupCheckGP->setChecked(false);
243 resetGenGroup(myGenGroupCheckGP, false, true);
246 GroupMakePoints->hide();
248 GroupPoints->TextLabel3->show();
249 GroupPoints->PushButton3->show();
250 GroupPoints->LineEdit3->show();
251 GroupPoints->PushButton1->click();
252 myGenGroupCheckGP->setChecked(false);
253 resetGenGroup(myGenGroupCheckGP, false, true);
257 GroupMakePoints->show();
258 GroupMakePoints->PushButton1->click();
259 myStepByStepCheckGMP->setChecked(false);
260 myGenGroupCheckGMP->setChecked(false);
261 resetGenGroup(myGenGroupCheckGMP, false, true);
267 qApp->processEvents();
271 SelectionIntoArgument();
275 //=================================================================================
276 // function : SelectionBittonClicked()
277 // purpose : Selection type Radio button management
278 //=================================================================================
279 void GenerationGUI_PipeDlg::SelectionTypeButtonClicked()
282 if ( GroupPoints->CheckButton1->isChecked() ) {
283 localSelection( TopAbs_EDGE );
285 TColStd_MapOfInteger aMap;
286 aMap.Add(GEOM_COMPOUND);
289 globalSelection(aMap);
291 if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
292 myEditCurrentArgument->setText("");
299 //=================================================================================
300 // function : ClickOnOk()
302 //=================================================================================
303 void GenerationGUI_PipeDlg::ClickOnOk()
305 setIsApplyAndClose( true );
310 //=================================================================================
311 // function : ClickOnApply()
313 //=================================================================================
314 bool GenerationGUI_PipeDlg::ClickOnApply()
324 //=================================================================================
325 // function : SelectionIntoArgument()
326 // purpose : Called when selection is changed or on dialog initialization or activation
327 //=================================================================================
328 void GenerationGUI_PipeDlg::SelectionIntoArgument()
331 myEditCurrentArgument->setText("");
333 if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
334 myBaseObjects.clear();
335 QList<GEOM::GeomObjPtr> objects = getSelected( TopAbs_SHAPE, -1 );
336 for ( int i = 0; i < objects.count(); i++ ) {
337 GEOM::shape_type stype = objects[i]->GetMaxShapeType();
338 GEOM::shape_type maxallowed = getConstructorId() == 1 ? GEOM::FACE : GEOM::SHELL;
339 GEOM::shape_type minallowed = getConstructorId() == 1 ? GEOM::EDGE : GEOM::VERTEX;
340 if ( stype < maxallowed || stype > minallowed )
342 myBaseObjects << objects[i];
344 if ( !myBaseObjects.isEmpty() ) {
345 QString aName = myBaseObjects.count() > 1 ? QString( "%1_objects").arg( myBaseObjects.count() ) : GEOMBase::GetName( myBaseObjects[0].get() );
346 myEditCurrentArgument->setText( aName );
349 else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
350 QList<TopAbs_ShapeEnum> types;
351 types << TopAbs_EDGE << TopAbs_WIRE;
352 myPath = getSelected( types );
354 QString aName = GEOMBase::GetName( myPath.get() );
355 myEditCurrentArgument->setText( aName );
356 if ( getConstructorId() == 1 && !myVec )
357 GroupPoints->PushButton3->click();
358 else if ( myBaseObjects.isEmpty() )
359 GroupPoints->PushButton1->click();
363 else if (myEditCurrentArgument == GroupPoints->LineEdit3) {
364 myVec = getSelected( TopAbs_EDGE );
366 QString aName = GEOMBase::GetName( myVec.get() );
367 myEditCurrentArgument->setText( aName );
368 if ( myBaseObjects.isEmpty() )
369 GroupPoints->PushButton1->click();
371 GroupPoints->PushButton2->click();
374 else if ( myEditCurrentArgument == GroupMakePoints->LineEdit1 ) {
375 QList<TopAbs_ShapeEnum> types;
376 types << TopAbs_EDGE << TopAbs_WIRE << TopAbs_FACE << TopAbs_SHELL;
377 QList<GEOM::GeomObjPtr> objects = getSelected( types, -1 );
378 GEOMBase::Synchronize( myBaseObjects, objects );
379 if ( !myBaseObjects.isEmpty() ) {
380 QString aName = myBaseObjects.count() > 1 ? QString( "%1_objects").arg( myBaseObjects.count() ) : GEOMBase::GetName( myBaseObjects[0].get() );
381 myEditCurrentArgument->setText( aName );
384 else if ( myEditCurrentArgument == GroupMakePoints->LineEdit2 ) {
385 localSelection( TopAbs_VERTEX );
386 QList<GEOM::GeomObjPtr> objects = getSelected( TopAbs_VERTEX, -1 );
387 GEOMBase::Synchronize( myLocations, objects );
388 if ( !myLocations.isEmpty() ) {
389 QString aName = myLocations.count() > 1 ? QString( "%1_objects").arg( myLocations.count() ) : GEOMBase::GetName( myLocations[0].get() );
390 myEditCurrentArgument->setText( aName );
393 else if ( myEditCurrentArgument == GroupMakePoints->LineEdit3 ) {
394 QList<TopAbs_ShapeEnum> types;
395 types << TopAbs_EDGE << TopAbs_WIRE;
396 myPath = getSelected( types );
398 QString aName = GEOMBase::GetName( myPath.get() );
399 myEditCurrentArgument->setText( aName );
407 //=================================================================================
408 // function : SetEditCurrentArgument()
410 //=================================================================================
411 void GenerationGUI_PipeDlg::SetEditCurrentArgument()
413 QPushButton* send = (QPushButton*)sender();
415 disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
416 globalSelection(GEOM_ALLSHAPES);
417 GroupPoints->PushButton1->setDown(false);
418 GroupPoints->PushButton2->setDown(false);
419 GroupPoints->PushButton3->setDown(false);
420 GroupPoints->LineEdit1->setEnabled(false);
421 GroupPoints->LineEdit2->setEnabled(false);
422 GroupPoints->LineEdit3->setEnabled(false);
423 if (send == GroupPoints->PushButton1) {
424 myEditCurrentArgument = GroupPoints->LineEdit1;
425 GroupPoints->CheckButton1->setEnabled(false);
427 else if (send == GroupPoints->PushButton2) {
428 myEditCurrentArgument = GroupPoints->LineEdit2;
430 if ( GroupPoints->CheckButton1->isChecked() ) {
431 localSelection( TopAbs_EDGE );
433 TColStd_MapOfInteger aMap;
434 aMap.Add(GEOM_COMPOUND);
437 globalSelection(aMap);
439 GroupPoints->CheckButton1->setEnabled(true);
441 else if(send == GroupPoints->PushButton3) {
442 myEditCurrentArgument = GroupPoints->LineEdit3;
443 GroupPoints->CheckButton1->setEnabled(false);
444 localSelection(TopAbs_EDGE);
447 GroupMakePoints->PushButton1->setDown(false);
448 GroupMakePoints->PushButton2->setDown(false);
449 GroupMakePoints->PushButton3->setDown(false);
450 GroupMakePoints->LineEdit1->setEnabled(false);
451 GroupMakePoints->LineEdit2->setEnabled(false);
452 GroupMakePoints->LineEdit3->setEnabled(false);
453 if (send == GroupMakePoints->PushButton1) {
454 myEditCurrentArgument = GroupMakePoints->LineEdit1;
456 else if(send == GroupMakePoints->PushButton2) {
457 myEditCurrentArgument = GroupMakePoints->LineEdit2;
459 else if (send == GroupMakePoints->PushButton3) {
460 myEditCurrentArgument = GroupMakePoints->LineEdit3;
463 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
464 this, SLOT(SelectionIntoArgument()));
467 myEditCurrentArgument->setEnabled(true);
468 myEditCurrentArgument->setFocus();
469 // after setFocus(), because it will be setDown(false) when loses focus
472 // seems we need it only to avoid preview disappearing, caused by selection mode change
476 //=================================================================================
477 // function : ActivateThisDialog()
479 //=================================================================================
480 void GenerationGUI_PipeDlg::ActivateThisDialog()
482 GEOMBase_Skeleton::ActivateThisDialog();
483 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
484 this, SLOT( SelectionIntoArgument() ) );
486 ConstructorsClicked(getConstructorId());
489 //=================================================================================
490 // function : enterEvent()
491 // purpose : when mouse enter onto the QWidget
492 //=================================================================================
493 void GenerationGUI_PipeDlg::enterEvent (QEvent*)
495 if (!mainFrame()->GroupConstructors->isEnabled())
496 ActivateThisDialog();
499 //=================================================================================
500 // function : createOperation
502 //=================================================================================
503 GEOM::GEOM_IOperations_ptr GenerationGUI_PipeDlg::createOperation()
505 return getGeomEngine()->GetI3DPrimOperations(getStudyId());
508 //=================================================================================
509 // function : isValid
511 //=================================================================================
512 bool GenerationGUI_PipeDlg::isValid (QString&)
515 switch ( getConstructorId() ) {
517 ok = !myBaseObjects.isEmpty() && myPath;
520 ok = !myBaseObjects.isEmpty() && myPath && myVec;
523 ok = !myBaseObjects.isEmpty() && ( myLocations.isEmpty() || myBaseObjects.count() == myLocations.count() ) && myPath;
531 //=================================================================================
532 // function : execute
534 //=================================================================================
535 bool GenerationGUI_PipeDlg::execute (ObjectList& objects)
537 GEOM::ListOfGO_var aList;
539 GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
540 bool doGroups = !IsPreview();
542 myGroupObjectsMap.clear();
544 switch( getConstructorId() ) {
548 doGroups = myGenGroupCheckGP->isEnabled() &&
549 myGenGroupCheckGP->isChecked();
552 for (int i = 0; i < myBaseObjects.count(); i++) {
553 switch ( getConstructorId() ) {
555 aList = anOper->MakePipe(myBaseObjects[i].get(),
556 myPath.get(), doGroups);
559 aList = anOper->MakePipeBiNormalAlongVector
560 (myBaseObjects[i].get(), myPath.get(), myVec.get(), doGroups);
564 if (aList->length() > 0) {
569 if (!aList[0]->_is_nil()) {
570 objects.push_back(aList[0]._retn());
577 GEOM::ListOfGO_var myBaseGO = new GEOM::ListOfGO();
578 GEOM::ListOfGO_var myLocationsGO = new GEOM::ListOfGO();
579 myBaseGO->length( myBaseObjects.count() );
580 myLocationsGO->length( myLocations.count() );
581 for (int i = 0; i < myBaseObjects.count(); i++) {
582 myBaseGO[i] = myBaseObjects[i].copy();
584 for (int i = 0; i < myLocations.count(); i++) {
585 myLocationsGO[i] = myLocations[i].copy();
589 doGroups = myGenGroupCheckGMP->isEnabled() &&
590 myGenGroupCheckGMP->isChecked();
593 bool isWithContact = GroupMakePoints->CheckBox1->isEnabled() &&
594 GroupMakePoints->CheckBox1->isChecked();
595 bool isWithCorrection = GroupMakePoints->CheckBox2->isEnabled() &&
596 GroupMakePoints->CheckBox2->isChecked();
598 aList = anOper->MakePipeWithDifferentSections
599 (myBaseGO.in(), myLocationsGO.in(), myPath.get(),
600 isWithContact, isWithCorrection,
601 myStepByStepCheckGMP->isChecked(),
604 if (aList->length() > 0) {
609 if (!aList[0]->_is_nil()) {
610 objects.push_back(aList[0]._retn());
621 //=================================================================================
622 // function : addSubshapeToStudy
623 // purpose : virtual method to add new SubObjects if local selection
624 //=================================================================================
625 void GenerationGUI_PipeDlg::addSubshapesToStudy()
627 GEOMBase::PublishSubObject( myPath.get() );
628 GEOMBase::PublishSubObject( myVec.get() );
631 //=================================================================================
632 // function : extractPrefix
633 // purpose : redefined from GEOMBase_Helper class
634 //=================================================================================
635 bool GenerationGUI_PipeDlg::extractPrefix() const
637 return myBaseObjects.count() > 1;
640 //=================================================================================
641 // function : restoreSubShapes
642 // purpose : virtual method to restore tree of argument's sub-shapes under
643 // the resulting shape. Redefined from GEOMBase_Helper class.
644 //=================================================================================
645 void GenerationGUI_PipeDlg::restoreSubShapes
646 (SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_ptr theSObject)
648 QCheckBox *aGenGroupCheck = NULL;
649 QLineEdit *aPrefixEdit = NULL;
651 switch (getConstructorId()) {
654 aGenGroupCheck = myGenGroupCheckGP;
655 aPrefixEdit = myPrefixEditGP;
658 aGenGroupCheck = myGenGroupCheckGMP;
659 aPrefixEdit = myPrefixEditGMP;
665 if (aGenGroupCheck == NULL || !aGenGroupCheck->isChecked()) {
669 // get Object from SObject
670 GEOM::GEOM_Object_var aFather = GEOM::GEOM_Object::_narrow
671 (theSObject->GetObject());
673 if (CORBA::is_nil(aFather)) {
677 ObjectMap::const_iterator anIter =
678 myGroupObjectsMap.find(aFather->GetEntry());
679 QString aPrefix = aPrefixEdit->text();
680 bool hasPrefix = !aPrefix.isEmpty();
682 if (anIter != myGroupObjectsMap.end()) {
683 QList<GEOM::GeomObjPtr>::const_iterator it = anIter->second.begin();
685 for (; it != anIter->second.end(); it++) {
690 aName = aPrefix + "_";
693 aName += tr((*it)->GetName());
694 getGeomEngine()->AddInStudy(theStudy, (*it).get(),
695 aName.toStdString().c_str(), aFather);
700 //=================================================================================
701 // function : getSourceObjects
702 // purpose : virtual method to get source objects
703 //=================================================================================
704 QList<GEOM::GeomObjPtr> GenerationGUI_PipeDlg::getSourceObjects()
706 QList<GEOM::GeomObjPtr> res(myBaseObjects);
707 res << myPath << myVec;
708 for (int i = 0; i < myLocations.count(); i++)
709 res << myLocations[i];
713 //=================================================================================
714 // function : GenGroupClicked
715 // purpose : Slot to treat checking "Generate groups" check box.
716 //=================================================================================
717 void GenerationGUI_PipeDlg::GenGroupClicked(bool isChecked)
719 resetGenGroup((QCheckBox *)sender(), isChecked, false);
722 //=================================================================================
723 // function : StepByStepClicked
724 // purpose : Slot to treat checking "Step-by-step generation" check box.
725 //=================================================================================
726 void GenerationGUI_PipeDlg::StepByStepClicked(bool isChecked)
728 GroupMakePoints->CheckBox1->setEnabled(!isChecked);
729 GroupMakePoints->CheckBox2->setEnabled(!isChecked);
732 //=================================================================================
733 // function : updateGenGroup
734 // purpose : Update "Generate groups" widgets depending on the path.
735 //=================================================================================
736 void GenerationGUI_PipeDlg::updateGenGroup()
738 bool isEnable = true;
741 // Check if the path is closed.
742 TopoDS_Shape aShapePath;
744 if (GEOMBase::GetShape(myPath.get(), aShapePath)) {
745 isEnable = GEOMUtils::IsOpenPath(aShapePath);
749 QCheckBox *aGenGroupCheck = NULL;
751 switch (getConstructorId()) {
754 aGenGroupCheck = myGenGroupCheckGP;
757 aGenGroupCheck = myGenGroupCheckGMP;
763 if (aGenGroupCheck != NULL) {
764 const bool isChecked = aGenGroupCheck->isChecked();
766 aGenGroupCheck->setEnabled(isEnable);
767 resetGenGroup(aGenGroupCheck, isEnable && isChecked, false);
771 //=================================================================================
772 // function : resetGenGroup
773 // purpose : Resets data of "Generate groups" widgets.
774 //=================================================================================
775 void GenerationGUI_PipeDlg::resetGenGroup(QCheckBox *theGenGroup,
776 const bool isChecked,
777 const bool isClearPrefix)
779 QLabel *aPrefixLbl = NULL;
780 QLineEdit *aPrefixEdit = NULL;
782 if (theGenGroup == myGenGroupCheckGP) {
783 aPrefixLbl = myPrefixLblGP;
784 aPrefixEdit = myPrefixEditGP;
785 } else if (theGenGroup == myGenGroupCheckGMP) {
786 aPrefixLbl = myPrefixLblGMP;
787 aPrefixEdit = myPrefixEditGMP;
790 if (aPrefixLbl != NULL) {
791 aPrefixLbl->setEnabled(isChecked);
792 aPrefixEdit->setEnabled(isChecked);
795 aPrefixEdit->setText("");
800 //=================================================================================
801 // function : addGroups
802 // purpose : Add result groups to the list of groups.
803 //=================================================================================
804 void GenerationGUI_PipeDlg::addGroups(GEOM::ListOfGO_var &theResult)
806 const int aNbObj = theResult->length();
809 if (!theResult[0]->_is_nil()) {
810 QString anEntry = theResult[0]->GetEntry();
813 for (i = 1; i < aNbObj; ++i) {
814 if (!theResult[i]->_is_nil()) {
815 myGroupObjectsMap[anEntry].append(GEOM::GeomObjPtr(theResult[i]));