From: jfa Date: Thu, 31 Mar 2011 11:20:40 +0000 (+0000) Subject: IMP 0021069: Hide selected in explode function X-Git-Tag: Start_BR_19998_21191~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8afa92f295620e2a609cce63f8e1dadee676d961;p=modules%2Fgeom.git IMP 0021069: Hide selected in explode function --- diff --git a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx index 9650843b4..f9ea01983 100644 --- a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx +++ b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx @@ -29,22 +29,31 @@ #include #include +#include +#include +#include +#include +#include +#include + #include #include #include #include #include -#include -#include -#include -#include -#include +#include #include +#include #include +#include + +#include #include +#include + //================================================================================= // class : EntityGUI_SubShapeDlg // purpose : Constructs a EntityGUI_SubShapeDlg which is a child of 'parent', with the @@ -52,47 +61,49 @@ // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -EntityGUI_SubShapeDlg::EntityGUI_SubShapeDlg( GeometryGUI* theGeometryGUI, QWidget* parent, - bool modal, Qt::WindowFlags fl ) - : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) +EntityGUI_SubShapeDlg::EntityGUI_SubShapeDlg(GeometryGUI* theGeometryGUI, QWidget* parent, + bool modal, Qt::WindowFlags fl) + : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl) { - QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_SUBSHAPE" ) ) ); - QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_SUBSHAPE"))); + QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); - setWindowTitle( tr( "GEOM_SUBSHAPE_TITLE" ) ); + setWindowTitle(tr("GEOM_SUBSHAPE_TITLE")); /***************************************************************/ - mainFrame()->GroupConstructors->setTitle( tr( "GEOM_SUB_SHAPE" ) ); - mainFrame()->RadioButton1->setIcon( image0 ); - mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose ); + mainFrame()->GroupConstructors->setTitle(tr("GEOM_SUB_SHAPE")); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); mainFrame()->RadioButton2->close(); - mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); + mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); mainFrame()->RadioButton3->close(); - GroupPoints = new DlgRef_1Sel1Check1List( centralWidget() ); - - GroupPoints->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) ); - GroupPoints->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) ); - GroupPoints->TextLabel2->setText( tr( "GEOM_SUBSHAPE_TYPE" ) ); - GroupPoints->CheckButton1->setText( tr( "GEOM_SUBSHAPE_SELECT" ) ); - GroupPoints->PushButton1->setIcon( image1 ); - GroupPoints->LineEdit1->setReadOnly( true ); - - QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); - layout->setMargin( 0 ); layout->setSpacing( 6 ); - layout->addWidget( GroupPoints ); + GroupPoints = new DlgRef_1Sel1List1Check3Btn(centralWidget()); + + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT")); + GroupPoints->TextLabel2->setText(tr("GEOM_SUBSHAPE_TYPE")); + GroupPoints->CheckButton1->setText(tr("GEOM_SUBSHAPE_SELECT")); + GroupPoints->PushButton1->setIcon(image1); + GroupPoints->PushButton2->setText(tr("SHOW_ONLY_SELECTED")); + GroupPoints->PushButton3->setText(tr("HIDE_SELECTED")); + GroupPoints->PushButton4->setText(tr("SHOW_ALL_SUB_SHAPES")); + GroupPoints->LineEdit1->setReadOnly(true); + + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); + layout->setMargin(0); layout->setSpacing(6); + layout->addWidget(GroupPoints); /***************************************************************/ - setIsOptimizedBrowsing( true ); + setIsOptimizedBrowsing(true); - setHelpFileName( "create_explode_page.html" ); + setHelpFileName("create_explode_page.html"); mainFrame()->GroupBoxName->hide(); Init(); } - //================================================================================= // function : ~EntityGUI_SubShapeDlg() // purpose : Destroys the object and frees any allocated resources @@ -101,7 +112,6 @@ EntityGUI_SubShapeDlg::~EntityGUI_SubShapeDlg() { } - //================================================================================= // function : Init() // purpose : @@ -115,40 +125,76 @@ void EntityGUI_SubShapeDlg::Init() myWithShape = true; /* type for sub shape selection */ - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Compound" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Compsolid" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Solid" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Shell" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Face" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Wire" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Edge" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Vertex" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Shape" ); - - if ( SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() - != OCCViewer_Viewer::Type() ) - GroupPoints->CheckButton1->setEnabled( false ); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compound"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compsolid"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Solid"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shell"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Face"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Wire"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Edge"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Vertex"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shape"); + + if (SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() + != OCCViewer_Viewer::Type()) + GroupPoints->CheckButton1->setEnabled(false); /* signals and slots connections */ - connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); + connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); - connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect( GroupPoints->ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ComboTextChanged() ) ); - connect( GroupPoints->CheckButton1, SIGNAL( stateChanged( int ) ), this, SLOT( SubShapeToggled() ) ); + connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged())); + connect(GroupPoints->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(SubShapeToggled())); - connect( myGeomGUI->getApp()->selectionMgr(), - SIGNAL( currentSelectionChanged( )), this, SLOT( SelectionIntoArgument() ) ); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(showOnlySelected())); + connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(showOnlySelected())); + connect(GroupPoints->PushButton4, SIGNAL(clicked()), this, SLOT(showOnlySelected())); + + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); updateButtonState(); resize(100,100); SelectionIntoArgument(); } +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void EntityGUI_SubShapeDlg::enterEvent(QEvent*) +{ + if (!mainFrame()->GroupConstructors->isEnabled()) + ActivateThisDialog(); +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void EntityGUI_SubShapeDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(myGeomGUI->getApp()->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + SubShapeToggled(); + updateButtonState(); +} + +//================================================================================= +//function : closeEvent +//purpose : remove temporary geom object +//================================================================================= +void EntityGUI_SubShapeDlg::closeEvent(QCloseEvent* e) +{ + erasePreview(true); + GEOMBase_Skeleton::closeEvent(e); +} //================================================================================= // function : ClickOnOk() @@ -156,31 +202,30 @@ void EntityGUI_SubShapeDlg::Init() //================================================================================= void EntityGUI_SubShapeDlg::ClickOnOk() { - setIsApplyAndClose( true ); - if ( ClickOnApply() ) + setIsApplyAndClose(true); + if (ClickOnApply()) ClickOnCancel(); } - //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= bool EntityGUI_SubShapeDlg::ClickOnApply() { - SUIT_Session::session()->activeApplication()->putInfo( "" ); + SUIT_Session::session()->activeApplication()->putInfo(""); /* Explode all sub shapes */ - if ( isAllSubShapes() ) { + if (isAllSubShapes()) { /* More than 30 subshapes : ask confirmation */ - unsigned int nb = NumberOfSubShapes( myShape, shapeType() ); - if ( nb > 30 ) { - const QString caption = tr( "GEOM_CONFIRM" ); - const QString text = tr( "GEOM_CONFIRM_INFO" ).arg( nb ); - const QString button0 = tr( "GEOM_BUT_EXPLODE" ); - const QString button1 = tr( "GEOM_BUT_CANCEL" ); - - if ( QMessageBox::warning( this, caption, text, button0, button1 ) != 0 ) + unsigned int nb = NumberOfSubShapes(myShape, shapeType()); + if (nb > 30) { + const QString caption = tr("GEOM_CONFIRM"); + const QString text = tr("GEOM_CONFIRM_INFO").arg(nb); + const QString button0 = tr("GEOM_BUT_EXPLODE"); + const QString button1 = tr("GEOM_BUT_CANCEL"); + + if (QMessageBox::warning(this, caption, text, button0, button1) != 0) return false; /* aborted */ } } @@ -193,11 +238,9 @@ bool EntityGUI_SubShapeDlg::ClickOnApply() return isOk; } - //================================================================================= // function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -// : used only by SelectButtonC1A1 (LineEditC1A1) +// purpose : Called when selection has changed or other case //================================================================================= void EntityGUI_SubShapeDlg::SelectionIntoArgument() { @@ -217,21 +260,21 @@ void EntityGUI_SubShapeDlg::SelectionIntoArgument() return; Handle(SALOME_InteractiveObject) IO = aSelList.First(); - if ( !IO->hasEntry() ) { - SUIT_Session::session()->activeApplication()->putInfo( tr( "GEOM_PRP_SHAPE_IN_STUDY" ) ); + if (!IO->hasEntry()) { + SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); updateButtonState(); return; } - TopoDS_Shape S = GEOMBase::GetTopoFromSelection( aSelList ); - if ( S.IsNull() || S.ShapeType() == TopAbs_VERTEX ) { + TopoDS_Shape S = GEOMBase::GetTopoFromSelection(aSelList); + if (S.IsNull() || S.ShapeType() == TopAbs_VERTEX) { myObject = GEOM::GEOM_Object::_nil(); updateButtonState(); return; } - myObject = GEOMBase::ConvertIOinGEOMObject( IO ); - if ( myObject->_is_nil() ) { + myObject = GEOMBase::ConvertIOinGEOMObject(IO); + if (myObject->_is_nil()) { updateButtonState(); return; } @@ -249,7 +292,7 @@ void EntityGUI_SubShapeDlg::SelectionIntoArgument() // Solving PAL5590 if (myShape.ShapeType() == TopAbs_COMPOUND) { unsigned int nb = NumberOfSubShapes(myShape, TopAbs_COMPOUND); - if ( nb > 0 ) + if (nb > 0) i++; } while (i <= myShape.ShapeType()) { @@ -264,35 +307,34 @@ void EntityGUI_SubShapeDlg::SelectionIntoArgument() } } else { - if ( myWithShape == true ) { - GroupPoints->ComboBox1->removeItem( GroupPoints->ComboBox1->count() - 1 ); + if (myWithShape == true) { + GroupPoints->ComboBox1->removeItem(GroupPoints->ComboBox1->count() - 1); myWithShape = false; } } int count1 = GroupPoints->ComboBox1->count(); - if ( myWithShape ) + if (myWithShape) count1 = count1 - 1; - if ( SelectedShapeType > myShape.ShapeType() ) { - if ( SelectedShapeType == 8 ) { - if ( myShape.ShapeType() != TopAbs_COMPOUND ) { - GroupPoints->ComboBox1->setCurrentIndex( 0 ); + if (SelectedShapeType > myShape.ShapeType()) { + if (SelectedShapeType == 8) { + if (myShape.ShapeType() != TopAbs_COMPOUND) { + GroupPoints->ComboBox1->setCurrentIndex(0); ComboTextChanged(); } } else - GroupPoints->ComboBox1->setCurrentIndex( count1 - count + SelectedShapeType ); + GroupPoints->ComboBox1->setCurrentIndex(count1 - count + SelectedShapeType); } else { - GroupPoints->ComboBox1->setCurrentIndex( 0 ); + GroupPoints->ComboBox1->setCurrentIndex(0); ComboTextChanged(); } updateButtonState(); } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -302,12 +344,11 @@ void EntityGUI_SubShapeDlg::SetEditCurrentArgument() GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; - GroupPoints->CheckButton1->setChecked( false ); + GroupPoints->CheckButton1->setChecked(false); SubShapeToggled(); SelectionIntoArgument(); } - //================================================================================= // function : LineEditReturnPressed() // purpose : @@ -315,7 +356,7 @@ void EntityGUI_SubShapeDlg::SetEditCurrentArgument() void EntityGUI_SubShapeDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if ( send == GroupPoints->LineEdit1 ) + if (send == GroupPoints->LineEdit1) SetEditCurrentArgument(); else return; @@ -323,43 +364,6 @@ void EntityGUI_SubShapeDlg::LineEditReturnPressed() GEOMBase_Skeleton::LineEditReturnPressed(); } - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void EntityGUI_SubShapeDlg::DeactivateActiveDialog() -{ - if ( mainFrame()->GroupConstructors->isEnabled() ) { - GEOMBase_Skeleton::DeactivateActiveDialog(); - } -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void EntityGUI_SubShapeDlg::ActivateThisDialog() -{ - GEOMBase_Skeleton::ActivateThisDialog(); - connect( myGeomGUI->getApp()->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - SubShapeToggled(); - updateButtonState(); -} - - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void EntityGUI_SubShapeDlg::enterEvent( QEvent* ) -{ - if ( !mainFrame()->GroupConstructors->isEnabled() ) - ActivateThisDialog(); -} - //================================================================================= // function : ResetStateOfDialog() // purpose : Completely reset the state of method including local context @@ -368,34 +372,33 @@ void EntityGUI_SubShapeDlg::ResetStateOfDialog() { myObject = GEOM::GEOM_Object::_nil(); myShape.Nullify(); - myEditCurrentArgument->setText( "" ); + myEditCurrentArgument->setText(""); int SelectedShapeType = GroupPoints->ComboBox1->currentIndex(); int count = GroupPoints->ComboBox1->count(); - if ( myWithShape ) + if (myWithShape) count = count - 1; /* type for sub shape selection */ GroupPoints->ComboBox1->clear(); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Compound" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Compsolid" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Solid" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Shell" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Face" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Wire" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Edge" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Vertex" ); - GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Shape" ); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compound"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Compsolid"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Solid"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shell"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Face"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Wire"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Edge"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Vertex"); + GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shape"); myWithShape = true; - GroupPoints->ComboBox1->setCurrentIndex( 8 - count + SelectedShapeType ); + GroupPoints->ComboBox1->setCurrentIndex(8 - count + SelectedShapeType); ComboTextChanged(); updateButtonState(); } - //================================================================================= // function : SubShapeToggled() // purpose : Allow user selection of all or only selected sub shapes @@ -403,13 +406,9 @@ void EntityGUI_SubShapeDlg::ResetStateOfDialog() //================================================================================= void EntityGUI_SubShapeDlg::SubShapeToggled() { - globalSelection( GEOM_ALLSHAPES ); - - if ( !isAllSubShapes() ) - localSelection( myObject, shapeType() ); + activateSelection(); } - //================================================================================= // function : ComboTextChanged() // purpose : @@ -421,38 +420,37 @@ void EntityGUI_SubShapeDlg::ComboTextChanged() SubShapeToggled(); } - //================================================================================= // function : NumberOfSubShapes() // purpose : //================================================================================= -unsigned int EntityGUI_SubShapeDlg::NumberOfSubShapes( const TopoDS_Shape& S, - const int shapeType ) const +unsigned int EntityGUI_SubShapeDlg::NumberOfSubShapes(const TopoDS_Shape& S, + const int shapeType) const { - if ( S.IsNull() ) + if (S.IsNull()) return 0; unsigned int index = 0; TopTools_MapOfShape M; - if ( S.ShapeType() == TopAbs_COMPOUND && - ( TopAbs_ShapeEnum(shapeType) == TopAbs_SHAPE || + if (S.ShapeType() == TopAbs_COMPOUND && + (TopAbs_ShapeEnum(shapeType) == TopAbs_SHAPE || TopAbs_ShapeEnum(shapeType) == TopAbs_COMPSOLID || - TopAbs_ShapeEnum(shapeType) == TopAbs_COMPOUND ) ) { - TopoDS_Iterator It( S, Standard_True, Standard_True ); - for ( ; It.More(); It.Next() ) { - if ( M.Add( It.Value() ) ) { - if ( TopAbs_ShapeEnum( shapeType ) == TopAbs_SHAPE || - TopAbs_ShapeEnum( shapeType ) == It.Value().ShapeType() ) { + TopAbs_ShapeEnum(shapeType) == TopAbs_COMPOUND)) { + TopoDS_Iterator It(S, Standard_True, Standard_True); + for (; It.More(); It.Next()) { + if (M.Add(It.Value())) { + if (TopAbs_ShapeEnum(shapeType) == TopAbs_SHAPE || + TopAbs_ShapeEnum(shapeType) == It.Value().ShapeType()) { index++; } } } } else { - TopExp_Explorer Exp ( S, TopAbs_ShapeEnum( shapeType ) ); - for ( ; Exp.More(); Exp.Next() ) { - if ( M.Add( Exp.Current() ) ) { + TopExp_Explorer Exp (S, TopAbs_ShapeEnum(shapeType)); + for (; Exp.More(); Exp.Next()) { + if (M.Add(Exp.Current())) { index++; } } @@ -468,13 +466,13 @@ unsigned int EntityGUI_SubShapeDlg::NumberOfSubShapes( const TopoDS_Shape& S, //================================================================================= void EntityGUI_SubShapeDlg::updateButtonState() { - if ( SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() != OCCViewer_Viewer::Type() || - myObject->_is_nil() || shapeType() == TopAbs_SHAPE || shapeType() == TopAbs_COMPOUND ) { - GroupPoints->CheckButton1->setChecked( false ); - GroupPoints->CheckButton1->setEnabled( false ); + if (SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() != OCCViewer_Viewer::Type() || + myObject->_is_nil() || shapeType() == TopAbs_SHAPE || shapeType() == TopAbs_COMPOUND) { + GroupPoints->CheckButton1->setChecked(false); + GroupPoints->CheckButton1->setEnabled(false); } else - GroupPoints->CheckButton1->setEnabled( true ); + GroupPoints->CheckButton1->setEnabled(true); } //================================================================================= @@ -494,26 +492,176 @@ int EntityGUI_SubShapeDlg::shapeType() const { int type = GroupPoints->ComboBox1->currentIndex(); - if ( myObject->_is_nil() ) + if (myObject->_is_nil()) return type; // Solving PAL5590 type += myShape.ShapeType() + 1; - if ( myShape.ShapeType() == TopAbs_COMPOUND && - NumberOfSubShapes( myShape, TopAbs_COMPOUND ) > 0 ) { + if (myShape.ShapeType() == TopAbs_COMPOUND && + NumberOfSubShapes(myShape, TopAbs_COMPOUND) > 0) { type--; } return type; } +//================================================================================= +// function : showOnlySelected +// purpose : +//================================================================================= +void EntityGUI_SubShapeDlg::showOnlySelected() +{ + if (CORBA::is_nil(myObject) || isAllSubShapes()) + return; + + QPushButton* send = (QPushButton*)sender(); + if (send == GroupPoints->PushButton4) { + activateSelection(); + return; + } + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + GEOM_Displayer* aDisplayer = getDisplayer(); + + if (send == GroupPoints->PushButton3) { + aDisplayer->Erase(aSelList, false, true); + } + else { + aDisplayer->EraseAll(); + aDisplayer->Display(aSelList, true); + } +} + +//================================================================================= +// function : getSelectedSubshapes +// purpose : +//================================================================================= +int EntityGUI_SubShapeDlg::getSelectedSubshapes (TColStd_IndexedMapOfInteger& theMapIndex) +{ + theMapIndex.Clear(); + + SalomeApp_Application* app = myGeomGUI->getApp(); + if (!app || myObject->_is_nil()) + return 0; + + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + // try to find out and process the global selection + // (of not published objects and of published sub-shapes) + { + SALOME_ListIteratorOfListIO anIter (aSelList); + for (int i = 0; anIter.More(); anIter.Next(), i++) + { + Handle(SALOME_InteractiveObject) anIObj = anIter.Value(); + QString anEntry = anIObj->getEntry(); + QString str = "_"; + int index = anEntry.lastIndexOf(str); + if (index > 0) // selection among special preview + { + anEntry.remove(0, index+1); + int anIndex = anEntry.toInt(); + if (anIndex) + theMapIndex.Add(anIndex); + } + else // selection among published shapes + { + SalomeApp_Study* appStudy = dynamic_cast(app->activeStudy()); + if (!appStudy) return 0; + _PTR(Study) aStudy = appStudy->studyDS(); + + _PTR(SObject) aSObj (aStudy->FindObjectID(anEntry.toLatin1().constData())); + GEOM::GEOM_Object_var aGeomObj = + GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObj)); + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aGeomObj, aShape)) { + if (aGeomObj->GetType() == GEOM_GROUP || aShape.ShapeType() == (TopAbs_ShapeEnum)shapeType()) { + TopTools_IndexedMapOfShape aMainMap; + TopExp::MapShapes(myShape, aMainMap); + + TopExp_Explorer anExp (aShape, (TopAbs_ShapeEnum)shapeType()); + for (; anExp.More(); anExp.Next()) { + TopoDS_Shape aSubShape = anExp.Current(); + int anIndex = aMainMap.FindIndex(aSubShape); + if (anIndex >= 0) { + theMapIndex.Add(anIndex); + } + } + } + } + } + } // for aSelList + } + + return theMapIndex.Extent(); +} + +//================================================================================= +// function : activateSelection +// purpose : Activate selection in accordance with myEditCurrentArgument +//================================================================================= +void EntityGUI_SubShapeDlg::activateSelection() +{ + erasePreview(false); + + // local selection + if (!myObject->_is_nil() && !isAllSubShapes()) + { + GEOM_Displayer* aDisplayer = getDisplayer(); + int prevDisplayMode = aDisplayer->SetDisplayMode(0); + + SUIT_ViewWindow* aViewWindow = 0; + SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy(); + if (activeStudy) + aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); + if (aViewWindow == 0) return; + + SUIT_ViewManager* aViewManager = aViewWindow->getViewManager(); + if (aViewManager->getType() != OCCViewer_Viewer::Type() && + aViewManager->getType() != SVTK_Viewer::Type()) + return; + + SUIT_ViewModel* aViewModel = aViewManager->getViewModel(); + SALOME_View* aView = dynamic_cast(aViewModel); + if (aView == 0) return; + + //TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myObject); + + TopTools_IndexedMapOfShape aSubShapesMap; + TopExp::MapShapes(myShape, aSubShapesMap); + CORBA::String_var aMainEntry = myObject->GetStudyEntry(); + QString anEntryBase = aMainEntry.in(); + + TopExp_Explorer anExp (myShape, (TopAbs_ShapeEnum)shapeType()); + for (; anExp.More(); anExp.Next()) + { + TopoDS_Shape aSubShape = anExp.Current(); + int index = aSubShapesMap.FindIndex(aSubShape); + QString anEntry = anEntryBase + QString("_%1").arg(index); + + SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView); + if (aPrs) { + displayPreview(aPrs, true, false); // append, do not update + } + } + aDisplayer->UpdateViewer(); + aDisplayer->SetDisplayMode(prevDisplayMode); + } + + globalSelection(GEOM_ALLSHAPES); +} + //================================================================================= // function : createOperation // purpose : //================================================================================= GEOM::GEOM_IOperations_ptr EntityGUI_SubShapeDlg::createOperation() { - return getGeomEngine()->GetIShapesOperations( getStudyId() ); + return getGeomEngine()->GetIShapesOperations(getStudyId()); } //================================================================================= @@ -532,20 +680,12 @@ bool EntityGUI_SubShapeDlg::isValid (QString& msg) if (isAllSubShapes()) isOk = true; else { - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - - if (aSelList.Extent() == 1) { - GEOM::GEOM_Object_var anObj = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - if ( !anObj->_is_nil() ) { - TColStd_IndexedMapOfInteger aMapIndex; - aSelMgr->GetIndexes(aSelList.First(), aMapIndex); - isOk = aMapIndex.Extent() > 0; - if (!isOk) - msg += tr("NO_SUBSHAPES_SELECTED"); - } - } + TColStd_IndexedMapOfInteger aMapIndex; + int nbSel = getSelectedSubshapes(aMapIndex); + isOk = nbSel > 0; + + if (!isOk) + msg += tr("NO_SUBSHAPES_SELECTED"); } return isOk; @@ -566,25 +706,18 @@ bool EntityGUI_SubShapeDlg::execute (ObjectList& objects) // Throw away sub-shapes not selected by user if not in preview mode // and manual selection is active if (!isAllSubShapes()) { - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - - if (aSelList.Extent() == 1) { - GEOM::GEOM_Object_var anObj = - GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - - if ( !anObj->_is_nil() ) { - TColStd_IndexedMapOfInteger aMapIndex; - aSelMgr->GetIndexes(aSelList.First(), aMapIndex); - - GEOM::GEOM_ILocalOperations_var aLocOp = - getGeomEngine()->GetILocalOperations(getStudyId()); - - for (int i = 0, n = aList->length(); i < n; i++) - if (aMapIndex.Contains(aLocOp->GetSubShapeIndex(myObject, aList[i]))) - objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i])); - } + TColStd_IndexedMapOfInteger aMapIndex; + int nbSel = getSelectedSubshapes(aMapIndex); + + if (nbSel > 0) { + GEOM::GEOM_ILocalOperations_var aLocOp = + getGeomEngine()->GetILocalOperations(getStudyId()); + + for (int i = 0, n = aList->length(); i < n; i++) + if (aMapIndex.Contains(aLocOp->GetSubShapeIndex(myObject, aList[i]))) + objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i])); + else + aList[i]->UnRegister(); } } else @@ -597,13 +730,17 @@ bool EntityGUI_SubShapeDlg::execute (ObjectList& objects) //================================================================ // Function : getFather // Purpose : Get father object for object to be added in study -// ( called with addInStudy method ) +// (called with addInStudy method) //================================================================ -GEOM::GEOM_Object_ptr EntityGUI_SubShapeDlg::getFather( GEOM::GEOM_Object_ptr ) +GEOM::GEOM_Object_ptr EntityGUI_SubShapeDlg::getFather(GEOM::GEOM_Object_ptr) { return myObject; } +//================================================================ +// Function : getNewObjectName +// Purpose : +//================================================================ QString EntityGUI_SubShapeDlg::getNewObjectName() const { return QString::null; diff --git a/src/EntityGUI/EntityGUI_SubShapeDlg.h b/src/EntityGUI/EntityGUI_SubShapeDlg.h index added8581..15df70813 100644 --- a/src/EntityGUI/EntityGUI_SubShapeDlg.h +++ b/src/EntityGUI/EntityGUI_SubShapeDlg.h @@ -18,70 +18,76 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : EntityGUI_SubShapeDlg.h // Author : Lucien PIGNOLONI, Open CASCADE S.A.S. -// + #ifndef ENTITYGUI_SUBSHAPEDLG_H #define ENTITYGUI_SUBSHAPEDLG_H #include -class DlgRef_1Sel1Check1List; +#include + +class DlgRef_1Sel1List1Check3Btn; //================================================================================= // class : EntityGUI_SubShapeDlg // purpose : //================================================================================= class EntityGUI_SubShapeDlg : public GEOMBase_Skeleton -{ +{ Q_OBJECT public: - EntityGUI_SubShapeDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0 ); + EntityGUI_SubShapeDlg (GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0); ~EntityGUI_SubShapeDlg(); protected: // redefined from GEOMBase_Helper virtual GEOM::GEOM_IOperations_ptr createOperation(); - virtual bool isValid( QString& ); - virtual bool execute( ObjectList& ); - virtual GEOM::GEOM_Object_ptr getFather( GEOM::GEOM_Object_ptr ); + virtual bool isValid (QString&); + virtual bool execute (ObjectList&); + virtual GEOM::GEOM_Object_ptr getFather (GEOM::GEOM_Object_ptr); virtual QString getNewObjectName() const; + void closeEvent (QCloseEvent*); + private slots: void ClickOnOk(); bool ClickOnApply(); void ActivateThisDialog(); - void DeactivateActiveDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void SubShapeToggled(); void ComboTextChanged(); + void showOnlySelected(); + private: void Init(); - void enterEvent( QEvent* ); + void enterEvent (QEvent*); void ResetStateOfDialog(); - unsigned int NumberOfSubShapes( const TopoDS_Shape&, - const int ) const; + unsigned int NumberOfSubShapes (const TopoDS_Shape&, + const int) const; + + void activateSelection(); + int getSelectedSubshapes (TColStd_IndexedMapOfInteger& theMapIndex); void updateButtonState(); bool isAllSubShapes() const; int shapeType() const; -private: +private: TopoDS_Shape myShape; GEOM::GEOM_Object_var myObject; - - bool myWithShape; - - DlgRef_1Sel1Check1List* GroupPoints; - ObjectList myResult; + + bool myWithShape; + + DlgRef_1Sel1List1Check3Btn* GroupPoints; }; #endif // ENTITYGUI_SUBSHAPEDLG_H diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index b4725cbe5..ce17adc22 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -4263,6 +4263,18 @@ Otherwise the dimensions will be kept without modifications. GEOM_PLUGINS_OTHER Other + + SHOW_ONLY_SELECTED + Show only selected + + + HIDE_SELECTED + Hide selected + + + SHOW_ALL_SUB_SHAPES + Show all sub-shapes + BasicGUI_CurveDlg @@ -4513,18 +4525,6 @@ Number of sketch points too small REMOVE Remove - - SHOW_ONLY_SELECTED - Show only selected - - - HIDE_SELECTED - Hide selected - - - SHOW_ALL_SUB_SHAPES - Show all sub-shapes - SELECT_ALL Select All diff --git a/src/GEOMGUI/GEOM_msg_fr.ts b/src/GEOMGUI/GEOM_msg_fr.ts index bf64e7c49..4a713af33 100644 --- a/src/GEOMGUI/GEOM_msg_fr.ts +++ b/src/GEOMGUI/GEOM_msg_fr.ts @@ -4231,6 +4231,18 @@ le paramètre '%1' aux préférences du module Géométrie.GEOM_PLUGINS_OTHER Autre + + SHOW_ONLY_SELECTED + Afficher uniquement la sélection + + + HIDE_SELECTED + Cacher la sélection + + + SHOW_ALL_SUB_SHAPES + Afficher tous les sous-objets + BasicGUI_CurveDlg @@ -4473,18 +4485,6 @@ Le nombre de points n'est pas suffisant REMOVE Supprimer - - SHOW_ONLY_SELECTED - Afficher uniquement la sélection - - - HIDE_SELECTED - Cacher la sélection - - - SHOW_ALL_SUB_SHAPES - Afficher tous les sous-objets - SELECT_ALL Tout sélectionner