From: asl Date: Wed, 13 Jul 2005 04:25:18 +0000 (+0000) Subject: Dialogs were divided to "operation and dialog" X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c2e6b533c62051a21ff6a90d21cb25e434960776;p=modules%2Fsmesh.git Dialogs were divided to "operation and dialog" --- diff --git a/src/SMESHGUI/Makefile.in b/src/SMESHGUI/Makefile.in index acc7d63ef..b587937df 100644 --- a/src/SMESHGUI/Makefile.in +++ b/src/SMESHGUI/Makefile.in @@ -59,6 +59,7 @@ LIB_SRC = SMESHGUI.cxx \ SMESHGUI_MeshPatternDlg.cxx \ SMESHGUI_SpinBox.cxx \ SMESHGUI_NodesDlg.cxx \ + SMESHGUI_NodesOp.cxx \ SMESHGUI_InitMeshDlg.cxx \ SMESHGUI_InitMeshOp.cxx \ SMESHGUI_AddSubMeshDlg.cxx \ @@ -78,6 +79,7 @@ LIB_SRC = SMESHGUI.cxx \ SMESHGUI_MoveNodesDlg.cxx \ SMESHGUI_AddMeshElementDlg.cxx \ SMESHGUI_EditHypothesesDlg.cxx \ + SMESHGUI_EditHypothesesOp.cxx \ SMESHGUI_CreateHypothesesDlg.cxx \ SMESHGUI_XmlHandler.cxx \ SMESHGUI_Filter.cxx \ @@ -88,6 +90,7 @@ LIB_SRC = SMESHGUI.cxx \ SMESHGUI_aParameter.cxx \ SMESHGUI_DeleteGroupDlg.cxx \ SMESHGUI_GroupOpDlg.cxx \ + SMESHGUI_GroupOp.cxx \ SMESHGUI_SmoothingDlg.cxx \ SMESHGUI_RenumberingDlg.cxx \ SMESHGUI_ExtrusionDlg.cxx \ @@ -110,7 +113,8 @@ LIB_SRC = SMESHGUI.cxx \ SMESHGUI_Selection.cxx \ SMESHGUI_CreatePolyhedralVolumeDlg.cxx \ SMESHGUI_Dialog.cxx \ - SMESHGUI_Operation.cxx + SMESHGUI_Operation.cxx \ + SMESHGUI_SelectionOp.cxx LIB_MOC = \ SMESHGUI.h \ @@ -118,6 +122,7 @@ LIB_MOC = \ SMESHGUI_MeshPatternDlg.h \ SMESHGUI_CreatePatternDlg.h \ SMESHGUI_NodesDlg.h \ + SMESHGUI_NodesOp.h \ SMESHGUI_SpinBox.h \ SMESHGUI_InitMeshDlg.h \ SMESHGUI_InitMeshOp.h \ @@ -137,6 +142,7 @@ LIB_MOC = \ SMESHGUI_MoveNodesDlg.h \ SMESHGUI_AddMeshElementDlg.h \ SMESHGUI_EditHypothesesDlg.h \ + SMESHGUI_EditHypothesesOp.h \ SMESHGUI_CreateHypothesesDlg.h \ SMESHGUI_FilterDlg.h \ SMESHGUI_FilterLibraryDlg.h \ @@ -144,6 +150,7 @@ LIB_MOC = \ SMESHGUI_MultiEditDlg.h \ SMESHGUI_DeleteGroupDlg.h \ SMESHGUI_GroupOpDlg.h \ + SMESHGUI_GroupOp.h \ SMESHGUI_SmoothingDlg.h \ SMESHGUI_RenumberingDlg.h \ SMESHGUI_ExtrusionDlg.h \ @@ -157,7 +164,8 @@ LIB_MOC = \ SMESHGUI_MergeNodesDlg.h \ SMESHGUI_Dialog.h \ SMESHGUI_CreatePolyhedralVolumeDlg.h \ - SMESHGUI_Operation.h + SMESHGUI_Operation.h \ + SMESHGUI_SelectionOp.h LIB_CLIENT_IDL = SALOME_Exception.idl \ GEOM_Gen.idl \ diff --git a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx index 0735b21c2..584533e6c 100644 --- a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx @@ -59,6 +59,7 @@ SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( SMESHGUI* theModule ) new QLabel(tr("SMESH_NAME"), GroupC1, "TextLabel_NameMesh"); GroupC1->addSpace(1); myMeshName = new QLineEdit(GroupC1, "LineEdit_NameMesh"); + connect( myMeshName, SIGNAL( textChanged( const QString& ) ), this, SIGNAL( nameChanged( const QString& ) ) ); createObject( tr("SMESH_OBJECT_MESH"), GroupC1, MeshObj ); createObject( tr("SMESH_OBJECT_GEOM"), GroupC1, GeomObj ); @@ -85,29 +86,19 @@ SMESHGUI_AddSubMeshDlg::~SMESHGUI_AddSubMeshDlg() } //================================================================================= -// function : updateControlState() -// purpose : -//================================================================================= -void SMESHGUI_AddSubMeshDlg::updateControlState( const bool isEnabled ) -{ - setButtonEnabled( isEnabled, OK | Apply ); -} - -//================================================================================= -// function : init() +// function : subMeshName // purpose : //================================================================================= -void SMESHGUI_AddSubMeshDlg::init() +QString SMESHGUI_AddSubMeshDlg::subMeshName() const { - clearSelection(); - myMeshName->setText( tr( "SMESH_SUBMESH" ) ); + return myMeshName->text().stripWhiteSpace(); } //================================================================================= -// function : subMeshName +// function : setSubMeshName // purpose : //================================================================================= -QString SMESHGUI_AddSubMeshDlg::subMeshName() const +void SMESHGUI_AddSubMeshDlg::setSubMeshName( const QString& name ) { - return myMeshName->text().stripWhiteSpace(); + myMeshName->setText( name ); } diff --git a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h index 1ccde29f4..3b0645847 100644 --- a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h +++ b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h @@ -48,10 +48,12 @@ public: SMESHGUI_AddSubMeshDlg( SMESHGUI* ); ~SMESHGUI_AddSubMeshDlg(); - void init(); - void updateControlState( const bool ); + void setSubMeshName( const QString& ); QString subMeshName() const; +signals: + void nameChanged( const QString& ); + private: QLineEdit* myMeshName; diff --git a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx index b03e461ac..a5fa046f7 100644 --- a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx @@ -28,77 +28,13 @@ #include "SMESHGUI_EditHypothesesDlg.h" -#include "SMESHGUI.h" -#include "SMESHGUI_Utils.h" -#include "SMESHGUI_GEOMGenUtils.h" -#include "SMESHGUI_HypothesesUtils.h" - -#include "SMESH_TypeFilter.hxx" -#include "SMESH_NumberFilter.hxx" - -#include "SALOME_ListIO.hxx" -#include "SALOME_ListIteratorOfListIO.hxx" - -#include "SALOMEDSClient_Study.hxx" -#include "SALOMEDSClient_AttributeIOR.hxx" -#include "SALOMEDSClient_AttributeName.hxx" - -#include "SUIT_Session.h" -#include "SUIT_OverrideCursor.h" -#include "SUIT_Operation.h" -#include "SUIT_Desktop.h" - -#include "utilities.h" - -#include "SVTK_ViewModel.h" - -// QT Includes +#include +#include #include #include -#include -#include -#include -#include - -using namespace std; - -//VRV: porting on Qt 3.0.5 -#if QT_VERSION >= 0x030005 -#include -#endif -//VRV: porting on Qt 3.0.5 - -class ListBoxIOR : public QListBoxText -{ -public: - enum { RTTI_IOR = 1000 }; - -public: - ListBoxIOR (QListBox* listbox, - const char* ior, - const QString& text = QString::null) - : QListBoxText(listbox, text), myIOR(ior) {} - virtual ~ListBoxIOR() {}; - virtual int rtti() const { return RTTI_IOR; } - const char* GetIOR() { return myIOR.c_str(); } - -private: - string myIOR; -}; - -#define ALLOW_CHANGE_SHAPE 0 -int findItem (QListBox* listBox, const string& ior) -{ - for (int i = 0; i < listBox->count(); i++) { - if (listBox->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { - ListBoxIOR* anItem = (ListBoxIOR*)(listBox->item(i)); - if (anItem && ior == string(anItem->GetIOR())) - return i; - } - } - return -1; -} +#include +#include CORBA_SERVER_HEADER(SMESH_Gen) //================================================================================= // function : SMESHGUI_EditHypothesesDlg() @@ -107,56 +43,25 @@ int findItem (QListBox* listBox, const string& ior) // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg (SMESHGUI* theModule, const char* name, - bool modal, WFlags fl) - : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | - WStyle_Title | WStyle_SysMenu | WDestructiveClose), - myImportedMesh(false), - mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) +SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg( SMESHGUI* theModule ) +: SMESHGUI_Dialog( theModule, false, true ) { - QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); - if (!name) - setName("SMESHGUI_EditHypothesesDlg"); + setName("SMESHGUI_EditHypothesesDlg"); setCaption(tr("SMESH_EDIT_HYPOTHESES")); - setSizeGripEnabled(TRUE); - QGridLayout* SMESHGUI_EditHypothesesDlgLayout = new QGridLayout(this); - SMESHGUI_EditHypothesesDlgLayout->setSpacing(6); - SMESHGUI_EditHypothesesDlgLayout->setMargin(11); + + QVBoxLayout* main = new QVBoxLayout( mainFrame(), 0, 5 ); /***************************************************************/ - GroupC1 = new QGroupBox(tr("SMESH_ARGUMENTS"), this, "GroupC1"); - GroupC1->setColumnLayout(0, Qt::Vertical); - GroupC1->layout()->setSpacing(0); - GroupC1->layout()->setMargin(0); - QGridLayout* GroupC1Layout = new QGridLayout(GroupC1->layout()); - GroupC1Layout->setAlignment(Qt::AlignTop); - GroupC1Layout->setSpacing(6); - GroupC1Layout->setMargin(11); - - TextLabelC1A1 = new QLabel(tr("SMESH_OBJECT_MESHorSUBMESH"), GroupC1, "TextLabelC1A1"); - GroupC1Layout->addWidget(TextLabelC1A1, 0, 0); - SelectButtonC1A1 = new QPushButton(GroupC1, "SelectButtonC1A1"); - SelectButtonC1A1->setPixmap(image0); - GroupC1Layout->addWidget(SelectButtonC1A1, 0, 1); - LineEditC1A1 = new QLineEdit(GroupC1, "LineEditC1A1"); - LineEditC1A1->setReadOnly(true); - GroupC1Layout->addWidget(LineEditC1A1, 0, 2); - - TextLabelC1A2 = new QLabel(tr("SMESH_OBJECT_GEOM"), GroupC1, "TextLabelC1A2"); - GroupC1Layout->addWidget(TextLabelC1A2, 1, 0); - SelectButtonC1A2 = new QPushButton(GroupC1, "SelectButtonC1A2"); - SelectButtonC1A2->setPixmap(image0); - SelectButtonC1A2->setToggleButton(FALSE); - GroupC1Layout->addWidget(SelectButtonC1A2, 1, 1); - LineEditC1A2 = new QLineEdit(GroupC1, "LineEditC1A2"); - LineEditC1A2->setReadOnly(true); - GroupC1Layout->addWidget(LineEditC1A2, 1, 2); - - SMESHGUI_EditHypothesesDlgLayout->addWidget(GroupC1, 0, 0); + QGroupBox* GroupC1 = new QGroupBox(tr("SMESH_ARGUMENTS"), mainFrame(), "GroupC1"); + GroupC1->setColumnLayout( 3, Qt::Horizontal ); + + createObject( tr("SMESH_OBJECT_MESHorSUBMESH"), GroupC1, MeshOrSubMesh ); + createObject( tr("SMESH_OBJECT_GEOM"), GroupC1, GeomShape ); + + main->addWidget( GroupC1 ); /***************************************************************/ - GroupHypotheses = new QGroupBox(tr("SMESH_HYPOTHESES"), this, "GroupHypotheses"); + GroupHypotheses = new QGroupBox(tr("SMESH_HYPOTHESES"), mainFrame(), "GroupHypotheses"); GroupHypotheses->setColumnLayout(0, Qt::Vertical); GroupHypotheses->layout()->setSpacing(0); GroupHypotheses->layout()->setMargin(0); @@ -179,10 +84,10 @@ SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg (SMESHGUI* theModule, con ListHypAssignation->setMinimumSize(100, 100); grid_3->addWidget(ListHypAssignation, 1, 1); - SMESHGUI_EditHypothesesDlgLayout->addWidget(GroupHypotheses, 1, 0); + main->addWidget( GroupHypotheses ); /***************************************************************/ - GroupAlgorithms = new QGroupBox(tr("SMESH_ADD_ALGORITHM"), this, "GroupAlgorithms"); + GroupAlgorithms = new QGroupBox(tr("SMESH_ADD_ALGORITHM"), mainFrame(), "GroupAlgorithms"); GroupAlgorithms->setColumnLayout(0, Qt::Vertical); GroupAlgorithms->layout()->setSpacing(0); GroupAlgorithms->layout()->setMargin(0); @@ -205,40 +110,13 @@ SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg (SMESHGUI* theModule, con ListAlgoAssignation ->setMinimumSize(100, 100); grid_4->addWidget(ListAlgoAssignation, 1, 1); - SMESHGUI_EditHypothesesDlgLayout->addWidget(GroupAlgorithms, 2, 0); + main->addWidget( GroupAlgorithms ); - /***************************************************************/ - GroupButtons = new QGroupBox(this, "GroupButtons"); - GroupButtons->setColumnLayout(0, Qt::Vertical); - GroupButtons->layout()->setSpacing(0); - GroupButtons->layout()->setMargin(0); - QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); - GroupButtonsLayout->setAlignment(Qt::AlignTop); - GroupButtonsLayout->setSpacing(6); - GroupButtonsLayout->setMargin(11); - - buttonOk = new QPushButton(tr("SMESH_BUT_OK"), GroupButtons, "buttonOk"); - buttonOk->setAutoDefault(TRUE); - buttonOk->setDefault(FALSE); - GroupButtonsLayout->addWidget(buttonOk, 0, 0); - - buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons, "buttonApply"); - buttonApply->setAutoDefault(TRUE); - buttonApply->setDefault(FALSE); - GroupButtonsLayout->addWidget(buttonApply, 0, 1); - - GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2); - - buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons, "buttonCancel"); - buttonCancel->setAutoDefault(TRUE); - buttonCancel->setDefault(TRUE); - buttonCancel->setEnabled(TRUE); - GroupButtonsLayout->addWidget(buttonCancel, 0, 3); - - SMESHGUI_EditHypothesesDlgLayout->addWidget(GroupButtons, 4, 0); + connect(ListHypAssignation, SIGNAL(doubleClicked(QListBoxItem*)), this, SLOT(removeItem(QListBoxItem*))); + connect(ListAlgoAssignation, SIGNAL(doubleClicked(QListBoxItem*)), this, SLOT(removeItem(QListBoxItem*))); - /***************************************************************/ - Init(); + connect(ListHypDefinition, SIGNAL(doubleClicked(QListBoxItem*)), this, SLOT(addItem(QListBoxItem*))); + connect(ListAlgoDefinition, SIGNAL(doubleClicked(QListBoxItem*)), this, SLOT(addItem(QListBoxItem*))); } //================================================================================= @@ -250,245 +128,11 @@ SMESHGUI_EditHypothesesDlg::~SMESHGUI_EditHypothesesDlg() // no need to delete child widgets, Qt does it all for us } -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void SMESHGUI_EditHypothesesDlg::Init() -{ - mySMESHGUI->SetActiveDialogBox((QDialog*)this); - - InitHypDefinition(); - InitAlgoDefinition(); - - //myGeomFilter = new SALOME_TypeFilter ("GEOM"); - TColStd_MapOfInteger allTypesMap; - for (int i = 0; i < 10; i++) - allTypesMap.Add(i); - myGeomFilter = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 0, allTypesMap); - myMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH); - - myGeomShape = GEOM::GEOM_Object::_nil(); - myMesh = SMESH::SMESH_Mesh::_nil(); - mySubMesh = SMESH::SMESH_subMesh::_nil(); - - /* signals and slots connections */ - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); - - connect(SelectButtonC1A1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); - connect(SelectButtonC1A2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); - - connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); - connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - - connect(ListHypAssignation, SIGNAL(doubleClicked(QListBoxItem*)), this, SLOT(removeItem(QListBoxItem*))); - connect(ListAlgoAssignation, SIGNAL(doubleClicked(QListBoxItem*)), this, SLOT(removeItem(QListBoxItem*))); - - connect(ListHypDefinition, SIGNAL(doubleClicked(QListBoxItem*)), this, SLOT(addItem(QListBoxItem*))); - connect(ListAlgoDefinition, SIGNAL(doubleClicked(QListBoxItem*)), this, SLOT(addItem(QListBoxItem*))); - - int x, y; - mySMESHGUI->DefineDlgPosition(this, x, y); - this->move(x, y); - this->show(); - - LineEditC1A1->setFocus(); - myEditCurrentArgument = LineEditC1A1; - mySelectionMgr->clearFilters(); - mySelectionMgr->installFilter(myMeshOrSubMeshFilter); - - SelectionIntoArgument(); - - UpdateControlState(); -} - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void SMESHGUI_EditHypothesesDlg::ClickOnOk() -{ - if (ClickOnApply()) - ClickOnCancel(); -} - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -bool SMESHGUI_EditHypothesesDlg::ClickOnApply() -{ - if (mySMESHGUI->isActiveStudyLocked()) - return false; - - bool aRes = false; - - SUIT_OverrideCursor wc; - - SUIT_Operation* op = new SUIT_Operation - (SUIT_Session::session()->activeApplication()); - - // start transaction - op->start(); - - if (!myMesh->_is_nil()) - aRes = StoreMesh(); - else if (!mySubMesh->_is_nil()) - aRes = StoreSubMesh(); - - if (true/*aRes*/) { // abort desynchronizes contents of a Study and a mesh on server - // commit transaction - op->commit(); - InitHypAssignation(); - InitAlgoAssignation(); - } else { - // abort transaction - op->abort(); - } - - UpdateControlState(); - mySMESHGUI->updateObjBrowser(); - - return aRes; -} - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void SMESHGUI_EditHypothesesDlg::ClickOnCancel() -{ - close(); -} - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= -void SMESHGUI_EditHypothesesDlg::SelectionIntoArgument() -{ - QString aString = ""; - - SALOME_ListIO aList; - mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); - - int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); - - if (myEditCurrentArgument == LineEditC1A1) { - if (nbSel != 1) { - myMesh = SMESH::SMESH_Mesh::_nil(); - mySubMesh = SMESH::SMESH_subMesh::_nil(); - aString = ""; - } else { - Handle(SALOME_InteractiveObject) IO = aList.First(); - myMesh = SMESH::IObjectToInterface(IO); - if (myMesh->_is_nil()) { - mySubMesh = SMESH::IObjectToInterface(IO); - if (mySubMesh->_is_nil()) { - aString = ""; - } - } - } - myEditCurrentArgument->setText(aString); - - // InitGeom() will try to retrieve a shape from myMesh or mySubMesh - myGeomShape = GEOM::GEOM_Object::_nil(); - InitGeom(); - - myImportedMesh = myGeomShape->_is_nil(); - - InitHypAssignation(); - InitAlgoAssignation(); - - } else if (myEditCurrentArgument == LineEditC1A2) { - if (nbSel != 1) { - myGeomShape = GEOM::GEOM_Object::_nil(); - } else { - Handle(SALOME_InteractiveObject) IO = aList.First(); - myGeomShape = SMESH::IObjectToInterface(IO); - } - InitGeom(); - } - - UpdateControlState(); -} - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void SMESHGUI_EditHypothesesDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus(); - myEditCurrentArgument = LineEditC1A1; - mySelectionMgr->clearFilters(); - mySelectionMgr->installFilter(myMeshOrSubMeshFilter); - } else if (send == SelectButtonC1A2) { - LineEditC1A2->setFocus(); - myEditCurrentArgument = LineEditC1A2; - mySelectionMgr->clearFilters(); - mySelectionMgr->installFilter(myGeomFilter); - } - SelectionIntoArgument(); -} - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void SMESHGUI_EditHypothesesDlg::DeactivateActiveDialog() -{ - if (GroupC1->isEnabled()) { - disconnect(mySelectionMgr, 0, this, 0); - GroupC1->setEnabled(false); - GroupButtons->setEnabled(false); - } -} - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void SMESHGUI_EditHypothesesDlg::ActivateThisDialog() -{ - mySMESHGUI->EmitSignalDeactivateDialog(); - GroupC1->setEnabled(true); - GroupButtons->setEnabled(true); - connect (mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); -} - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void SMESHGUI_EditHypothesesDlg::enterEvent (QEvent*) -{ - if (!GroupC1->isEnabled()) - ActivateThisDialog(); -} - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_EditHypothesesDlg::closeEvent (QCloseEvent* e) -{ - disconnect(mySelectionMgr, 0, this, 0); - mySMESHGUI->ResetState(); - mySelectionMgr->clearFilters(); - QDialog::closeEvent(e); -} - //======================================================================= -// function : IsOld() +// function : isOld() // purpose : //======================================================================= -bool SMESHGUI_EditHypothesesDlg::IsOld (QListBoxItem* hypItem) +bool SMESHGUI_EditHypothesesDlg::isOld (QListBoxItem* hypItem) { if (hypItem->rtti() == ListBoxIOR::RTTI_IOR) { ListBoxIOR* hyp = (ListBoxIOR*) hypItem; @@ -510,15 +154,15 @@ void SMESHGUI_EditHypothesesDlg::removeItem (QListBoxItem* item) if (!item) return; if (aSender == ListHypAssignation) { - myNbModification += IsOld(item) ? 1 : -1; + myNbModification += isOld(item) ? 1 : -1; ListHypAssignation->removeItem(ListHypAssignation->index(item)); } else if (aSender == ListAlgoAssignation) { - myNbModification += IsOld(item) ? 1 : -1; + myNbModification += isOld(item) ? 1 : -1; ListAlgoAssignation->removeItem(ListAlgoAssignation->index(item)); } - UpdateControlState(); + emit( needToUpdate() ); } //================================================================================= @@ -566,397 +210,64 @@ void SMESHGUI_EditHypothesesDlg::addItem (QListBoxItem* item) } if (!isFound) - myNbModification += IsOld(item) ? -1 : 1; + myNbModification += isOld(item) ? -1 : 1; - UpdateControlState(); + emit( needToUpdate() ); } //================================================================================= -// function : InitHypDefinition() +// function : setListsEnabled() // purpose : //================================================================================= -void SMESHGUI_EditHypothesesDlg::InitHypDefinition() +void SMESHGUI_EditHypothesesDlg::setListsEnabled( const bool en ) { - ListHypDefinition->clear(); - - _PTR(SComponent) father = SMESH::GetActiveStudyDocument()->FindComponent("SMESH"); - if (!father) - return; - - _PTR(SObject) HypothesisRoot; - _PTR(GenericAttribute) anAttr; - _PTR(AttributeName) aName; - _PTR(AttributeIOR) anIOR; - - //int Tag_HypothesisRoot = 1; - if (father->FindSubObject(1, HypothesisRoot)) { - _PTR(ChildIterator) it = - SMESH::GetActiveStudyDocument()->NewChildIterator(HypothesisRoot); - ListBoxIOR* anItem; - for (; it->More();it->Next()) { - _PTR(SObject) Obj = it->Value(); - if (Obj->FindAttribute(anAttr, "AttributeName")) { - aName = anAttr; - if (Obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = anAttr; - anItem = new ListBoxIOR (ListHypDefinition, - anIOR->Value().c_str(), - aName->Value().c_str()); - } - } - } - } + ListHypDefinition ->setEnabled( en ); + ListHypAssignation ->setEnabled( en ); + ListAlgoDefinition ->setEnabled( en ); + ListAlgoAssignation->setEnabled( en ); } //================================================================================= -// function : InitHypAssignation() +// function : hypoCount() // purpose : //================================================================================= -void SMESHGUI_EditHypothesesDlg::InitHypAssignation() +int SMESHGUI_EditHypothesesDlg::hypoCount() const { - myNbModification = 0; - - myMapOldHypos.clear(); - ListHypAssignation->clear(); - if (myImportedMesh) - return; - - _PTR(SObject) aMorSM, AHR, aRef; - _PTR(GenericAttribute) anAttr; - _PTR(AttributeName) aName; - _PTR(AttributeIOR) anIOR; - - if (!myMesh->_is_nil()) - aMorSM = SMESH::FindSObject(myMesh); - else if (!mySubMesh->_is_nil()) - aMorSM = SMESH::FindSObject(mySubMesh); - - if (aMorSM && aMorSM->FindSubObject(2, AHR)) { - _PTR(ChildIterator) it = - SMESH::GetActiveStudyDocument()->NewChildIterator(AHR); - for (; it->More();it->Next()) { - _PTR(SObject) Obj = it->Value(); - if (Obj->ReferencedObject(aRef)) { - if (aRef->FindAttribute(anAttr, "AttributeName")) { - aName = anAttr; - if (aRef->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = anAttr; - ListBoxIOR* anItem = new ListBoxIOR (ListHypAssignation, - anIOR->Value().c_str(), - aName->Value().c_str()); - myMapOldHypos[ anIOR->Value() ] = ListHypAssignation->index(anItem); - } - } - } - } - } + return ListHypAssignation->count(); } //================================================================================= -// function : InitAlgoDefinition() +// function : algoCount() // purpose : //================================================================================= -void SMESHGUI_EditHypothesesDlg::InitAlgoDefinition() +int SMESHGUI_EditHypothesesDlg::algoCount() const { - ListAlgoDefinition->clear(); - - _PTR(SComponent) father = SMESH::GetActiveStudyDocument()->FindComponent("SMESH"); - if (!father) - return; - - _PTR(SObject) AlgorithmsRoot; - _PTR(GenericAttribute) anAttr; - _PTR(AttributeName) aName; - _PTR(AttributeIOR) anIOR; - - if (father->FindSubObject (2, AlgorithmsRoot)) { - _PTR(ChildIterator) it = - SMESH::GetActiveStudyDocument()->NewChildIterator(AlgorithmsRoot); - ListBoxIOR* anItem; - for (; it->More();it->Next()) { - _PTR(SObject) Obj = it->Value(); - if (Obj->FindAttribute(anAttr, "AttributeName")) { - aName = anAttr; - if (Obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = anAttr; - anItem = new ListBoxIOR (ListAlgoDefinition, - anIOR->Value().c_str(), - aName->Value().c_str()); - } - } - } - } + return ListAlgoAssignation->count(); } //================================================================================= -// function : InitAlgoAssignation() +// function : isModified() // purpose : //================================================================================= -void SMESHGUI_EditHypothesesDlg::InitAlgoAssignation() +bool SMESHGUI_EditHypothesesDlg::isModified() const { - myMapOldAlgos.clear(); - ListAlgoAssignation->clear(); - if (myImportedMesh) - return; - - _PTR(SObject) aMorSM, AHR, aRef; - _PTR(GenericAttribute) anAttr; - _PTR(AttributeName) aName; - _PTR(AttributeIOR) anIOR; - - if (!myMesh->_is_nil()) - aMorSM = SMESH::FindSObject(myMesh); - else if (!mySubMesh->_is_nil()) - aMorSM = SMESH::FindSObject(mySubMesh); - - if (aMorSM && aMorSM->FindSubObject(3, AHR)) { - _PTR(ChildIterator) it = - SMESH::GetActiveStudyDocument()->NewChildIterator(AHR); - for (; it->More();it->Next()) { - _PTR(SObject) Obj = it->Value(); - if (Obj->ReferencedObject(aRef)) { - if (aRef->FindAttribute(anAttr, "AttributeName")) { - aName = anAttr; - if (aRef->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = anAttr; - ListBoxIOR* anItem = new ListBoxIOR (ListAlgoAssignation, - anIOR->Value().c_str(), - aName->Value().c_str()); - myMapOldAlgos[ anIOR->Value() ] = ListAlgoAssignation->index(anItem); - } - } - } - } - } + return myNbModification!=0; } //================================================================================= -// function : InitGeom() +// function : findItem() // purpose : //================================================================================= -void SMESHGUI_EditHypothesesDlg::InitGeom() +int SMESHGUI_EditHypothesesDlg::findItem( QListBox* listBox, const QString& ior ) { - LineEditC1A2->setText(""); - - if (myGeomShape->_is_nil() && !myMesh->_is_nil()) { - _PTR(SObject) aMesh = SMESH::FindSObject(myMesh); - if (aMesh) - myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMesh); - } - if (myGeomShape->_is_nil() && !mySubMesh->_is_nil()) { - _PTR(SObject) aSubMesh = SMESH::FindSObject(mySubMesh); - if (aSubMesh) - myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aSubMesh); - } - - _PTR(GenericAttribute) anAttr; - _PTR(AttributeName) aName; - if (!myGeomShape->_is_nil() && (!myMesh->_is_nil() || !mySubMesh->_is_nil())) { - _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - //_PTR(SObject) aSO = aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomShape)); - _PTR(SObject) aSO = aStudy->FindObjectID(myGeomShape->GetStudyEntry()); - if (aSO) { - if (aSO->FindAttribute(anAttr, "AttributeName")) { - aName = anAttr; - LineEditC1A2->setText(QString(aName->Value().c_str())); - } - } - } -} - -//================================================================================= -// function : UpdateControlState() -// purpose : -//================================================================================= -void SMESHGUI_EditHypothesesDlg::UpdateControlState() -{ - bool isEnabled = (!myMesh->_is_nil() && !myGeomShape->_is_nil() && - ListHypAssignation->count() && ListAlgoAssignation->count()) - || - (!mySubMesh->_is_nil() && !myGeomShape->_is_nil() && - (ListHypAssignation->count() || ListAlgoAssignation->count())); - - buttonOk ->setEnabled(myNbModification && isEnabled && !myImportedMesh); - buttonApply->setEnabled(myNbModification && isEnabled && !myImportedMesh); - - SelectButtonC1A2 ->setEnabled(ALLOW_CHANGE_SHAPE && !myImportedMesh); - LineEditC1A2 ->setEnabled(ALLOW_CHANGE_SHAPE && !myImportedMesh); - ListHypDefinition ->setEnabled(!myImportedMesh); - ListHypAssignation ->setEnabled(!myImportedMesh); - ListAlgoDefinition ->setEnabled(!myImportedMesh); - ListAlgoAssignation->setEnabled(!myImportedMesh); -} - -//================================================================================= -// function : StoreMesh() -// purpose : -//================================================================================= -bool SMESHGUI_EditHypothesesDlg::StoreMesh() -{ - MapIOR anOldHypos, aNewHypos; - if (myGeomShape->_is_nil()) - return false; - - // 1. Check whether the geometric shape has changed - _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh); - GEOM::GEOM_Object_var aIniGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMeshSO); - bool bShapeChanged = aIniGeomShape->_is_nil() || - !aIniGeomShape->_is_equivalent(myGeomShape); - if (bShapeChanged) { - // VSR : TODO : Set new shape - not supported yet by SMESH engine - // 1. remove all old hypotheses and algorithms and also submeshes - // 2. set new shape - } - - int nbFail = 0; - MapIOR::iterator it; - - // 2. remove not used hypotheses from the mesh - for (it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it) { - string ior = it->first; - int index = findItem(ListHypAssignation, ior); - if (index < 0) { - SMESH::SMESH_Hypothesis_var aHyp = - SMESH::IORToInterface(ior.c_str()); - if (!aHyp->_is_nil()) { - if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh(aMeshSO, aHyp)) - nbFail++; - } - } - } - - // 3. remove not used algorithms from the mesh - for (it = myMapOldAlgos.begin(); it != myMapOldAlgos.end(); ++it) { - string ior = it->first; - int index = findItem(ListAlgoAssignation, ior); - if (index < 0) { - SMESH::SMESH_Hypothesis_var aHyp = - SMESH::IORToInterface(ior.c_str()); - if (!aHyp->_is_nil()) { - if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh(aMeshSO, aHyp)) - nbFail++; - } - } - } - - // 4. Add new algorithms - for (int i = 0; i < ListAlgoAssignation->count(); i++) { - if (ListAlgoAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { - ListBoxIOR* anItem = (ListBoxIOR*)(ListAlgoAssignation->item(i)); - if (anItem) { - string ior = anItem->GetIOR(); - if (myMapOldAlgos.find(ior) == myMapOldAlgos.end()) { - SMESH::SMESH_Hypothesis_var aHyp = - SMESH::IORToInterface(ior.c_str()); - if (!aHyp->_is_nil()) { - if (!SMESH::AddHypothesisOnMesh(myMesh, aHyp)) - nbFail++; - } - } - } - } - } - - // 5. Add new hypotheses - for (int i = 0; i < ListHypAssignation->count(); i++) { - if (ListHypAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { - ListBoxIOR* anItem = (ListBoxIOR*)(ListHypAssignation->item(i)); - if (anItem) { - string ior = anItem->GetIOR(); - if (myMapOldHypos.find(ior) == myMapOldHypos.end()) { - SMESH::SMESH_Hypothesis_var aHyp = - SMESH::IORToInterface(ior.c_str()); - if (!aHyp->_is_nil()) { - if (!SMESH::AddHypothesisOnMesh(myMesh, aHyp)) - nbFail++; - } - } - } - } - } - return (nbFail == 0); -} - -//================================================================================= -// function : StoreSubMesh() -// purpose : -//================================================================================= -bool SMESHGUI_EditHypothesesDlg::StoreSubMesh() -{ - MapIOR anOldHypos, aNewHypos; - if (myGeomShape->_is_nil()) - return false; - - // 1. Check whether the geometric shape has changed - _PTR(SObject) aSubMeshSO = SMESH::FindSObject(mySubMesh); - GEOM::GEOM_Object_var aIniGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aSubMeshSO); - bool bShapeChanged = aIniGeomShape->_is_nil() || !aIniGeomShape->_is_equivalent(myGeomShape); - if (bShapeChanged) { - // VSR : TODO : Set new shape - not supported yet by engine - // 1. remove all old hypotheses and algorithms - // 2. set new shape - } - int nbFail = 0; - MapIOR::iterator it; - - // 2. remove not used hypotheses from the submesh - for (it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it) { - string ior = it->first; - int index = findItem(ListHypAssignation, ior); - if (index < 0) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); - if (!aHyp->_is_nil()) { - if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh(aSubMeshSO, aHyp)) - nbFail++; - } - } - } - - // 3. remove not used algorithms from the submesh - for (it = myMapOldAlgos.begin(); it != myMapOldAlgos.end(); ++it) { - string ior = it->first; - int index = findItem(ListAlgoAssignation, ior); - if (index < 0) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); - if (!aHyp->_is_nil()){ - if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh(aSubMeshSO, aHyp)) - nbFail++; - } - } - } - - // 4. Add new algorithms - for (int i = 0; i < ListAlgoAssignation->count(); i++) { - if (ListAlgoAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { - ListBoxIOR* anItem = (ListBoxIOR*)(ListAlgoAssignation->item(i)); - if (anItem) { - string ior = anItem->GetIOR(); - if (myMapOldAlgos.find(ior) == myMapOldAlgos.end()) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); - if (!aHyp->_is_nil()){ - if (!SMESH::AddHypothesisOnSubMesh(mySubMesh, aHyp)) - nbFail++; - } - } - } - } - } - - // 5. Add new hypotheses - for (int i = 0; i < ListHypAssignation->count(); i++) { - if (ListHypAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { - ListBoxIOR* anItem = (ListBoxIOR*)(ListHypAssignation->item(i)); - if (anItem) { - string ior = anItem->GetIOR(); - if (myMapOldHypos.find(ior) == myMapOldHypos.end()) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); - if (!aHyp->_is_nil()){ - if (!SMESH::AddHypothesisOnSubMesh(mySubMesh, aHyp)) - nbFail++; - } - } - } + for (int i = 0; i < listBox->count(); i++) + { + if (listBox->item(i)->rtti() == ListBoxIOR::RTTI_IOR) + { + ListBoxIOR* anItem = (ListBoxIOR*)(listBox->item(i)); + if( anItem && ior == anItem->GetIOR() ) + return i; } } - return (nbFail == 0); + return -1; } diff --git a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h index 6c40460e5..69e5d56ca 100644 --- a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h +++ b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h @@ -29,99 +29,65 @@ #ifndef DIALOGBOX_EDIT_HYPOTHESES_H #define DIALOGBOX_EDIT_HYPOTHESES_H -//#include "SMESH_TypeFilter.hxx" -#include "SUIT_SelectionFilter.h" -#include "SalomeApp_SelectionMgr.h" +#include +#include +#include -// QT Includes -#include +#include -// IDL Headers -#include -#include CORBA_SERVER_HEADER(GEOM_Gen) -#include CORBA_SERVER_HEADER(SMESH_Mesh) +typedef QMap< QString, int > MapIOR; +typedef QMap< QString, QString > MapIORText; -#include -#include +class ListBoxIOR : public QListBoxText +{ +public: + enum { RTTI_IOR = 1000 }; + +public: + ListBoxIOR (QListBox* listbox, + const QString& ior, + const QString& text = QString::null ) + : QListBoxText(listbox, text), myIOR(ior) {} + virtual ~ListBoxIOR() {}; + virtual int rtti() const { return RTTI_IOR; } + QString GetIOR() const { return myIOR; } -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QListBox; -class QListBoxItem; -class SMESHGUI; +private: + QString myIOR; +}; -typedef map MapIOR; //================================================================================= // class : SMESHGUI_EditHypothesesDlg // purpose : //================================================================================= -class SMESHGUI_EditHypothesesDlg : public QDialog +class SMESHGUI_EditHypothesesDlg : public SMESHGUI_Dialog { Q_OBJECT public: - SMESHGUI_EditHypothesesDlg (SMESHGUI*, - const char* name = 0, - bool modal = FALSE, - WFlags fl = 0); + enum { MeshOrSubMesh, GeomShape }; + typedef enum { HypoDef, HypoAssign, AlgoDef, AlgoAssign } ListType; + +public: + SMESHGUI_EditHypothesesDlg( SMESHGUI* ); ~SMESHGUI_EditHypothesesDlg(); -protected: - virtual void closeEvent (QCloseEvent*); - virtual void enterEvent (QEvent*); + void setListsEnabled( const bool ); + int hypoCount() const; + int algoCount() const; + bool isModified() const; + int findItem( QListBox*, const QString& ); +signals: + void needToUpdate(); + private: - void Init(); - - void InitHypDefinition(); - void InitAlgoDefinition(); - void InitHypAssignation(); - void InitAlgoAssignation(); - - void InitGeom(); - - void UpdateControlState(); - - bool StoreMesh(); - bool StoreSubMesh(); - - bool IsOld(QListBoxItem* hypItem); + bool isOld(QListBoxItem* hypItem); private: - SMESHGUI* mySMESHGUI; - SalomeApp_SelectionMgr* mySelectionMgr; - - GEOM::GEOM_Object_var myGeomShape; - QLineEdit* myEditCurrentArgument; - - SMESH::SMESH_Mesh_var myMesh; - SMESH::SMESH_subMesh_var mySubMesh; - - //Handle(SALOME_TypeFilter) myGeomFilter; - //Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter; - SUIT_SelectionFilter* myGeomFilter; - SUIT_SelectionFilter* myMeshOrSubMeshFilter; - - MapIOR myMapOldHypos, myMapOldAlgos; - int myNbModification; - - bool myImportedMesh; - - QGroupBox* GroupButtons; - QPushButton* buttonOk; - QPushButton* buttonApply; - QPushButton* buttonCancel; - - QGroupBox* GroupC1; - QLabel* TextLabelC1A1; - QPushButton* SelectButtonC1A1; - QLineEdit* LineEditC1A1; - QLabel* TextLabelC1A2; - QPushButton* SelectButtonC1A2; - QLineEdit* LineEditC1A2; + MapIOR myMapOldHypos, myMapOldAlgos; + int myNbModification; QGroupBox* GroupHypotheses; QLabel* TextHypDefinition; @@ -136,16 +102,11 @@ private: QListBox* ListAlgoAssignation; private slots: - void ClickOnOk(); - bool ClickOnApply(); - void ClickOnCancel(); - void SetEditCurrentArgument(); - void SelectionIntoArgument(); - void DeactivateActiveDialog(); - void ActivateThisDialog(); - void removeItem(QListBoxItem*); void addItem(QListBoxItem*); + +private: + friend class SMESHGUI_EditHypothesesOp; }; #endif // DIALOGBOX_EDIT_HYPOTHESES_H diff --git a/src/SMESHGUI/SMESHGUI_EditHypothesesOp.cxx b/src/SMESHGUI/SMESHGUI_EditHypothesesOp.cxx new file mode 100644 index 000000000..6c0226cc6 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_EditHypothesesOp.cxx @@ -0,0 +1,499 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_EditHypothesesOp.cxx +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +#include "SMESHGUI_EditHypothesesOp.h" +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#include + +#define ALLOW_CHANGE_SHAPE 0 + +//================================================================================= +// function : +// purpose : +//================================================================================= +SMESHGUI_EditHypothesesOp::SMESHGUI_EditHypothesesOp() +: SMESHGUI_SelectionOp(), + myDlg( 0 ), + myImportedMesh( false ) +{ +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +SMESHGUI_EditHypothesesOp::~SMESHGUI_EditHypothesesOp() +{ + if( myDlg ) + delete myDlg; +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +SalomeApp_Dialog* SMESHGUI_EditHypothesesOp::dlg() const +{ + return myDlg; +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesOp::startOperation() +{ + if( !myDlg ) + { + myDlg = new SMESHGUI_EditHypothesesDlg( getSMESHGUI() ); + connect( myDlg, SIGNAL( needToUpdate() ), this, SLOT( onUpdate() ) ); + } + + SMESHGUI_SelectionOp::startOperation(); + + myDlg->show(); +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesOp::selectionDone() +{ + SMESHGUI_SelectionOp::selectionDone(); + if( myDlg ) + updateDialog(); +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +bool SMESHGUI_EditHypothesesOp::onApply() +{ + if( getSMESHGUI()->isActiveStudyLocked() ) + return false; + + bool aRes = false; + + SUIT_OverrideCursor wc; + + aRes = storeMeshOrSubMesh(); + if( aRes ) + { + initHypAssignation(); + initAlgoAssignation(); + } + + update( UF_Model | UF_ObjBrowser ); + + initDialog(); + return aRes; +} + +//================================================================================= +// function : onSelectionChanged +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesOp::onSelectionChanged( int id ) +{ + if( id==SMESHGUI_EditHypothesesDlg::MeshOrSubMesh ) + { + initGeom(); + myImportedMesh = !myDlg->hasSelection( SMESHGUI_EditHypothesesDlg::GeomShape ); + initHypAssignation(); + initAlgoAssignation(); + updateDialog(); + } + else if( id==SMESHGUI_EditHypothesesDlg::GeomShape ) + { + } +} + +//================================================================================= +// function : initGeom +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesOp::initGeom() +{ + QStringList selMesh; myDlg->selectedObject( SMESHGUI_EditHypothesesDlg::MeshOrSubMesh, selMesh ); + if( selMesh.isEmpty() ) + return; + + _PTR(SObject) aMesh = studyDS()->FindObjectID( selMesh.first() ); + GEOM::GEOM_Object_var aGeomShape = SMESH::GetShapeOnMeshOrSubMesh( aMesh ); + if( !aGeomShape->_is_nil() ) + { + QString name, id = aGeomShape->GetStudyEntry(); + + _PTR(GenericAttribute) anAttr; + _PTR(AttributeName) aName; + _PTR(SObject) aSO = studyDS()->FindObjectID(aGeomShape->GetStudyEntry()); + if (aSO) + if (aSO->FindAttribute(anAttr, "AttributeName")) + { + aName = anAttr; + name = aName->Value().c_str(); + } + + int type = aGeomShape->GetType(); + myDlg->selectObject( SMESHGUI_EditHypothesesDlg::GeomShape, name, type, id ); + } +} + +//================================================================================= +// function : initHypDefinition +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesOp::initHypDefinition() +{ + myDlg->ListHypDefinition->clear(); + + _PTR(Study) study = studyDS(); + _PTR(SComponent) father = study->FindComponent("SMESH"); + if (!father) + return; + + _PTR(SObject) HypothesisRoot; + _PTR(GenericAttribute) anAttr; + _PTR(AttributeName) aName; + _PTR(AttributeIOR) anIOR; + + //int Tag_HypothesisRoot = 1; + if (father->FindSubObject(1, HypothesisRoot)) { + _PTR(ChildIterator) it = + study->NewChildIterator(HypothesisRoot); + ListBoxIOR* anItem; + for (; it->More();it->Next()) { + _PTR(SObject) Obj = it->Value(); + if (Obj->FindAttribute(anAttr, "AttributeName")) { + aName = anAttr; + if (Obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = anAttr; + anItem = new ListBoxIOR (myDlg->ListHypDefinition, + anIOR->Value().c_str(), + aName->Value().c_str()); + } + } + } + } +} + +//================================================================================= +// function : initAlgoDefinition +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesOp::initAlgoDefinition() +{ + myDlg->ListAlgoDefinition->clear(); + + _PTR(Study) study = studyDS(); + _PTR(SComponent) father = study->FindComponent("SMESH"); + if (!father) + return; + + _PTR(SObject) AlgorithmsRoot; + _PTR(GenericAttribute) anAttr; + _PTR(AttributeName) aName; + _PTR(AttributeIOR) anIOR; + + if (father->FindSubObject (2, AlgorithmsRoot)) { + _PTR(ChildIterator) it = + study->NewChildIterator(AlgorithmsRoot); + ListBoxIOR* anItem; + for (; it->More();it->Next()) { + _PTR(SObject) Obj = it->Value(); + if (Obj->FindAttribute(anAttr, "AttributeName")) { + aName = anAttr; + if (Obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = anAttr; + anItem = new ListBoxIOR (myDlg->ListAlgoDefinition, + anIOR->Value().c_str(), + aName->Value().c_str()); + } + } + } + } +} + +//================================================================================= +// function : initHypAssignation +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesOp::initHypAssignation() +{ + myDlg->myNbModification = 0; + + myDlg->myMapOldHypos.clear(); + myDlg->ListHypAssignation->clear(); + if (myImportedMesh) + return; + + _PTR(Study) study = studyDS(); + _PTR(SObject) aMorSM, AHR, aRef; + _PTR(GenericAttribute) anAttr; + _PTR(AttributeName) aName; + _PTR(AttributeIOR) anIOR; + + QStringList selMesh; + myDlg->selectedObject( SMESHGUI_EditHypothesesDlg::MeshOrSubMesh, selMesh ); + aMorSM = studyDS()->FindObjectID( selMesh.first() ); + + if (aMorSM && aMorSM->FindSubObject(2, AHR)) { + _PTR(ChildIterator) it = + study->NewChildIterator(AHR); + for (; it->More();it->Next()) { + _PTR(SObject) Obj = it->Value(); + if (Obj->ReferencedObject(aRef)) { + if (aRef->FindAttribute(anAttr, "AttributeName")) { + aName = anAttr; + if (aRef->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = anAttr; + ListBoxIOR* anItem = new ListBoxIOR (myDlg->ListHypAssignation, + anIOR->Value().c_str(), + aName->Value().c_str()); + myDlg->myMapOldHypos[ anIOR->Value() ] = myDlg->ListHypAssignation->index(anItem); + } + } + } + } + } +} + +//================================================================================= +// function : initAlgoAssignation +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesOp::initAlgoAssignation() +{ + myDlg->myMapOldAlgos.clear(); + myDlg->ListAlgoAssignation->clear(); + if (myImportedMesh) + return; + + _PTR(Study) study = studyDS(); + _PTR(SObject) aMorSM, AHR, aRef; + _PTR(GenericAttribute) anAttr; + _PTR(AttributeName) aName; + _PTR(AttributeIOR) anIOR; + + QStringList selMesh; + myDlg->selectedObject( SMESHGUI_EditHypothesesDlg::MeshOrSubMesh, selMesh ); + aMorSM = studyDS()->FindObjectID( selMesh.first() ); + + if (aMorSM && aMorSM->FindSubObject(3, AHR)) { + _PTR(ChildIterator) it = + study->NewChildIterator(AHR); + for (; it->More();it->Next()) { + _PTR(SObject) Obj = it->Value(); + if (Obj->ReferencedObject(aRef)) { + if (aRef->FindAttribute(anAttr, "AttributeName")) { + aName = anAttr; + if (aRef->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = anAttr; + ListBoxIOR* anItem = new ListBoxIOR (myDlg->ListAlgoAssignation, + anIOR->Value().c_str(), + aName->Value().c_str()); + myDlg->myMapOldAlgos[ anIOR->Value() ] = myDlg->ListAlgoAssignation->index(anItem); + } + } + } + } + } +} + +//================================================================================= +// function : createFilter +// purpose : +//================================================================================= +SUIT_SelectionFilter* SMESHGUI_EditHypothesesOp::createFilter( const int id ) const +{ + if( id==SMESHGUI_EditHypothesesDlg::GeomShape ) + { + TColStd_MapOfInteger allTypesMap; + for (int i = 0; i < 10; i++) + allTypesMap.Add(i); + return new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 0, allTypesMap); + } + + else if( id==SMESHGUI_EditHypothesesDlg::MeshOrSubMesh ) + return new SMESH_TypeFilter (MESHorSUBMESH); + + else + return 0; +} + +//================================================================================= +// function : updateDialog +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesOp::updateDialog() +{ + bool isEnabled = myDlg->hasSelection( SMESHGUI_EditHypothesesDlg::MeshOrSubMesh ) && + myDlg->hasSelection( SMESHGUI_EditHypothesesDlg::GeomShape ) && + ( myDlg->hypoCount() || myDlg->algoCount() ); + + myDlg->setButtonEnabled( myDlg->isModified() && isEnabled && !myImportedMesh, QtxDialog::OK | QtxDialog::Apply ); + myDlg->setObjectEnabled( SMESHGUI_EditHypothesesDlg::GeomShape, ALLOW_CHANGE_SHAPE && !myImportedMesh ); + myDlg->setListsEnabled( myDlg->hasSelection( SMESHGUI_EditHypothesesDlg::MeshOrSubMesh ) && !myImportedMesh ); +} + +//================================================================================= +// function : initDialog +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesOp::initDialog() +{ + SMESHGUI_SelectionOp::initDialog(); + + initHypDefinition(); + initAlgoDefinition(); + + updateDialog(); +} + +//================================================================================= +// function : storeMeshOrSubMesh +// purpose : +//================================================================================= +bool SMESHGUI_EditHypothesesOp::storeMeshOrSubMesh() +{ + MapIOR anOldHypos, aNewHypos; + if( !myDlg->hasSelection( SMESHGUI_EditHypothesesDlg::GeomShape ) ) + return false; + + QStringList selMesh, selGeom; + myDlg->selectedObject( SMESHGUI_EditHypothesesDlg::MeshOrSubMesh, selMesh ); + myDlg->selectedObject( SMESHGUI_EditHypothesesDlg::GeomShape, selGeom ); + + // 1. Check whether the geometric shape has changed + _PTR(SObject) SO = studyDS()->FindObjectID( selMesh.first() ); + _PTR(SObject) aGeom = studyDS()->FindObjectID( selGeom.first() ); + + GEOM::GEOM_Object_var aGeomShape = GEOM::GEOM_Object::_narrow( _CAST(SObject,aGeom)->GetObject() ); + + GEOM::GEOM_Object_var aIniGeomShape = SMESH::GetShapeOnMeshOrSubMesh(SO); + bool bShapeChanged = aIniGeomShape->_is_nil() || !aIniGeomShape->_is_equivalent(aGeomShape); + if (bShapeChanged) { + // VSR : TODO : Set new shape - not supported yet by engine + // 1. remove all old hypotheses and algorithms + // 2. set new shape + } + int nbFail = 0; + MapIOR::iterator it; + + // 2. remove not used hypotheses from the submesh + for (it = myDlg->myMapOldHypos.begin(); it != myDlg->myMapOldHypos.end(); ++it) { + QString ior = it.key(); + int index = myDlg->findItem(myDlg->ListHypAssignation, ior); + if (index < 0) { + SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.latin1()); + if (!aHyp->_is_nil()) { + if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh( SO, aHyp)) + nbFail++; + } + } + } + + // 3. remove not used algorithms from the submesh + for (it = myDlg->myMapOldAlgos.begin(); it != myDlg->myMapOldAlgos.end(); ++it) { + QString ior = it.key(); + int index = myDlg->findItem(myDlg->ListAlgoAssignation, ior); + if (index < 0) { + SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.latin1()); + if (!aHyp->_is_nil()){ + if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh( SO, aHyp ) ) + nbFail++; + } + } + } + + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( _CAST(SObject,SO)->GetObject() ); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( _CAST(SObject,SO)->GetObject() ); + + // 4. Add new algorithms + for (int i = 0; i < myDlg->ListAlgoAssignation->count(); i++) { + if (myDlg->ListAlgoAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { + ListBoxIOR* anItem = (ListBoxIOR*)(myDlg->ListAlgoAssignation->item(i)); + if (anItem) { + QString ior = anItem->GetIOR(); + if (myDlg->myMapOldAlgos.find(ior) == myDlg->myMapOldAlgos.end()) { + SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.latin1()); + if (!aHyp->_is_nil()){ + if( !aMesh->_is_nil() && !SMESH::AddHypothesisOnMesh( aMesh, aHyp)) + nbFail++; + if( !aSubMesh->_is_nil() && !SMESH::AddHypothesisOnSubMesh( aSubMesh, aHyp)) + nbFail++; + } + } + } + } + } + + // 5. Add new hypotheses + for (int i = 0; i < myDlg->ListHypAssignation->count(); i++) { + if (myDlg->ListHypAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { + ListBoxIOR* anItem = (ListBoxIOR*)(myDlg->ListHypAssignation->item(i)); + if (anItem) { + QString ior = anItem->GetIOR(); + if (myDlg->myMapOldHypos.find(ior) == myDlg->myMapOldHypos.end()) { + SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.latin1()); + if (!aHyp->_is_nil()){ + if( !aMesh->_is_nil() && !SMESH::AddHypothesisOnMesh( aMesh, aHyp)) + nbFail++; + if( !aSubMesh->_is_nil() && !SMESH::AddHypothesisOnSubMesh( aSubMesh, aHyp)) + nbFail++; + } + } + } + } + } + return (nbFail == 0); +} + +//================================================================================= +// function : onUpdate +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesOp::onUpdate() +{ + updateDialog(); +} diff --git a/src/SMESHGUI/SMESHGUI_EditHypothesesOp.h b/src/SMESHGUI/SMESHGUI_EditHypothesesOp.h new file mode 100644 index 000000000..494dd93a7 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_EditHypothesesOp.h @@ -0,0 +1,77 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_EditHypothesesOp.h +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +#ifndef OPERATION_EDIT_HYPOTHESES_H +#define OPERATION_EDIT_HYPOTHESES_H + +#include + +class SMESHGUI_EditHypothesesDlg; + +//================================================================================= +// class : SMESHGUI_EditHypothesesOp +// purpose : +//================================================================================= +class SMESHGUI_EditHypothesesOp : public SMESHGUI_SelectionOp +{ + Q_OBJECT + +public: + SMESHGUI_EditHypothesesOp(); + ~SMESHGUI_EditHypothesesOp(); + + virtual SalomeApp_Dialog* dlg() const; + virtual void initDialog(); + +protected: + virtual void startOperation(); + virtual void selectionDone(); + virtual SUIT_SelectionFilter* createFilter( const int ) const; + void updateDialog(); + +protected slots: + virtual bool onApply(); + +private slots: + void onSelectionChanged( int ); + void onUpdate(); + +private: + void initGeom(); + void initHypDefinition(); + void initAlgoDefinition(); + void initHypAssignation(); + void initAlgoAssignation(); + bool storeMeshOrSubMesh(); + +private: + SMESHGUI_EditHypothesesDlg *myDlg; + bool myImportedMesh; +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_GroupOp.cxx b/src/SMESHGUI/SMESHGUI_GroupOp.cxx new file mode 100644 index 000000000..ea80945af --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_GroupOp.cxx @@ -0,0 +1,249 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_GroupOp.cxx +// Author : Sergey LITONIN +// Module : SMESH + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include CORBA_SERVER_HEADER(SMESH_Group) + + +/* + Class : SMESHGUI_GroupOp + Description : Perform boolean operations on groups +*/ + +//======================================================================= +// name : SMESHGUI_GroupOp +// Purpose : +//======================================================================= +SMESHGUI_GroupOp::SMESHGUI_GroupOp( const int mode ) +: SMESHGUI_SelectionOp(), + myMode( mode ), + myDlg( 0 ) +{ +} + +//======================================================================= +// name : ~SMESHGUI_GroupOp +// Purpose : +//======================================================================= +SMESHGUI_GroupOp::~SMESHGUI_GroupOp() +{ + if( myDlg ) + delete myDlg; +} + +//======================================================================= +// name : dlg +// Purpose : +//======================================================================= +SalomeApp_Dialog* SMESHGUI_GroupOp::dlg() const +{ + return myDlg; +} + +//======================================================================= +// name : onApply +// Purpose : +//======================================================================= +bool SMESHGUI_GroupOp::onApply() +{ + if( !myDlg || !isValid() || getSMESHGUI()->isActiveStudyLocked() ) + return false; + + QStringList selGroup[2]; + for( int i=1; i<=2; i++ ) + myDlg->selectedObject( i, selGroup[i-1] ); + + _PTR(SObject) pGroup1 = studyDS()->FindObjectID( selGroup[0].first() ), + pGroup2 = studyDS()->FindObjectID( selGroup[1].first() ); + SMESH::SMESH_GroupBase_var aGroup1 = SMESH::SMESH_GroupBase::_narrow( _CAST(SObject,pGroup1)->GetObject() ), + aGroup2 = SMESH::SMESH_GroupBase::_narrow( _CAST(SObject,pGroup2)->GetObject() ); + + SMESH::SMESH_Mesh_ptr aMesh = aGroup1->GetMesh(); + QString aName = myDlg->name(); + SMESH::SMESH_Group_ptr aNewGrp = SMESH::SMESH_Group::_nil(); + + if( myMode == UNION ) + aNewGrp = aMesh->UnionGroups( aGroup1, aGroup2, aName.latin1() ); + + else if( myMode == INTERSECT ) + aNewGrp = aMesh->IntersectGroups( aGroup1, aGroup2, aName.latin1() ); + + else + aNewGrp = aMesh->CutGroups( aGroup1, aGroup2, aName.latin1() ); + + if (!aNewGrp->_is_nil()) + { + update( UF_Model | UF_ObjBrowser ); + initDialog(); + return true; + } + else + { + SUIT_MessageBox::warn1( SMESHGUI::desktop(), tr("SMESH_ERROR"), + tr("SMESH_OPERATION_FAILED"), tr( "SMESH_BUT_OK" ) ); + return false; + } +} + +//======================================================================= +// name : startOperation +// Purpose : +//======================================================================= +void SMESHGUI_GroupOp::startOperation() +{ + if( !myDlg ) + { + myDlg = new SMESHGUI_GroupOpDlg( getSMESHGUI(), myMode ); + connect( myDlg, SIGNAL( nameChanged( const QString& ) ), this, SLOT( onNameChanged( const QString& ) ) ); + } + + SMESHGUI_SelectionOp::startOperation(); + + myDlg->show(); +} + +//======================================================================= +// name : startOperation +// Purpose : +//======================================================================= +SUIT_SelectionFilter* SMESHGUI_GroupOp::createFilter( const int ) const +{ + return new SMESH_TypeFilter( GROUP ); +} + +//======================================================================= +// name : startOperation +// Purpose : +//======================================================================= +void SMESHGUI_GroupOp::initDialog() +{ + SMESHGUI_SelectionOp::initDialog(); + if( myDlg ) + { + myDlg->setName( QString::null ); + updateDialog(); + } +} + +//======================================================================= +// name : updateDialog +// Purpose : +//======================================================================= +void SMESHGUI_GroupOp::selectionDone() +{ + SMESHGUI_SelectionOp::selectionDone(); + updateDialog(); +} + +//======================================================================= +// name : updateDialog +// Purpose : +//======================================================================= +void SMESHGUI_GroupOp::updateDialog() +{ + if( !myDlg ) + return; + + bool isEnabled = !myDlg->name().isEmpty() && myDlg->hasSelection( 1 ) && myDlg->hasSelection( 2 ); + myDlg->setButtonEnabled( isEnabled, QtxDialog::OK | QtxDialog::Apply ); +} + +//======================================================================= +// name : isValid +// Purpose : Verify validity of input data +//======================================================================= +bool SMESHGUI_GroupOp::isValid() const +{ + if( !myDlg ) + return false; + + // Verify validity of group name + if( myDlg->name().isEmpty() ) + { + SUIT_MessageBox::warn1( SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("EMPTY_NAME"), tr( "SMESH_BUT_OK" ) ); + return false; + } + + QStringList selGroup[2]; + for( int i=1; i<=2; i++ ) + myDlg->selectedObject( i, selGroup[i-1] ); + + _PTR(SObject) pGroup1 = studyDS()->FindObjectID( selGroup[0].first() ), + pGroup2 = studyDS()->FindObjectID( selGroup[1].first() ); + SMESH::SMESH_GroupBase_var aGroup1 = SMESH::SMESH_GroupBase::_narrow( _CAST(SObject,pGroup1)->GetObject() ), + aGroup2 = SMESH::SMESH_GroupBase::_narrow( _CAST(SObject,pGroup2)->GetObject() ); + + // Verufy wheter arguments speciffiyed + if( aGroup1->_is_nil() || aGroup2->_is_nil()) + { + SUIT_MessageBox::warn1( SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("INCORRECT_ARGUMENTS"), tr( "SMESH_BUT_OK" ) ); + return false; + } + + // Verify whether arguments belongs to same mesh + SMESH::SMESH_Mesh_ptr aMesh1 = aGroup1->GetMesh(); + SMESH::SMESH_Mesh_ptr aMesh2 = aGroup2->GetMesh(); + + int aMeshId1 = !aMesh1->_is_nil() ? aMesh1->GetId() : -1; + int aMeshId2 = !aMesh2->_is_nil() ? aMesh2->GetId() : -1; + + if (aMeshId1 != aMeshId2 || aMeshId1 == -1) { + SUIT_MessageBox::warn1( SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("DIFF_MESHES"), tr( "SMESH_BUT_OK" ) ); + return false; + } + + // Verify whether groups have same types of entities + if( aGroup1->GetType() != aGroup2->GetType() ) { + SUIT_MessageBox::warn1( SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("DIFF_TYPES"), tr( "SMESH_BUT_OK" ) ); + return false; + } + + return true; +} + +//======================================================================= +// name : onNameChanged +// Purpose : +//======================================================================= +void SMESHGUI_GroupOp::onNameChanged( const QString& ) +{ + updateDialog(); +} diff --git a/src/SMESHGUI/SMESHGUI_GroupOp.h b/src/SMESHGUI/SMESHGUI_GroupOp.h new file mode 100644 index 000000000..aa7fbd503 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_GroupOp.h @@ -0,0 +1,73 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_GroupOp.h +// Author : Sergey LITONIN +// Module : SMESH + + +#ifndef SMESHGUI_GroupOp_H +#define SMESHGUI_GroupOp_H + +#include + +class SMESHGUI_GroupOpDlg; + +/* + Class : SMESHGUI_GroupOp + Description : Perform boolean operations on groups +*/ + +class SMESHGUI_GroupOp : public SMESHGUI_SelectionOp +{ + Q_OBJECT + +public: + enum { UNION, INTERSECT, CUT }; + +public: + SMESHGUI_GroupOp( const int ); + virtual ~SMESHGUI_GroupOp(); + + virtual SalomeApp_Dialog* dlg() const; + +protected: + virtual void startOperation(); + virtual void initDialog(); + virtual void selectionDone(); + + virtual SUIT_SelectionFilter* createFilter( const int ) const; + + bool isValid() const; + void updateDialog(); + +protected slots: + virtual bool onApply(); + +private slots: + void onNameChanged( const QString& ); + +private: + SMESHGUI_GroupOpDlg *myDlg; + int myMode; +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx index 7c15603ed..a88045688 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx @@ -27,30 +27,10 @@ #include "SMESHGUI_GroupOpDlg.h" -#include "SMESHGUI.h" -#include "SMESHGUI_Utils.h" -#include "SMESHGUI_VTKUtils.h" - -#include "SMESH_TypeFilter.hxx" - -#include "SUIT_ResourceMgr.h" -#include "SUIT_Desktop.h" - -#include "SalomeApp_SelectionMgr.h" -#include "SVTK_Selection.h" -#include "SVTK_ViewWindow.h" -#include "SVTK_Selector.h" -#include "SALOME_ListIO.hxx" - -// QT Includes -#include #include -#include #include #include -#include #include -#include #define SPACING 5 #define MARGIN 10 @@ -64,97 +44,35 @@ // name : SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg // Purpose : Constructor //======================================================================= -SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( SMESHGUI* theModule, const int theMode ) - : QDialog( SMESH::GetDesktop( theModule ), "SMESHGUI_GroupOpDlg", false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), - mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myViewWindow( SMESH::GetViewWindow( theModule ) ), - mySelector( myViewWindow->GetSelector() ) +SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( SMESHGUI* theModule, const int aMode ) +: SMESHGUI_Dialog( theModule, false, true ) { - myMode = theMode; - - if (myMode == UNION) setCaption(tr("UNION_OF_TWO_GROUPS")); - else if (myMode == INTERSECT) setCaption(tr("INTERSECTION_OF_TWO_GROUPS")); - else setCaption(tr("CUT_OF_TWO_GROUPS")); - - QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING); - - QFrame* aMainFrame = createMainFrame (this); - QFrame* aBtnFrame = createButtonFrame(this); - - aDlgLay->addWidget(aMainFrame); - aDlgLay->addWidget(aBtnFrame); - - aDlgLay->setStretchFactor(aMainFrame, 1); - - Init(); -} + QString caption; + if( aMode == 0 ) + caption = "UNION_OF_TWO_GROUPS"; + else if( aMode == 1 ) + caption = "INTERSECTION_OF_TWO_GROUPS"; + else + caption = "CUT_OF_TWO_GROUPS"; + + setCaption( tr( caption ) ); -//======================================================================= -// name : SMESHGUI_GroupOpDlg::createMainFrame -// Purpose : Create frame containing dialog's input fields -//======================================================================= -QFrame* SMESHGUI_GroupOpDlg::createMainFrame (QWidget* theParent) -{ - QGroupBox* aMainGrp = new QGroupBox(1, Qt::Horizontal, theParent); - aMainGrp->setFrameStyle(QFrame::NoFrame); - aMainGrp->setInsideMargin(0); + QVBoxLayout* aDlgLay = new QVBoxLayout( mainFrame() ); +// aDlgLay->setMargin( MARGIN ); +// aDlgLay->setSpacing( SPACING ); - QGroupBox* aNameGrp = new QGroupBox(1, Qt::Vertical, tr("NAME"), aMainGrp); + QGroupBox* aNameGrp = new QGroupBox(1, Qt::Vertical, tr("NAME"), mainFrame() ); new QLabel(tr("RESULT_NAME"), aNameGrp); myNameEdit = new QLineEdit(aNameGrp); + connect( myNameEdit, SIGNAL( textChanged( const QString& ) ), this, SIGNAL( nameChanged( const QString& ) ) ); - QGroupBox* anArgGrp = new QGroupBox(3, Qt::Horizontal, tr("ARGUMENTS"), aMainGrp); - - new QLabel(myMode == CUT ? tr("MAIN_OBJECT") :tr("OBJECT_1"), anArgGrp); - myBtn1 = new QPushButton(anArgGrp); - myEdit1 = new QLineEdit(anArgGrp); - myEdit1->setAlignment( Qt::AlignLeft ); - - new QLabel(myMode == CUT ? tr("TOOL_OBJECT") :tr("OBJECT_2"), anArgGrp); - myBtn2 = new QPushButton(anArgGrp); - myEdit2 = new QLineEdit(anArgGrp); - myEdit2->setAlignment( Qt::AlignLeft ); - - myEdit1->setReadOnly(true); - myEdit2->setReadOnly(true); - - QPixmap aPix (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); - myBtn1->setPixmap(aPix); - myBtn2->setPixmap(aPix); - - return aMainGrp; -} - -//======================================================================= -// name : SMESHGUI_GroupOpDlg::createButtonFrame -// Purpose : Create frame containing buttons -//======================================================================= -QFrame* SMESHGUI_GroupOpDlg::createButtonFrame (QWidget* theParent) -{ - QFrame* aFrame = new QFrame(theParent); - aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken); - - myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame); - myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame); - myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame); - - QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); + QGroupBox* anArgGrp = new QGroupBox(3, Qt::Horizontal, tr("ARGUMENTS"), mainFrame() ); - QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING); + createObject( aMode==2 ? tr( "MAIN_OBJECT" ) : tr( "OBJECT_1" ), anArgGrp, 1 ); + createObject( aMode==2 ? tr( "TOOL_OBJECT" ) : tr( "OBJECT_2" ), anArgGrp, 2 ); - aLay->addWidget(myOkBtn); - aLay->addWidget(myApplyBtn); - aLay->addItem(aSpacer); - aLay->addWidget(myCloseBtn); - - // connect signals and slots - connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); - connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); - connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply())); - - return aFrame; + aDlgLay->addWidget( aNameGrp ); + aDlgLay->addWidget( anArgGrp ); } //======================================================================= @@ -166,216 +84,19 @@ SMESHGUI_GroupOpDlg::~SMESHGUI_GroupOpDlg() } //======================================================================= -// name : SMESHGUI_GroupOpDlg::Init -// Purpose : Init dialog fields, connect signals and slots, show dialog -//======================================================================= -void SMESHGUI_GroupOpDlg::Init() -{ - mySMESHGUI->SetActiveDialogBox((QDialog*)this); - myFocusWg = myEdit1; - - myGroup1 = SMESH::SMESH_GroupBase::_nil(); - myGroup2 = SMESH::SMESH_GroupBase::_nil(); - - // selection and SMESHGUI - connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); - connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); - connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(ClickOnClose())); - - connect(myBtn1, SIGNAL(clicked()), this, SLOT(onFocusChanged())); - connect(myBtn2, SIGNAL(clicked()), this, SLOT(onFocusChanged())); - - int x, y; - mySMESHGUI->DefineDlgPosition(this, x, y); - this->move(x, y); - this->show(); - - // set selection mode - myViewWindow->SetSelectionMode(ActorSelection); - mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP)); - - return; -} - -//======================================================================= -// name : SMESHGUI_GroupOpDlg::isValid -// Purpose : Verify validity of input data -//======================================================================= -bool SMESHGUI_GroupOpDlg::isValid() -{ - // Verify validity of group name - if (myNameEdit->text() == "") { - QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), - tr("EMPTY_NAME"), QMessageBox::Ok); - return false; - } - - // Verufy wheter arguments speciffiyed - if (myGroup1->_is_nil() || myGroup2->_is_nil()) { - QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), - tr("INCORRECT_ARGUMENTS"), QMessageBox::Ok); - return false; - } - - // Verify whether arguments belongs to same mesh - SMESH::SMESH_Mesh_ptr aMesh1 = myGroup1->GetMesh(); - SMESH::SMESH_Mesh_ptr aMesh2 = myGroup2->GetMesh(); - - int aMeshId1 = !aMesh1->_is_nil() ? aMesh1->GetId() : -1; - int aMeshId2 = !aMesh2->_is_nil() ? aMesh2->GetId() : -1; - - if (aMeshId1 != aMeshId2 || aMeshId1 == -1) { - QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), - tr("DIFF_MESHES"), QMessageBox::Ok); - return false; - } - - // Verify whether groups have same types of entities - if (myGroup1->GetType() != myGroup2->GetType()) { - QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), - tr("DIFF_TYPES"), QMessageBox::Ok); - return false; - } - - return true; -} - -//======================================================================= -// name : SMESHGUI_GroupOpDlg::onApply -// Purpose : SLOT called when "Apply" button pressed. -//======================================================================= -bool SMESHGUI_GroupOpDlg::onApply() -{ - if (!isValid() || mySMESHGUI->isActiveStudyLocked()) - return false; - - SMESH::SMESH_Mesh_ptr aMesh = myGroup1->GetMesh(); - QString aName = myNameEdit->text(); - SMESH::SMESH_Group_ptr aNewGrp = SMESH::SMESH_Group::_nil(); - - if (myMode == UNION) aNewGrp = aMesh->UnionGroups(myGroup1, myGroup2, aName.latin1()); - else if (myMode == INTERSECT) aNewGrp = aMesh->IntersectGroups(myGroup1, myGroup2, aName.latin1()); - else aNewGrp = aMesh->CutGroups(myGroup1, myGroup2, aName.latin1()); - - if (!aNewGrp->_is_nil()) { - mySMESHGUI->updateObjBrowser(true); - reset(); - return true; - } else { - QMessageBox::critical(SMESHGUI::desktop(), tr("SMESH_ERROR"), - tr("SMESH_OPERATION_FAILED"), "OK"); - return false; - } -} - -//======================================================================= -// name : SMESHGUI_GroupOpDlg::onOk -// Purpose : SLOT called when "Ok" button pressed. -//======================================================================= -void SMESHGUI_GroupOpDlg::onOk() -{ - if (onApply()) - onClose(); -} - -//======================================================================= -// name : SMESHGUI_GroupOpDlg::onClose -// Purpose : SLOT called when "Close" button pressed. Close dialog -//======================================================================= -void SMESHGUI_GroupOpDlg::onClose() -{ - myViewWindow->SetSelectionMode(ActorSelection); - disconnect(mySelectionMgr, 0, this, 0); - disconnect(mySMESHGUI, 0, this, 0); - mySMESHGUI->ResetState(); - mySelectionMgr->clearFilters(); - reject(); -} - -//======================================================================= -// name : SMESHGUI_GroupOpDlg::onSelectionDone -// Purpose : SLOT called when selection changed -//======================================================================= -void SMESHGUI_GroupOpDlg::onSelectionDone() -{ - if (myFocusWg == myEdit1) - myGroup1 = SMESH::SMESH_GroupBase::_nil(); - else - myGroup2 = SMESH::SMESH_GroupBase::_nil(); - - myFocusWg->setText(""); - - SALOME_ListIO aList; - mySelectionMgr->selectedObjects(aList); - - if (aList.Extent() == 1) { - SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface(aList.First()); - - if (!aGroup->_is_nil()) - { - myFocusWg->setText(aGroup->GetName()); - myFocusWg->setCursorPosition( 0 ); - - if (myFocusWg == myEdit1) - myGroup1 = aGroup; - else - myGroup2 = aGroup; - } - } -} - -//======================================================================= -// name : SMESHGUI_GroupOpDlg::onDeactivate -// Purpose : SLOT called when dialog must be deativated -//======================================================================= -void SMESHGUI_GroupOpDlg::onDeactivate() -{ - setEnabled(false); - mySelectionMgr->clearFilters(); -} - -//======================================================================= -// name : SMESHGUI_GroupOpDlg::enterEvent -// Purpose : Event filter -//======================================================================= -void SMESHGUI_GroupOpDlg::enterEvent (QEvent*) -{ - mySMESHGUI->EmitSignalDeactivateDialog(); - setEnabled(true); - myViewWindow->SetSelectionMode(ActorSelection); - mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP)); -} - -//======================================================================= -// name : SMESHGUI_GroupOpDlg::closeEvent -// purpose : -//======================================================================= -void SMESHGUI_GroupOpDlg::closeEvent (QCloseEvent*) -{ - onClose(); -} - -//======================================================================= -// name : SMESHGUI_GroupOpDlg::onFocusChanged -// Purpose : SLOT. Called when "Select" button pressed. +// name : setName +// Purpose : //======================================================================= -void SMESHGUI_GroupOpDlg::onFocusChanged() +void SMESHGUI_GroupOpDlg::setName( const QString& name ) { - const QObject* aSender = sender(); - myFocusWg = aSender == myBtn1 ? myEdit1 : myEdit2; - onSelectionDone(); + myNameEdit->setText( name ); } //======================================================================= -// name : SMESHGUI_GroupOpDlg::reset -// Purpose : Rest state of dialog +// name : name +// Purpose : //======================================================================= -void SMESHGUI_GroupOpDlg::reset() +QString SMESHGUI_GroupOpDlg::name() const { - myNameEdit->setText(""); - myEdit1->setText(""); - myEdit2->setText(""); - myFocusWg = myEdit1; - myNameEdit->setFocus(); + return myNameEdit->text().stripWhiteSpace(); } diff --git a/src/SMESHGUI/SMESHGUI_GroupOpDlg.h b/src/SMESHGUI/SMESHGUI_GroupOpDlg.h index e04b02fde..ad316b1db 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOpDlg.h +++ b/src/SMESHGUI/SMESHGUI_GroupOpDlg.h @@ -27,84 +27,32 @@ #ifndef SMESHGUI_GroupOpDlg_H #define SMESHGUI_GroupOpDlg_H -#include - -#include -#include CORBA_SERVER_HEADER(SMESH_Group) - -class QCloseEvent; -class QLabel; -class QFrame; -class QPushButton; -class SalomeApp_SelectionMgr; -class QLineEdit; -class SMESHGUI; -class SVTK_ViewWindow; -class SVTK_Selector; +#include /* Class : SMESHGUI_GroupOpDlg Description : Perform boolean operations on groups */ -class SMESHGUI_GroupOpDlg : public QDialog +class SMESHGUI; +class QLineEdit; + +class SMESHGUI_GroupOpDlg : public SMESHGUI_Dialog { Q_OBJECT - -public: - enum { UNION, INTERSECT, CUT }; - -public: - SMESHGUI_GroupOpDlg( SMESHGUI*, const int ); - virtual ~SMESHGUI_GroupOpDlg(); - - void Init(); - -private: - - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; - -private slots: - void onOk(); - bool onApply(); - void onClose(); +public: + SMESHGUI_GroupOpDlg( SMESHGUI*, const int ); + virtual ~SMESHGUI_GroupOpDlg(); - void onDeactivate(); - void onSelectionDone(); - void onFocusChanged(); + void setName( const QString& ); + QString name() const; -private: +signals: + void nameChanged( const QString& ); - QFrame* createButtonFrame( QWidget* ); - QFrame* createMainFrame ( QWidget* ); - bool isValid(); - void reset(); - private: - - QPushButton* myOkBtn; - QPushButton* myApplyBtn; - QPushButton* myCloseBtn; - QLineEdit* myNameEdit; - QLineEdit* myEdit1; - QLineEdit* myEdit2; - QPushButton* myBtn1; - QPushButton* myBtn2; - - SMESHGUI* mySMESHGUI; - SalomeApp_SelectionMgr* mySelectionMgr; - int myMode; - SVTK_ViewWindow* myViewWindow; - SVTK_Selector* mySelector; - - QLineEdit* myFocusWg; - - SMESH::SMESH_GroupBase_var myGroup1; - SMESH::SMESH_GroupBase_var myGroup2; - }; #endif diff --git a/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx index c70984a64..7dfa03ab9 100644 --- a/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx @@ -60,6 +60,7 @@ SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg( SMESHGUI* theModule ) new QLabel(tr("SMESH_NAME"), GroupC1, "TextLabel_NameMesh"); GroupC1->addSpace(1); myMeshName = new QLineEdit(GroupC1, "LineEdit_NameMesh"); + connect( myMeshName, SIGNAL( textChanged( const QString& ) ), this, SIGNAL( nameChanged( const QString& ) ) ); createObject( tr("SMESH_OBJECT_GEOM"), GroupC1, GeomObj ); createObject( tr("SMESH_OBJECT_HYPOTHESIS"), GroupC1, Hypo ); @@ -83,17 +84,6 @@ SMESHGUI_InitMeshDlg::~SMESHGUI_InitMeshDlg() // no need to delete child widgets, Qt does it all for us } -//================================================================================= -// function : updateControlState -// purpose : -//================================================================================= -void SMESHGUI_InitMeshDlg::updateControlState() -{ - bool isEnabled = !meshName().isEmpty() && - hasSelection( GeomObj ) && hasSelection( Hypo ) && hasSelection( Algo ); - setButtonEnabled( isEnabled, OK | Apply ); -} - //================================================================================= // function : meshName // purpose : diff --git a/src/SMESHGUI/SMESHGUI_InitMeshDlg.h b/src/SMESHGUI/SMESHGUI_InitMeshDlg.h index 32ceba56e..c60f18c23 100644 --- a/src/SMESHGUI/SMESHGUI_InitMeshDlg.h +++ b/src/SMESHGUI/SMESHGUI_InitMeshDlg.h @@ -46,11 +46,12 @@ public: SMESHGUI_InitMeshDlg( SMESHGUI* ); ~SMESHGUI_InitMeshDlg(); - void updateControlState(); - void setMeshName( const QString& ); QString meshName() const; +signals: + void nameChanged( const QString& ); + private: QLineEdit* myMeshName; diff --git a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx index 47e8f82c2..097a0dda5 100644 --- a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx @@ -27,264 +27,44 @@ // $Header$ #include "SMESHGUI_NodesDlg.h" +#include +#include -#include "SMESHGUI.h" -#include "SMESHGUI_SpinBox.h" -#include "SMESHGUI_Utils.h" -#include "SMESHGUI_VTKUtils.h" -#include "SMESHGUI_MeshUtils.h" +#include -#include "SMESH_Actor.h" -#include "SMESH_ActorUtils.h" -#include "SMESH_ObjectDef.h" - -#include "SMDS_Mesh.hxx" -#include "SMDS_MeshNode.hxx" - -#include "SUIT_Session.h" -#include "SUIT_OverrideCursor.h" -#include "SUIT_ViewWindow.h" -#include "SUIT_ViewManager.h" -#include "SUIT_MessageBox.h" -#include "SUIT_Desktop.h" - -#include "SalomeApp_Study.h" -#include "SalomeApp_SelectionMgr.h" - -#include "SVTK_Selector.h" -#include "SVTK_ViewWindow.h" - -#include "SALOME_Actor.h" -#include "SALOME_ListIO.hxx" - -#include "utilities.h" - -// VTK Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// QT Includes +#include #include -#include -#include #include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - - -namespace SMESH { - - void AddNode (SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z) - { - SUIT_OverrideCursor wc; - try { - _PTR(SObject) aSobj = SMESH::FindSObject(theMesh); - SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor(); - aMeshEditor->AddNode(x,y,z); - _PTR(Study) aStudy = GetActiveStudyDocument(); - CORBA::Long anId = aStudy->StudyId(); - if (TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId, aSobj->GetID().c_str())) { - aVisualObj->Update(true); - } - } catch (SALOME::SALOME_Exception& exc) { - INFOS("Follow exception was cought:\n\t" << exc.details.text); - } catch (const std::exception& exc) { - INFOS("Follow exception was cought:\n\t" << exc.what()); - } catch (...) { - INFOS("Unknown exception was cought !!!"); - } - } - - class TNodeSimulation { - SVTK_ViewWindow* myViewWindow; - - SALOME_Actor *myPreviewActor; - vtkDataSetMapper* myMapper; - vtkPoints* myPoints; - - public: - TNodeSimulation(SVTK_ViewWindow* theViewWindow): - myViewWindow(theViewWindow) - { - vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New(); - - // Create points - myPoints = vtkPoints::New(); - myPoints->SetNumberOfPoints(1); - myPoints->SetPoint(0,0.0,0.0,0.0); - - // Create cells - vtkIdList *anIdList = vtkIdList::New(); - anIdList->SetNumberOfIds(1); - - vtkCellArray *aCells = vtkCellArray::New(); - aCells->Allocate(2, 0); - - vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); - aCellTypesArray->SetNumberOfComponents(1); - aCellTypesArray->Allocate(1); - - anIdList->SetId(0, 0); - aCells->InsertNextCell(anIdList); - aCellTypesArray->InsertNextValue(VTK_VERTEX); - - vtkIntArray* aCellLocationsArray = vtkIntArray::New(); - aCellLocationsArray->SetNumberOfComponents(1); - aCellLocationsArray->SetNumberOfTuples(1); - - aCells->InitTraversal(); - vtkIdType npts; - aCellLocationsArray->SetValue(0, aCells->GetTraversalLocation(npts)); - - aGrid->SetCells(aCellTypesArray, aCellLocationsArray, aCells); - - aGrid->SetPoints(myPoints); - aGrid->SetCells(aCellTypesArray, aCellLocationsArray,aCells); - aCellLocationsArray->Delete(); - aCellTypesArray->Delete(); - aCells->Delete(); - anIdList->Delete(); - - // Create and display actor - myMapper = vtkDataSetMapper::New(); - myMapper->SetInput(aGrid); - aGrid->Delete(); - - myPreviewActor = SALOME_Actor::New(); - myPreviewActor->SetInfinitive(true); - myPreviewActor->VisibilityOff(); - myPreviewActor->PickableOff(); - myPreviewActor->SetMapper(myMapper); - - vtkProperty* aProp = vtkProperty::New(); - aProp->SetRepresentationToPoints(); - - float anRGB[3]; - GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) ); - aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] ); - - float aPointSize = GetFloat( "SMESH:node_size", 3 ); - aProp->SetPointSize( aPointSize ); - - myPreviewActor->SetProperty( aProp ); - aProp->Delete(); - - myViewWindow->AddActor(myPreviewActor); - } - - void SetPosition (float x, float y, float z) - { - myPoints->SetPoint(0,x,y,z); - myPoints->Modified(); - SetVisibility(true); - } - - void SetVisibility (bool theVisibility) - { - myPreviewActor->SetVisibility(theVisibility); - RepaintCurrentView(); - } - - ~TNodeSimulation() - { - myViewWindow->RemoveActor(myPreviewActor); - myPreviewActor->Delete(); - - myMapper->RemoveAllInputs(); - myMapper->Delete(); - - myPoints->Delete(); - } - }; -} //================================================================================= // class : SMESHGUI_NodesDlg() // purpose : //================================================================================= -SMESHGUI_NodesDlg::SMESHGUI_NodesDlg (SMESHGUI* theModule, - const char* name, - bool modal, - WFlags fl): - QDialog(SMESH::GetDesktop(theModule), - name, - modal, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), - mySelector(SMESH::GetViewWindow(theModule)->GetSelector()), - mySelectionMgr(SMESH::GetSelectionMgr(theModule)), - myViewWindow(SMESH::GetViewWindow(theModule)), - mySMESHGUI(theModule) +SMESHGUI_NodesDlg::SMESHGUI_NodesDlg( SMESHGUI* theModule ) +: SMESHGUI_Dialog( theModule, false, false, OK | Apply | Close ) { - mySimulation = new SMESH::TNodeSimulation(myViewWindow); - - QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_NODE"))); - if (!name) - setName("SMESHGUI_NodesDlg"); + QPixmap image0( resMgr()->loadPixmap("SMESH", tr("ICON_DLG_NODE"))); + setName("SMESHGUI_NodesDlg"); resize(303, 185); setCaption(tr("MESH_NODE_TITLE")); setSizeGripEnabled(TRUE); - SMESHGUI_NodesDlgLayout = new QGridLayout(this); - SMESHGUI_NodesDlgLayout->setSpacing(6); - SMESHGUI_NodesDlgLayout->setMargin(11); - - /***************************************************************/ - GroupButtons = new QGroupBox(this, "GroupButtons"); - GroupButtons->setGeometry(QRect(10, 10, 281, 48)); - GroupButtons->setTitle(tr("" )); - GroupButtons->setColumnLayout(0, Qt::Vertical); - GroupButtons->layout()->setSpacing(0); - GroupButtons->layout()->setMargin(0); - GroupButtonsLayout = new QGridLayout(GroupButtons->layout()); - GroupButtonsLayout->setAlignment(Qt::AlignTop); - GroupButtonsLayout->setSpacing(6); - GroupButtonsLayout->setMargin(11); - buttonCancel = new QPushButton(GroupButtons, "buttonCancel"); - buttonCancel->setText(tr("SMESH_BUT_CLOSE" )); - buttonCancel->setAutoDefault(TRUE); - GroupButtonsLayout->addWidget(buttonCancel, 0, 3); - buttonApply = new QPushButton(GroupButtons, "buttonApply"); - buttonApply->setText(tr("SMESH_BUT_APPLY" )); - buttonApply->setAutoDefault(TRUE); - GroupButtonsLayout->addWidget(buttonApply, 0, 1); - QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - GroupButtonsLayout->addItem(spacer_9, 0, 2); - buttonOk = new QPushButton(GroupButtons, "buttonOk"); - buttonOk->setText(tr("SMESH_BUT_OK" )); - buttonOk->setAutoDefault(TRUE); - buttonOk->setDefault(TRUE); - GroupButtonsLayout->addWidget(buttonOk, 0, 0); - SMESHGUI_NodesDlgLayout->addWidget(GroupButtons, 2, 0); + QGridLayout* SMESHGUI_NodesDlgLayout = new QGridLayout(mainFrame()); + SMESHGUI_NodesDlgLayout->setSpacing(0); + SMESHGUI_NodesDlgLayout->setMargin(0); /***************************************************************/ - GroupConstructors = new QButtonGroup(this, "GroupConstructors"); + QButtonGroup* GroupConstructors = new QButtonGroup(mainFrame(), "GroupConstructors"); GroupConstructors->setTitle(tr("MESH_NODE" )); GroupConstructors->setExclusive(TRUE); GroupConstructors->setColumnLayout(0, Qt::Vertical); GroupConstructors->layout()->setSpacing(0); GroupConstructors->layout()->setMargin(0); - GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); + QGridLayout* GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout()); GroupConstructorsLayout->setAlignment(Qt::AlignTop); GroupConstructorsLayout->setSpacing(6); GroupConstructorsLayout->setMargin(11); - Constructor1 = new QRadioButton(GroupConstructors, "Constructor1"); + QRadioButton* Constructor1 = new QRadioButton(GroupConstructors, "Constructor1"); Constructor1->setText(tr("" )); Constructor1->setPixmap(image0); Constructor1->setChecked(TRUE); @@ -294,23 +74,23 @@ SMESHGUI_NodesDlg::SMESHGUI_NodesDlg (SMESHGUI* theModule, SMESHGUI_NodesDlgLayout->addWidget(GroupConstructors, 0, 0); /***************************************************************/ - GroupCoordinates = new QGroupBox(this, "GroupCoordinates"); + QGroupBox* GroupCoordinates = new QGroupBox(mainFrame(), "GroupCoordinates"); GroupCoordinates->setTitle(tr("SMESH_COORDINATES" )); GroupCoordinates->setColumnLayout(0, Qt::Vertical); GroupCoordinates->layout()->setSpacing(0); GroupCoordinates->layout()->setMargin(0); - GroupCoordinatesLayout = new QGridLayout(GroupCoordinates->layout()); + QGridLayout* GroupCoordinatesLayout = new QGridLayout(GroupCoordinates->layout()); GroupCoordinatesLayout->setAlignment(Qt::AlignTop); GroupCoordinatesLayout->setSpacing(6); GroupCoordinatesLayout->setMargin(11); - TextLabel_X = new QLabel(GroupCoordinates, "TextLabel_X"); + QLabel* TextLabel_X = new QLabel(GroupCoordinates, "TextLabel_X"); TextLabel_X->setText(tr("SMESH_X" )); GroupCoordinatesLayout->addWidget(TextLabel_X, 0, 0); - TextLabel_Y = new QLabel(GroupCoordinates, "TextLabel_Y"); + QLabel* TextLabel_Y = new QLabel(GroupCoordinates, "TextLabel_Y"); TextLabel_Y->setText(tr("SMESH_Y" )); GroupCoordinatesLayout->addWidget(TextLabel_Y, 0, 2); - TextLabel_Z = new QLabel(GroupCoordinates, "TextLabel_Z"); + QLabel* TextLabel_Z = new QLabel(GroupCoordinates, "TextLabel_Z"); TextLabel_Z->setText(tr("SMESH_Z" )); GroupCoordinatesLayout->addWidget(TextLabel_Z, 0, 4); @@ -323,10 +103,15 @@ SMESHGUI_NodesDlg::SMESHGUI_NodesDlg (SMESHGUI* theModule, SpinBox_Z = new SMESHGUI_SpinBox(GroupCoordinates, "SpinBox_Z"); GroupCoordinatesLayout->addWidget(SpinBox_Z, 0, 5); + SpinBox_X->RangeStepAndValidator(-999.999, +999.999, 25.0, 3); + SpinBox_Y->RangeStepAndValidator(-999.999, +999.999, 25.0, 3); + SpinBox_Z->RangeStepAndValidator(-999.999, +999.999, 25.0, 3); + + connect(SpinBox_X, SIGNAL(valueChanged(double)), this, SIGNAL(valueChanged(double))); + connect(SpinBox_Y, SIGNAL(valueChanged(double)), this, SIGNAL(valueChanged(double))); + connect(SpinBox_Z, SIGNAL(valueChanged(double)), this, SIGNAL(valueChanged(double))); + SMESHGUI_NodesDlgLayout->addWidget(GroupCoordinates, 1, 0); - - /* Initialisation and display */ - Init(); } //======================================================================= @@ -335,243 +120,29 @@ SMESHGUI_NodesDlg::SMESHGUI_NodesDlg (SMESHGUI* theModule, //======================================================================= SMESHGUI_NodesDlg::~SMESHGUI_NodesDlg() { - delete mySimulation; -} - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void SMESHGUI_NodesDlg::Init () -{ - /* Get setting of step value from file configuration */ - double step; - // QString St = SUIT_CONFIG->getSetting("xxxxxxxxxxxxx"); TODO - // step = St.toDouble(); TODO - step = 25.0; - - /* min, max, step and decimals for spin boxes */ - SpinBox_X->RangeStepAndValidator(-999.999, +999.999, step, 3); - SpinBox_Y->RangeStepAndValidator(-999.999, +999.999, step, 3); - SpinBox_Z->RangeStepAndValidator(-999.999, +999.999, step, 3); - SpinBox_X->SetValue(0.0); - SpinBox_Y->SetValue(0.0); - SpinBox_Z->SetValue(0.0); - - mySMESHGUI->SetActiveDialogBox((QDialog*)this); - - /* signals and slots connections */ - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - - connect(SpinBox_X, SIGNAL (valueChanged(double)), SLOT(ValueChangedInSpinBox(double))); - connect(SpinBox_Y, SIGNAL (valueChanged(double)), SLOT(ValueChangedInSpinBox(double))); - connect(SpinBox_Z, SIGNAL (valueChanged(double)), SLOT(ValueChangedInSpinBox(double))); - - connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument())); - connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog())); - /* to close dialog if study frame change */ - connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(ClickOnCancel())); - - /* Move widget on the botton right corner of main widget */ - int x, y; - mySMESHGUI->DefineDlgPosition(this, x, y); - this->move(x, y); - this->show(); - - // set selection mode - SMESH::SetPointRepresentation(true); - myViewWindow->SetSelectionMode(NodeSelection); - - SelectionIntoArgument(); -} - -//================================================================================= -// function : ValueChangedInSpinBox() -// purpose : -//================================================================================= -void SMESHGUI_NodesDlg::ValueChangedInSpinBox (double newValue) -{ - if (!myMesh->_is_nil()) { - double vx = SpinBox_X->GetValue(); - double vy = SpinBox_Y->GetValue(); - double vz = SpinBox_Z->GetValue(); - - mySimulation->SetPosition(vx,vy,vz); - } -} - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void SMESHGUI_NodesDlg::ClickOnOk() -{ - if (ClickOnApply()) - ClickOnCancel(); -} - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -bool SMESHGUI_NodesDlg::ClickOnApply() -{ - if (mySMESHGUI->isActiveStudyLocked()) - return false; - - if (myMesh->_is_nil()) { - SUIT_MessageBox::warn1(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"), - tr("MESH_IS_NOT_SELECTED"), tr("SMESH_BUT_OK")); - return false; - } - - /* Recup args and call method */ - double x = SpinBox_X->GetValue(); - double y = SpinBox_Y->GetValue(); - double z = SpinBox_Z->GetValue(); - mySimulation->SetVisibility(false); - SMESH::AddNode(myMesh,x,y,z); - SMESH::SetPointRepresentation(true); - - // select myMesh - SALOME_ListIO aList; - mySelectionMgr->selectedObjects(aList); - if (aList.Extent() != 1) { - if (SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView()) { - vtkActorCollection *aCollection = aViewWindow->getRenderer()->GetActors(); - aCollection->InitTraversal(); - while (vtkActor *anAct = aCollection->GetNextActor()) { - if (SMESH_Actor *anActor = dynamic_cast(anAct)) { - if (anActor->hasIO()) { - if (SMESH_MeshObj *aMeshObj = dynamic_cast(anActor->GetObject().get())) { - if (myMesh->_is_equivalent(aMeshObj->GetMeshServer())) { - aList.Clear(); - aList.Append(anActor->getIO()); - mySelectionMgr->setSelectedObjects(aList, false); - break; - } - } - } - } - } - } - } - return true; -} - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void SMESHGUI_NodesDlg::ClickOnCancel() -{ - disconnect(mySelectionMgr, 0, this, 0); - myViewWindow->SetSelectionMode(ActorSelection); - - mySimulation->SetVisibility(false); - SMESH::SetPointRepresentation(false); - mySMESHGUI->ResetState(); - - reject(); -} - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= -void SMESHGUI_NodesDlg::SelectionIntoArgument() -{ - if (!GroupConstructors->isEnabled()) - return; - - mySimulation->SetVisibility(false); - SMESH::SetPointRepresentation(true); - - const SALOME_ListIO& aList = mySelector->StoredIObjects(); - if (aList.Extent() == 1) { - Handle(SALOME_InteractiveObject) anIO = aList.First(); - if (anIO->hasEntry()) { - myMesh = SMESH::GetMeshByIO(anIO); - if (myMesh->_is_nil()) return; - QString aText; - if (SMESH::GetNameOfSelectedNodes(mySelector,anIO,aText) == 1) { - if (SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh.in())) { - if (SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh()) { - if (const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) { - SpinBox_X->SetValue(aNode->X()); - SpinBox_Y->SetValue(aNode->Y()); - SpinBox_Z->SetValue(aNode->Z()); - } - } - } - } - mySimulation->SetPosition(SpinBox_X->GetValue(), - SpinBox_Y->GetValue(), - SpinBox_Z->GetValue()); - } - } -} - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_NodesDlg::closeEvent (QCloseEvent*) -{ - this->ClickOnCancel(); /* same than click on cancel button */ -} - -//================================================================================= -// function : hideEvent() -// purpose : caused by ESC key -//================================================================================= -void SMESHGUI_NodesDlg::hideEvent (QHideEvent*) -{ - if (!isMinimized()) - ClickOnCancel(); } -//================================================================================= -// function : enterEvent() -// purpose : to reactivate this dialog box when mouse enter onto the window -//================================================================================= -void SMESHGUI_NodesDlg::enterEvent(QEvent*) -{ - if (!GroupConstructors->isEnabled()) - ActivateThisDialog(); -} - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : public slot to deactivate if active -//================================================================================= -void SMESHGUI_NodesDlg::DeactivateActiveDialog() +//======================================================================= +// function : coords() +// purpose : +//======================================================================= +void SMESHGUI_NodesDlg::coords( double& x, double& y, double& z ) const { - if (GroupConstructors->isEnabled()) { - GroupConstructors->setEnabled(false); - GroupCoordinates->setEnabled(false); - GroupButtons->setEnabled(false); - mySimulation->SetVisibility(false); - mySMESHGUI->ResetState(); - mySMESHGUI->SetActiveDialogBox(0); - } + x = SpinBox_X->value(); + y = SpinBox_Y->value(); + z = SpinBox_Z->value(); } -//================================================================================= -// function : ActivateThisDialog() +//======================================================================= +// function : setCoords() // purpose : -//================================================================================= -void SMESHGUI_NodesDlg::ActivateThisDialog() +//======================================================================= +void SMESHGUI_NodesDlg::setCoords( const double x, const double y, const double z ) { - mySMESHGUI->EmitSignalDeactivateDialog(); - GroupConstructors->setEnabled(true); - GroupCoordinates->setEnabled(true); - GroupButtons->setEnabled(true); - - SMESH::SetPointRepresentation(true); - myViewWindow->SetSelectionMode(NodeSelection); - - SelectionIntoArgument(); + SpinBox_X->setValue( x ); + SpinBox_Y->setValue( y ); + SpinBox_Z->setValue( z ); + SpinBox_X->clearFocus(); + SpinBox_Y->clearFocus(); + SpinBox_Z->clearFocus(); } diff --git a/src/SMESHGUI/SMESHGUI_NodesDlg.h b/src/SMESHGUI/SMESHGUI_NodesDlg.h index 0a64f964f..41843db0f 100644 --- a/src/SMESHGUI/SMESHGUI_NodesDlg.h +++ b/src/SMESHGUI/SMESHGUI_NodesDlg.h @@ -29,95 +29,32 @@ #ifndef DIALOGBOX_NODES_H #define DIALOGBOX_NODES_H -#include -#include +#include -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QFrame; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QRadioButton; - -class SMESHGUI; -class SVTK_Selector; -class SVTK_ViewWindow; class SMESHGUI_SpinBox; -class SalomeApp_SelectionMgr; - -namespace SMESH{ - struct TNodeSimulation; -} - -// IDL Headers -#include -#include CORBA_SERVER_HEADER(SMESH_Mesh) //================================================================================= // class : SMESHGUI_NodesDlg // purpose : //================================================================================= -class SMESHGUI_NodesDlg : public QDialog +class SMESHGUI_NodesDlg : public SMESHGUI_Dialog { Q_OBJECT public: - SMESHGUI_NodesDlg (SMESHGUI* theModule, - const char* name = 0, - bool modal = FALSE, - WFlags fl = 0); - + SMESHGUI_NodesDlg( SMESHGUI* ); ~SMESHGUI_NodesDlg(); -private: - SalomeApp_SelectionMgr* mySelectionMgr; - SVTK_ViewWindow* myViewWindow; - SVTK_Selector* mySelector; - SMESHGUI* mySMESHGUI; - - SMESH::SMESH_Mesh_var myMesh; - SMESH::TNodeSimulation* mySimulation; - - void Init (); - void enterEvent(QEvent* e); - void closeEvent(QCloseEvent*); - void hideEvent (QHideEvent *); /* ESC key */ + void coords( double&, double&, double& ) const; + void setCoords( const double, const double, const double ); + +signals: + void valueChanged( double ); - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - QGroupBox* GroupCoordinates; +private: SMESHGUI_SpinBox* SpinBox_X; SMESHGUI_SpinBox* SpinBox_Y; SMESHGUI_SpinBox* SpinBox_Z; - - QLabel* TextLabel_X; - QLabel* TextLabel_Y; - QLabel* TextLabel_Z; - - QGroupBox* GroupButtons; - QPushButton* buttonApply; - QPushButton* buttonOk; - QPushButton* buttonCancel; - -private slots: - - void ClickOnOk(); - void ClickOnCancel(); - bool ClickOnApply(); - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - void SelectionIntoArgument() ; - void ValueChangedInSpinBox( double newValue ) ; - -protected: - QGridLayout* SMESHGUI_NodesDlgLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupCoordinatesLayout; - QGridLayout* GroupButtonsLayout; }; #endif // DIALOGBOX_NODES_H diff --git a/src/SMESHGUI/SMESHGUI_NodesOp.cxx b/src/SMESHGUI/SMESHGUI_NodesOp.cxx new file mode 100644 index 000000000..4e0ff14f2 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_NodesOp.cxx @@ -0,0 +1,366 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_NodesOp.cxx +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +#include "SMESHGUI_NodesOp.h" +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +#include +#include + +#include +#include + +#include +#include + +#include "utilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace SMESH { + + void AddNode (SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z) + { + SUIT_OverrideCursor wc; + try { + _PTR(SObject) aSobj = SMESH::FindSObject(theMesh); + SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor(); + aMeshEditor->AddNode(x,y,z); + _PTR(Study) aStudy = GetActiveStudyDocument(); + CORBA::Long anId = aStudy->StudyId(); + if (TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId, aSobj->GetID().c_str())) { + aVisualObj->Update(true); + } + } catch (SALOME::SALOME_Exception& exc) { + INFOS("Follow exception was cought:\n\t" << exc.details.text); + } catch (const std::exception& exc) { + INFOS("Follow exception was cought:\n\t" << exc.what()); + } catch (...) { + INFOS("Unknown exception was cought !!!"); + } + } + + class TNodeSimulation { + SVTK_ViewWindow* myViewWindow; + + SALOME_Actor *myPreviewActor; + vtkDataSetMapper* myMapper; + vtkPoints* myPoints; + + public: + TNodeSimulation(SVTK_ViewWindow* theViewWindow): + myViewWindow(theViewWindow) + { + vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New(); + + // Create points + myPoints = vtkPoints::New(); + myPoints->SetNumberOfPoints(1); + myPoints->SetPoint(0,0.0,0.0,0.0); + + // Create cells + vtkIdList *anIdList = vtkIdList::New(); + anIdList->SetNumberOfIds(1); + + vtkCellArray *aCells = vtkCellArray::New(); + aCells->Allocate(2, 0); + + vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); + aCellTypesArray->SetNumberOfComponents(1); + aCellTypesArray->Allocate(1); + + anIdList->SetId(0, 0); + aCells->InsertNextCell(anIdList); + aCellTypesArray->InsertNextValue(VTK_VERTEX); + + vtkIntArray* aCellLocationsArray = vtkIntArray::New(); + aCellLocationsArray->SetNumberOfComponents(1); + aCellLocationsArray->SetNumberOfTuples(1); + + aCells->InitTraversal(); + vtkIdType npts; + aCellLocationsArray->SetValue(0, aCells->GetTraversalLocation(npts)); + + aGrid->SetCells(aCellTypesArray, aCellLocationsArray, aCells); + + aGrid->SetPoints(myPoints); + aGrid->SetCells(aCellTypesArray, aCellLocationsArray,aCells); + aCellLocationsArray->Delete(); + aCellTypesArray->Delete(); + aCells->Delete(); + anIdList->Delete(); + + // Create and display actor + myMapper = vtkDataSetMapper::New(); + myMapper->SetInput(aGrid); + aGrid->Delete(); + + myPreviewActor = SALOME_Actor::New(); + myPreviewActor->SetInfinitive(true); + myPreviewActor->VisibilityOff(); + myPreviewActor->PickableOff(); + myPreviewActor->SetMapper(myMapper); + + vtkProperty* aProp = vtkProperty::New(); + aProp->SetRepresentationToPoints(); + + float anRGB[3]; + GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) ); + aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] ); + + float aPointSize = GetFloat( "SMESH:node_size", 3 ); + aProp->SetPointSize( aPointSize ); + + myPreviewActor->SetProperty( aProp ); + aProp->Delete(); + + myViewWindow->AddActor(myPreviewActor); + } + + void SetPosition (float x, float y, float z) + { + myPoints->SetPoint(0,x,y,z); + myPoints->Modified(); + SetVisibility(true); + } + + void SetVisibility (bool theVisibility) + { + myPreviewActor->SetVisibility(theVisibility); + RepaintCurrentView(); + } + + ~TNodeSimulation() + { + SetVisibility( false ); + myViewWindow->RemoveActor(myPreviewActor); + myPreviewActor->Delete(); + + myMapper->RemoveAllInputs(); + myMapper->Delete(); + + myPoints->Delete(); + } + }; +} + + +//================================================================================= +// function : +// purpose : +//================================================================================= +SMESHGUI_NodesOp::SMESHGUI_NodesOp() +: SMESHGUI_SelectionOp( NodeSelection ), + myDlg( 0 ), + mySimulation( 0 ) +{ +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +SMESHGUI_NodesOp::~SMESHGUI_NodesOp() +{ + if( myDlg ) + delete myDlg; +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +SalomeApp_Dialog* SMESHGUI_NodesOp::dlg() const +{ + return myDlg; +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +void SMESHGUI_NodesOp::startOperation() +{ + if( !myDlg ) + { + myDlg = new SMESHGUI_NodesDlg( getSMESHGUI() ); + connect( myDlg, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged( double ) ) ); + connect( myDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) ); + } + + SMESHGUI_SelectionOp::startOperation(); + + mySimulation = new SMESH::TNodeSimulation( viewWindow() ); + myDlg->show(); +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +void SMESHGUI_NodesOp::commitOperation() +{ + delete mySimulation; + mySimulation = 0; + SMESHGUI_SelectionOp::commitOperation(); +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +void SMESHGUI_NodesOp::abortOperation() +{ + delete mySimulation; + mySimulation = 0; + SMESHGUI_SelectionOp::abortOperation(); +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +void SMESHGUI_NodesOp::selectionDone() +{ + if( !mySimulation ) + return; + + mySimulation->SetVisibility(false); + SMESH::SetPointRepresentation(true); + + const SALOME_ListIO& aList = selector()->StoredIObjects(); + if (aList.Extent() == 1) { + Handle(SALOME_InteractiveObject) anIO = aList.First(); + if (anIO->hasEntry()) { + myMesh = SMESH::GetMeshByIO(anIO); + if (myMesh->_is_nil()) return; + QString aText; + if (SMESH::GetNameOfSelectedNodes(selector(),anIO,aText) == 1) { + if (SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh.in())) { + if (SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh()) { + if (const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) { + myDlg->setCoords( aNode->X(), aNode->Y(), aNode->Z() ); + } + } + } + } + double x, y, z; + myDlg->coords( x, y, z ); + mySimulation->SetPosition( x, y, z ); + } + } +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +void SMESHGUI_NodesOp::initDialog() +{ + myDlg->setCoords( 0, 0, 0 ); +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +bool SMESHGUI_NodesOp::onApply() +{ + if( getSMESHGUI()->isActiveStudyLocked() || !mySimulation ) + return false; + + if (myMesh->_is_nil()) { + SUIT_MessageBox::warn1( myDlg, tr("SMESH_WRN_WARNING"), + tr("MESH_IS_NOT_SELECTED"), tr("SMESH_BUT_OK")); + return false; + } + + double x, y, z; myDlg->coords( x, y, z ); + mySimulation->SetVisibility(false); + SMESH::AddNode(myMesh,x,y,z); + SMESH::SetPointRepresentation(true); + + // select myMesh + SALOME_ListIO aList; + selectionMgr()->selectedObjects(aList); + if (aList.Extent() != 1) { + if (SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView()) { + vtkActorCollection *aCollection = aViewWindow->getRenderer()->GetActors(); + aCollection->InitTraversal(); + while (vtkActor *anAct = aCollection->GetNextActor()) { + if (SMESH_Actor *anActor = dynamic_cast(anAct)) { + if (anActor->hasIO()) { + if (SMESH_MeshObj *aMeshObj = dynamic_cast(anActor->GetObject().get())) { + if (myMesh->_is_equivalent(aMeshObj->GetMeshServer())) { + aList.Clear(); + aList.Append(anActor->getIO()); + selectionMgr()->setSelectedObjects(aList, false); + break; + } + } + } + } + } + } + } + return true; +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +void SMESHGUI_NodesOp::onValueChanged( double ) +{ + double vx, vy, vz; myDlg->coords( vx, vy, vz ); + if( mySimulation ) + mySimulation->SetPosition( vx, vy, vz ); +} + + + diff --git a/src/SMESHGUI/SMESHGUI_NodesOp.h b/src/SMESHGUI/SMESHGUI_NodesOp.h new file mode 100644 index 000000000..bf3dfb602 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_NodesOp.h @@ -0,0 +1,79 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_NodesOp.h +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +#ifndef OPERATION_NODES_H +#define OPERATION_NODES_H + +namespace SMESH{ + struct TNodeSimulation; +} + +#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +class SMESHGUI_NodesDlg; + + +//================================================================================= +// class : SMESHGUI_NodesOp +// purpose : +//================================================================================= +class SMESHGUI_NodesOp : public SMESHGUI_SelectionOp +{ + Q_OBJECT + +public: + SMESHGUI_NodesOp(); + ~SMESHGUI_NodesOp(); + + virtual SalomeApp_Dialog* dlg() const; + +protected: + virtual void startOperation(); + virtual void selectionDone(); + virtual void commitOperation(); + virtual void abortOperation(); + + void initDialog(); + +protected slots: + virtual bool onApply(); + +private slots: + void onValueChanged( double ); + +private: + SMESH::SMESH_Mesh_var myMesh; + SMESH::TNodeSimulation* mySimulation; + SMESHGUI_NodesDlg* myDlg; +}; + +#endif // DIALOGBOX_NODES_H diff --git a/src/SMESHGUI/SMESHGUI_Operation.cxx b/src/SMESHGUI/SMESHGUI_Operation.cxx index 256a7aee8..9a98634f1 100755 --- a/src/SMESHGUI/SMESHGUI_Operation.cxx +++ b/src/SMESHGUI/SMESHGUI_Operation.cxx @@ -40,9 +40,25 @@ SMESHGUI_Operation::SMESHGUI_Operation() { } +//======================================================================= +// name : ~SMESHGUI_Operation +// Purpose : Destructor +//======================================================================= SMESHGUI_Operation::~SMESHGUI_Operation() { - +} + +//======================================================================= +// name : selectionMode +// Purpose : Returns selection mode +//======================================================================= +Selection_Mode SMESHGUI_Operation::selectionMode() const +{ + SVTK_ViewWindow* wnd = viewWindow(); + if( wnd ) + return wnd->SelectionMode(); + else + return ActorSelection; } //======================================================================= @@ -129,7 +145,9 @@ void SMESHGUI_Operation::startOperation() if( dlg()->testButtonFlags( QtxDialog::Cancel ) ) connect( dlg(), SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) ); - } + + initDialog(); + } SalomeApp_Operation::startOperation(); } @@ -332,21 +350,9 @@ void SMESHGUI_Operation::onCancel() } //======================================================================= -// name : commitOperation -// Purpose : -//======================================================================= -void SMESHGUI_Operation::commitOperation() -{ - selectionMgr()->clearFilters(); - SalomeApp_Operation::commitOperation(); -} - -//======================================================================= -// name : abortOperation +// name : initDialog // Purpose : //======================================================================= -void SMESHGUI_Operation::abortOperation() +void SMESHGUI_Operation::initDialog() { - selectionMgr()->clearFilters(); - SalomeApp_Operation::abortOperation(); } diff --git a/src/SMESHGUI/SMESHGUI_Operation.h b/src/SMESHGUI/SMESHGUI_Operation.h index 110357b33..68542417a 100755 --- a/src/SMESHGUI/SMESHGUI_Operation.h +++ b/src/SMESHGUI/SMESHGUI_Operation.h @@ -51,15 +51,17 @@ protected: } SelectedObjectType; protected: + Selection_Mode selectionMode() const; void setSelectionMode( const Selection_Mode ); void highlight( const Handle( SALOME_InteractiveObject )&, const bool, const bool = true ); void addOrRemoveIndex( const Handle( SALOME_InteractiveObject )&, const TColStd_MapOfInteger&, const bool ); + //! sets the dialog widgets to state just after operation start + virtual void initDialog(); + virtual void startOperation(); - virtual void commitOperation(); - virtual void abortOperation(); virtual bool isReadyToStart(); SMESHGUI* getSMESHGUI() const; diff --git a/src/SMESHGUI/SMESHGUI_SelectionOp.cxx b/src/SMESHGUI/SMESHGUI_SelectionOp.cxx new file mode 100644 index 000000000..4a497c68b --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_SelectionOp.cxx @@ -0,0 +1,192 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_SelectionOp.cxx +// Author : Alexander SOLOVYOV +// Module : SMESH + +#include +#include +#include + +/* + Class : SMESHGUI_SelectionOp + Description : Base operation for all operations using object selection in viewer or objectbrowser + through common widgets created by SalomeApp_Dialog::createObject +*/ + +//================================================================================= +// name : SMESHGUI_SelectionOp +// purpose : +//================================================================================= +SMESHGUI_SelectionOp::SMESHGUI_SelectionOp( const Selection_Mode mode ) +: SMESHGUI_Operation(), + myDefSelectionMode( mode ) +{ +} + +//================================================================================= +// name : ~SMESHGUI_SelectionOp +// purpose : +//================================================================================= +SMESHGUI_SelectionOp::~SMESHGUI_SelectionOp() +{ + Filters::const_iterator anIt = myFilters.begin(), + aLast = myFilters.end(); + for( ; anIt!=aLast; anIt++ ) + if( anIt.data() ) + delete anIt.data(); +} + +//================================================================================= +// name : startOperation +// purpose : +//================================================================================= +void SMESHGUI_SelectionOp::startOperation() +{ + SMESHGUI_Operation::startOperation(); + if( dlg() ) + { + disconnect( dlg(), SIGNAL( objectActivated( int ) ), this, SLOT( onActivateObject( int ) ) ); + disconnect( dlg(), SIGNAL( objectDeactivated( int ) ), this, SLOT( onDeactivateObject( int ) ) ); + disconnect( dlg(), SIGNAL( selectionChanged( int ) ), this, SLOT( onSelectionChanged( int ) ) ); + connect( dlg(), SIGNAL( objectActivated( int ) ), this, SLOT( onActivateObject( int ) ) ); + connect( dlg(), SIGNAL( objectDeactivated( int ) ), this, SLOT( onDeactivateObject( int ) ) ); + connect( dlg(), SIGNAL( selectionChanged( int ) ), this, SLOT( onSelectionChanged( int ) ) ); + } + + myOldSelectionMode = selectionMode(); + setSelectionMode( myDefSelectionMode ); +} + +//================================================================================= +// name : removeCustomFilters +// purpose : +//================================================================================= +void SMESHGUI_SelectionOp::removeCustomFilters() const +{ + SalomeApp_SelectionMgr* mgr = selectionMgr(); + if( !mgr ) + return; + + Filters::const_iterator anIt = myFilters.begin(), + aLast = myFilters.end(); + for( ; anIt!=aLast; anIt++ ) + if( anIt.data() ) + mgr->removeFilter( anIt.data() ); +} + +//================================================================================= +// name : commitOperation +// purpose : +//================================================================================= +void SMESHGUI_SelectionOp::commitOperation() +{ + removeCustomFilters(); + setSelectionMode( myOldSelectionMode ); + SMESHGUI_Operation::commitOperation(); +} + +//================================================================================= +// name : abortOperation +// purpose : +//================================================================================= +void SMESHGUI_SelectionOp::abortOperation() +{ + removeCustomFilters(); + setSelectionMode( myOldSelectionMode ); + SMESHGUI_Operation::abortOperation(); +} + +//================================================================================= +// name : selectionDone +// purpose : +//================================================================================= +void SMESHGUI_SelectionOp::selectionDone() +{ + if( !dlg() ) + return; + + QStringList names, ids; + SalomeApp_Dialog::TypesList types; + selected( names, types, ids ); + dlg()->selectObject( names, types, ids ); +} + +//================================================================================= +// name : createFilter +// purpose : +//================================================================================= +SUIT_SelectionFilter* SMESHGUI_SelectionOp::createFilter( const int ) const +{ + return 0; +} + +//================================================================================= +// name : onActivateObject +// purpose : +//================================================================================= +void SMESHGUI_SelectionOp::onActivateObject( int id ) +{ + SalomeApp_SelectionMgr* mgr = selectionMgr(); + if( !mgr ) + return; + + if( !myFilters.contains( id ) ) + myFilters[ id ] = createFilter( id ); + + if( myFilters[ id ] ) + mgr->installFilter( myFilters[ id ] ); + + selectionDone(); +} + +//================================================================================= +// name : onDeactivateObject +// purpose : +//================================================================================= +void SMESHGUI_SelectionOp::onDeactivateObject( int id ) +{ + SalomeApp_SelectionMgr* mgr = selectionMgr(); + if( mgr && myFilters.contains( id ) && myFilters[ id ] ) + mgr->removeFilter( myFilters[ id ] ); +} + +//================================================================================= +// name : initDialog +// purpose : +//================================================================================= +void SMESHGUI_SelectionOp::initDialog() +{ + if( dlg() ) + { + dlg()->clearSelection(); + dlg()->deactivateAll(); + } +} + +//================================================================================= +// name : initDialog +// purpose : +//================================================================================= +void SMESHGUI_SelectionOp::onSelectionChanged( int ) +{ +} diff --git a/src/SMESHGUI/SMESHGUI_SelectionOp.h b/src/SMESHGUI/SMESHGUI_SelectionOp.h new file mode 100644 index 000000000..0f9893f37 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_SelectionOp.h @@ -0,0 +1,88 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_SelectionOp.h +// Author : Alexander SOLOVYOV +// Module : SMESH + + +#ifndef SMESHGUI_SelectionOp_H +#define SMESHGUI_SelectionOp_H + +#include + +/* + Class : SMESHGUI_SelectionOp + Description : Base operation for all operations using object selection in viewer or objectbrowser + through common widgets created by SalomeApp_Dialog::createObject +*/ + +class SUIT_SelectionFilter; + +class SMESHGUI_SelectionOp : public SMESHGUI_Operation +{ + Q_OBJECT + +public: + SMESHGUI_SelectionOp( const Selection_Mode = ActorSelection ); + virtual ~SMESHGUI_SelectionOp(); + +protected: + virtual void startOperation(); + virtual void commitOperation(); + virtual void abortOperation(); + + virtual void selectionDone(); + + //! sets the dialog widgets to state just after operation start + virtual void initDialog(); + + /*! Creates filter being used when certain object selection widget is active + * If no filter must be used, then function must return 0 + * if id is negative, then function must return filter for common using independently of active widget + */ + virtual SUIT_SelectionFilter* createFilter( const int ) const; + + //! Remove only filters set by this operation (they are in map myFilters ) + void removeCustomFilters() const; + +protected slots: + //! Installs filter corresponding to certain object selection widget + virtual void onActivateObject( int ); + + //! Removes filter corresponding to certain object selection widget + virtual void onDeactivateObject( int ); + + /*! + * Empty default implementation. In successors it may be used for more advanced selection checking. + * This slot is connected to signal when the selection changed in some object selection widget + */ + virtual void onSelectionChanged( int ); + +private: + typedef QMap Filters; + +private: + Filters myFilters; + Selection_Mode myDefSelectionMode, myOldSelectionMode; +}; + +#endif