Salome HOME
Merge remote-tracking branch 'remotes/origin/hydro/imps_2017_salome_83' into HEAD
[modules/geom.git] / src / GroupGUI / GroupGUI_GroupDlg.cxx
index a13236cd2930b0302f53b54b43efcc2dedb175c9..a7ce624ec35f4e87a713f93b9ae5da102c363753 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -31,7 +31,9 @@
 #include <GeometryGUI.h>
 #include <GEOM_Displayer.h>
 #include <GEOMUtils.hxx>
+#ifndef DISABLE_PLOT2DVIEWER
 #include <MeasureGUI_ShapeStatisticsDlg.h>
+#endif
 
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
@@ -86,7 +88,8 @@ GroupGUI_GroupDlg::GroupGUI_GroupDlg (Mode mode, GeometryGUI* theGeometryGUI, QW
     myBusy(false),
     myIsShapeType(false),
     myIsHiddenMain(false),
-    myWasHiddenMain(true)
+    myWasHiddenMain(true),
+    myIsAccept(false)
 {
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
 
@@ -201,7 +204,9 @@ GroupGUI_GroupDlg::GroupGUI_GroupDlg (Mode mode, GeometryGUI* theGeometryGUI, QW
   myLessFilterSpin = new SalomeApp_DoubleSpinBox(myFilterGrp);
   myGreaterFilterSpin = new SalomeApp_DoubleSpinBox(myFilterGrp);
   myApplyFilterButton = new QPushButton(tr("GEOM_BUT_APPLY"), myFilterGrp);
+#ifndef DISABLE_PLOT2DVIEWER
   myPlotDistributionButton = new QPushButton(tr("GEOM_PLOT_DISTRIBUTION"), myFilterGrp);
+#endif
 
   QGridLayout* filterLayout = new QGridLayout(myFilterGrp);
   filterLayout->addWidget(myLessFilterCheck,    0, 0);
@@ -211,7 +216,9 @@ GroupGUI_GroupDlg::GroupGUI_GroupDlg (Mode mode, GeometryGUI* theGeometryGUI, QW
   filterLayout->addWidget(myGreaterFilterCombo, 1, 1);
   filterLayout->addWidget(myGreaterFilterSpin,  1, 2);
   filterLayout->addWidget(myApplyFilterButton,  0, 3);
+#ifndef DISABLE_PLOT2DVIEWER
   filterLayout->addWidget(myPlotDistributionButton,  1, 3);
+#endif
 
   QVBoxLayout* layout = new QVBoxLayout(centralWidget());
   layout->setMargin(0); layout->setSpacing(6);
@@ -229,10 +236,10 @@ GroupGUI_GroupDlg::~GroupGUI_GroupDlg()
   GEOM_Displayer* aDisplayer = getDisplayer();
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
   bool isHideObjects = resMgr->booleanValue( "Geometry", "hide_input_object", true);
-  if (myWasHiddenMain) {
+  if (myWasHiddenMain || ( isHideObjects && myIsAccept ) ) {
     myIsHiddenMain = true;
   }
-  else if (!isHideObjects) {
+  else {
     aDisplayer->Display(myMainObj);
     myIsHiddenMain = false;
   }
@@ -329,7 +336,9 @@ void GroupGUI_GroupDlg::Init()
   connect(myIdList,        SIGNAL(itemSelectionChanged()), this, SLOT(selectionChanged()));
 
   connect(myApplyFilterButton, SIGNAL(clicked()),         this, SLOT(ClickOnOkFilter()));
+#ifndef DISABLE_PLOT2DVIEWER
   connect(myPlotDistributionButton, SIGNAL(clicked()),    this, SLOT(ClickOnPlot()));
+#endif
   connect(myLessFilterCheck,   SIGNAL(stateChanged(int)), this, SLOT(MeasureToggled()));
   connect(myGreaterFilterCheck,   SIGNAL(stateChanged(int)), this, SLOT(MeasureToggled()));
 
@@ -387,7 +396,8 @@ bool GroupGUI_GroupDlg::ClickOnApply()
     setIsDisplayResult( false );
   }
     
-  if (!onAccept(myMode == CreateGroup, true, isApplyAndClose()))
+  myIsAccept = onAccept(myMode == CreateGroup, true, isApplyAndClose());
+  if (!myIsAccept)
     return false;
 
   if(!isApplyAndClose()) {
@@ -438,7 +448,7 @@ void GroupGUI_GroupDlg::ActivateThisDialog()
 //=================================================================================
 void GroupGUI_GroupDlg::SetEditCurrentArgument()
 {
-  QPushButton* send = (QPushButton*)sender();
+  QPushButton* send = qobject_cast<QPushButton*>( sender() );
 
   if (send == mySelBtn) {
     myEditCurrentArgument = myMainName;
@@ -464,7 +474,8 @@ void GroupGUI_GroupDlg::SetEditCurrentArgument()
   //  activateSelection();
   if(myEditCurrentArgument) {
     myEditCurrentArgument->setFocus();
-    send->setDown(true);
+    if ( send )
+      send->setDown(true);
   }
 
   updateState();
@@ -870,6 +881,12 @@ int GroupGUI_GroupDlg::getSelectedSubshapes (TColStd_IndexedMapOfInteger& theMap
         TopoDS_Shape aShape;
         if (GEOMBase::GetShape(aGeomObj, aShape)) {
           if (aGeomObj->GetType() == GEOM_GROUP || aShape.ShapeType() == getShapeType()) {
+            if (subSelectionWay() != ALL_SUBSHAPES &&
+                GEOMBase::GetName(aGeomObj) == myShape2Name->text()) {
+              // Skip selected in place object.
+              continue;
+            }
+
             TopTools_IndexedMapOfShape aMainMap;
             TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
             TopExp::MapShapes(aMainShape, aMainMap);
@@ -1081,7 +1098,7 @@ void GroupGUI_GroupDlg::activateSelection()
           int index = aSubShapesMap.FindIndex(aSubShape);
           QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index);
           Handle(SALOME_InteractiveObject) io =
-            new SALOME_InteractiveObject(anEntry.toAscii(), "GEOM", "TEMP_IO");
+            new SALOME_InteractiveObject(anEntry.toLatin1(), "GEOM", "TEMP_IO");
           if ( myGroupIdList.contains( index ) ) {
             aDisplayer->SetColor( aCol );
           }
@@ -1157,12 +1174,14 @@ void GroupGUI_GroupDlg::updateState (bool isAdd)
   GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
   GEOM::ListOfLong_var aSubShapes = aShOp->SubShapeAllIDs( myMainObj, getShapeType(), false );
   bool hasCurrentEntities = aSubShapes->length() > 0;
+#ifndef DISABLE_PLOT2DVIEWER
   myPlotDistributionButton->setEnabled( myFilterGrp->isEnabled() &&
                                        myIsShapeType &&
                                        ( getShapeType() == TopAbs_EDGE || 
                                          getShapeType() == TopAbs_FACE ||
                                          getShapeType() == TopAbs_SOLID ) &&
                                        hasCurrentEntities );
+#endif
   if (subSelectionWay() == ALL_SUBSHAPES)
     setInPlaceObj(GEOM::GEOM_Object::_nil());
 }
@@ -1451,6 +1470,7 @@ void GroupGUI_GroupDlg::ClickOnOkFilter()
   updateState(true);
 }
 
+#ifndef DISABLE_PLOT2DVIEWER
 //=================================================================================
 // function : ClickOnPlot()
 // purpose  : opens "Shape Statistics" dialog box in order to plot sub-shapes distribution.
@@ -1463,6 +1483,7 @@ void GroupGUI_GroupDlg::ClickOnPlot()
     dlg->show();
   }
 }
+#endif
 
 void GroupGUI_GroupDlg::MeasureToggled()
 {