From b4bd6fd51fafac649ab992a43f8a20336dca81da Mon Sep 17 00:00:00 2001 From: enk Date: Wed, 18 Oct 2006 12:23:31 +0000 Subject: [PATCH] Replace sclarmap to prsmerger --- src/VISUGUI/VisuGUI.cxx | 26 +-- src/VISUGUI/VisuGUI_PopupTools.cxx | 2 +- src/VISUGUI/VisuGUI_ScalarBarDlg.cxx | 220 ++++++++++++++++++++++++++ src/VISUGUI/VisuGUI_ScalarBarDlg.h | 53 ++++++- src/VISUGUI/VisuGUI_TimeAnimation.cxx | 6 +- src/VISUGUI/VisuGUI_Tools.cxx | 2 +- 6 files changed, 289 insertions(+), 20 deletions(-) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index aadd869d..c25658a0 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -107,7 +107,7 @@ #include "VisuGUI_BuildProgressDlg.h" #include "VisuGUI_TransparencyDlg.h" -#include "VISU_ScalarMap_i.hh" +#include "VISU_PrsMerger_i.hh" #include "VisuGUI_ScalarBarDlg.h" #include "VISU_DeformedShape_i.hh" @@ -545,7 +545,7 @@ void VisuGUI:: OnCreateScalarMap() { - CreatePrs3d(this); + CreatePrs3d(this); } @@ -751,7 +751,7 @@ OnEditScalarMap() { Handle(SALOME_InteractiveObject) anIO; if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) - EditPrs3d(this, anIO, aPrs3d); + EditPrs3d(this, anIO, aPrs3d); } void @@ -1743,10 +1743,10 @@ OnCopyPresentation() aSameMesh->SameAs(aMeshPrs); } break; - case VISU::TSCALARMAP: + case VISU::TPRSMERGER: { - VISU::ScalarMap_i* aScalarPrs = dynamic_cast(aPrsObject); - VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true); + VISU::PrsMerger_i* aScalarPrs = dynamic_cast(aPrsObject); + VISU::PrsMerger_i* aSameScalar = new VISU::PrsMerger_i(aScalarPrs->GetResult(),true); aSameScalar->SameAs(aScalarPrs); } break; @@ -2473,7 +2473,7 @@ createPopupMenus() // Rules - QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' " + QString aPrsAll ("'VISU::TPRSMERGER' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' " "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'"); // VISU root commands @@ -2536,13 +2536,13 @@ createPopupMenus() // 3D presentations commands QString aPrsType = " and $type in {'VISU::TMESH' " + aPrsAll + "}"; - QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}"; + QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TPRSMERGER' 'VISU::TDEFORMEDSHAPE'}"; QString aSurfFrameType = " and $type in {'VISU::TMESH'}"; - QString aSurfType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' " + QString aSurfType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TPRSMERGER' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' " " 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}"; - QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' " + QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TPRSMERGER' 'VISU::TISOSURFACE' " "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}"; - QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' " + QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TPRSMERGER' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' " "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE' }"; aRule = "selcount=1"; @@ -2596,7 +2596,7 @@ createPopupMenus() mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true ); mgr->setRule( action( VISU_EDIT_SCALARMAP ), - "selcount=1 and type='VISU::TSCALARMAP'", true ); + "selcount=1 and type='VISU::TPRSMERGER'", true ); mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPE ), "selcount=1 and type='VISU::TDEFORMEDSHAPE'", true ); mgr->setRule( action( VISU_EDIT_SCALARMAPONDEFORMEDSHAPE ), @@ -2633,6 +2633,8 @@ createPopupMenus() aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}"; mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true ); mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true ); + mgr->setRule( action( VISU_EDIT_PLOT3D ), + "selcount=1 and type='VISU::TPLOT3D'", true ); //aRule = "client='ObjectBrowser' and type='MEDFIELD'"; //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true ); diff --git a/src/VISUGUI/VisuGUI_PopupTools.cxx b/src/VISUGUI/VisuGUI_PopupTools.cxx index 45d034d9..a434301a 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.cxx +++ b/src/VISUGUI/VisuGUI_PopupTools.cxx @@ -93,7 +93,7 @@ QString VisuGUI_Selection::type( const int ind ) const ENUM2STRING( aResStr, VISU::TCURVE ); ENUM2STRING( aResStr, VISU::TCONTAINER ); ENUM2STRING( aResStr, VISU::TMESH ); - ENUM2STRING( aResStr, VISU::TSCALARMAP ); + ENUM2STRING( aResStr, VISU::TPRSMERGER ); ENUM2STRING( aResStr, VISU::TISOSURFACE ); ENUM2STRING( aResStr, VISU::TDEFORMEDSHAPE ); ENUM2STRING( aResStr, VISU::TSCALARMAPONDEFORMEDSHAPE ); diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index 45e47f88..51a7ce4c 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -41,6 +41,7 @@ #include "VISU_ScalarMapPL.hxx" #include "VISU_ScalarMap_i.hh" #include "VISU_ScalarMapAct.h" +#include "VISU_Result_i.hh" #include "LightApp_Application.h" @@ -55,6 +56,7 @@ #include +using namespace VISU; using namespace std; @@ -1082,6 +1084,9 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool Se TopLayout->setSpacing(6); TopLayout->setMargin(11); + myGroupPane = new VisuGUI_GroupSelectPane(this); + TopLayout->addWidget(myGroupPane); + myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref); TopLayout->addWidget(myScalarPane); @@ -1116,6 +1121,25 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool Se connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) ); } +/*! + Set values in the dialog from the presentation +*/ +void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::PrsMerger_i* thePrs) +{ + myScalarPane->initFromPrsObject(thePrs); + myGroupPane->initFromPrsObject(thePrs); +} + +/*! + Set values to presentation from the dialog +*/ +int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::PrsMerger_i* thePrs) +{ + bool res1 = myScalarPane->storeToPrsObject(thePrs); + bool res2 = myGroupPane->storeToPrsObject(thePrs); + return (res1&&res2); +} + /*! Called when button is clicked, validates data and closes dialog */ @@ -1297,3 +1321,199 @@ void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e ) onHelp(); } } + +/*! + Constructor +*/ +VisuGUI_GroupSelectPane::VisuGUI_GroupSelectPane(QWidget * parent): + QVBox(parent) +{ + // Main groupbox + myMainGroupBox = new QGroupBox(tr(""), this, "myMainGroupBox"); + myMainGroupBox->setColumnLayout(0, Qt::Vertical ); + myMainGroupBox->layout()->setSpacing( 0 ); + myMainGroupBox->layout()->setMargin( 0 ); + QGridLayout* aMainGroupBoxLayout = new QGridLayout( myMainGroupBox->layout() ); + myMainGroupBox->setAlignment( Qt::AlignTop ); + aMainGroupBoxLayout->setSpacing( 6 ); + aMainGroupBoxLayout->setMargin( 11 ); + + myOnGroupsCB = new QCheckBox (tr("PRS_ON_GROUPS"), myMainGroupBox); + myOnGroupsCB->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + // Lists of groups and add/remove buttons + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + QPixmap addImage ( aResourceMgr->loadPixmap("VISU", tr("ICON_ADD"))); + QPixmap removeImage ( aResourceMgr->loadPixmap("VISU", tr("ICON_REMOVE"))); + + myAllGroups = new VisuGUI_ListBox(myMainGroupBox, "myAllGroups"); + myAllGroups->setSelectionMode(QListBox::Extended); + + myAddButton = new QToolButton(myMainGroupBox); + myAddButton->setPixmap( addImage ); + + myRemoveButton = new QToolButton(myMainGroupBox); + myRemoveButton->setPixmap( removeImage ); + + mySelectedGroups = new VisuGUI_ListBox(myMainGroupBox, "mySelectedGroups"); + mySelectedGroups->setSelectionMode(QListBox::Extended); + + // Layouting + QVBoxLayout* buttonsLayout = new QVBoxLayout(); + buttonsLayout->addWidget(myAddButton); + buttonsLayout->addSpacing(6); + buttonsLayout->addWidget(myRemoveButton); + buttonsLayout->addStretch(); + + aMainGroupBoxLayout->addMultiCellWidget( myOnGroupsCB, 0, 0, 0, 2); + aMainGroupBoxLayout->addWidget( myAllGroups, 1, 0 ); + aMainGroupBoxLayout->addLayout( buttonsLayout, 1, 1 ); + aMainGroupBoxLayout->addWidget( mySelectedGroups, 1, 2 ); + aMainGroupBoxLayout->setRowStretch(1, 10); + + // Connections + + connect( myOnGroupsCB, SIGNAL( toggled( bool ) ), this, SLOT( onTypeChanged() ) ); + connect( myAllGroups, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onListDoubleClicked( QListBoxItem* ) ) ); + connect( mySelectedGroups, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onListDoubleClicked( QListBoxItem* ) ) ); + connect( myAddButton, SIGNAL(clicked()), this, SLOT(onAdd())); + connect( myRemoveButton, SIGNAL(clicked()), this, SLOT(onRemove())); + + mySelectedGroups->installEventFilter(this); + + onTypeChanged(); +} + +/*! + Called when the checkbox is toggled +*/ +void VisuGUI_GroupSelectPane::onTypeChanged( ) +{ + bool toEnable = myOnGroupsCB->isChecked(); + if (!toEnable) + { + myAllGroups->clearSelection(); + mySelectedGroups->clearSelection(); + } + myAllGroups->setEnabled( toEnable ); + mySelectedGroups->setEnabled( toEnable ); + myAddButton->setEnabled( toEnable ); + myRemoveButton->setEnabled( toEnable ); +} + +/*! + Initialise the pane from presentation object + */ +void VisuGUI_GroupSelectPane::initFromPrsObject(VISU::PrsMerger_i* thePrs) +{ + VISU::Result_i* theResult = thePrs->GetResult(); + VISU_Convertor* aInput = theResult->GetInput(); + + const VISU::TMeshMap& aMeshMap = aInput->GetMeshMap(); + + VISU::TMeshMap::const_iterator aMeshIter = aMeshMap.find(thePrs->GetMeshName()); + if(aMeshIter!=aMeshMap.end()){ + const PMesh& aMesh = aMeshIter->second; + const TGroupMap& aGroupMap = aMesh->myGroupMap; + TGroupMap::const_iterator aGroupIter = aGroupMap.begin(); + for(;aGroupIter!=aGroupMap.end();aGroupIter++) + { + const string& aGroupName = aGroupIter->first; + myAllGroups->insertItem( QString(aGroupName) ); + } + } + + if (myAllGroups->count() < 1) + { + myAllGroups->insertItem( tr("NO_GROUPS") ); + myMainGroupBox->setEnabled(false); + } + else + { + // Get names of the groups + string_array_var aGroupNames = thePrs->getGroupNames(); + for(int i=0; ilength(); i++) + mySelectedGroups->insertItem( QString(aGroupNames[i]) ); + + if (mySelectedGroups->count() > 0) + myOnGroupsCB->setChecked(true); + } +} + +/*! + Store values to presentation object + */ +int VisuGUI_GroupSelectPane::storeToPrsObject(VISU::PrsMerger_i* thePrs) +{ + thePrs->RemoveAllGeom(); + + if (myOnGroupsCB->isChecked()) + { + QString aMeshName = thePrs->GetMeshName(); + for (int i = 0; i < mySelectedGroups->count(); i++) + thePrs->AddMeshOnGroup( aMeshName , mySelectedGroups->text(i) ); + } + + return 1; +} + +/*! + Called when add button is clicked, adds item to choosen groups +*/ +void VisuGUI_GroupSelectPane::onAdd() +{ + QStringList aList; + + for (int i = 0; i < myAllGroups->count(); i++) + if (myAllGroups->isSelected(i)) + aList.append(myAllGroups->text(i)); + + for (int i = 0; i < mySelectedGroups->count(); i++) + aList.remove(mySelectedGroups->text(i)); + + mySelectedGroups->insertStringList(aList); +} + +/*! + Called when remove button is clicked, remove selected items from choosen +*/ +void VisuGUI_GroupSelectPane::onRemove() +{ + QPtrList aList; + aList.setAutoDelete(false); + for (int i = 0; i < mySelectedGroups->count(); i++) + if (mySelectedGroups->isSelected(i)) + aList.append(mySelectedGroups->item(i)); + + for (int i = 0; i < aList.count(); i++) + delete aList.at(i); +} + +/*! + Called when an item of listbox is double-clicked +*/ +void VisuGUI_GroupSelectPane::onListDoubleClicked( QListBoxItem* theItem ) +{ + QListBox* aListBox = theItem->listBox(); + + if (aListBox == myAllGroups) + { + if (!mySelectedGroups->findItem( theItem->text(), Qt::ExactMatch )) + mySelectedGroups->insertItem(theItem->text()); + } + else if (aListBox == mySelectedGroups) + delete theItem; +} + +/*! + Event filter +*/ +bool VisuGUI_GroupSelectPane::eventFilter (QObject* object, QEvent* event) +{ + if (event->type() == QEvent::KeyPress) { + QKeyEvent* aKeyEvent = (QKeyEvent*)event; + if (object == mySelectedGroups && aKeyEvent->key() == Key_Delete) + onRemove(); + } + return QObject::eventFilter(object, event); +} diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.h b/src/VISUGUI/VisuGUI_ScalarBarDlg.h index d9d0f6f2..513e7b0a 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.h +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.h @@ -43,8 +43,10 @@ #include #include "QtxDblSpinBox.h" +#include "QtxListBox.h" #include "VISU_ScalarMap_i.hh" +#include "VISU_PrsMerger_i.hh" class QButtonGroup; class QGroupBox; @@ -58,7 +60,7 @@ class QComboBox; class QVBox; class QToolButton; -class QtxDblSpinBox; +class QListBoxItem; class SalomeApp_Module; class SVTK_FontWidget; class VISU_ScalarMapAct; @@ -190,6 +192,50 @@ class VisuGUI_ScalarBarPane : public QVBox }; +class VisuGUI_ListBox: public QtxListBox +{ + Q_OBJECT; + + public: + VisuGUI_ListBox( QWidget * parent = 0, const char * name = 0, WFlags f = 0 ) + : QtxListBox(parent, name, f) {}; + ~VisuGUI_ListBox() {}; + + virtual QSize sizeHint() const { return minimumSizeHint(); }; +}; + +class VisuGUI_GroupSelectPane : public QVBox +{ + Q_OBJECT; + + public: + VisuGUI_GroupSelectPane(QWidget* parent); + ~VisuGUI_GroupSelectPane() {}; + + void initFromPrsObject(VISU::PrsMerger_i* thePrs); + int storeToPrsObject(VISU::PrsMerger_i* thePrs); + + bool eventFilter (QObject* object, QEvent* event); + + private slots: + void onTypeChanged(); + void onListDoubleClicked( QListBoxItem* theItem ); + void onAdd(); + void onRemove(); + + private: + QGroupBox* myMainGroupBox; + + QCheckBox* myOnGroupsCB; + + VisuGUI_ListBox* myAllGroups; + VisuGUI_ListBox* mySelectedGroups; + + QToolButton* myAddButton; + QToolButton* myRemoveButton; +}; + + class VisuGUI_ScalarBarDlg : public QDialog { Q_OBJECT; @@ -203,8 +249,8 @@ class VisuGUI_ScalarBarDlg : public QDialog void initFromResources() {myScalarPane->initFromResources();} void storeToResources() {myScalarPane->storeToResources();} - void initFromPrsObject(VISU::ScalarMap_i* thePrs) {myScalarPane->initFromPrsObject(thePrs);} - int storeToPrsObject(VISU::ScalarMap_i* thePrs) {return myScalarPane->storeToPrsObject(thePrs);} + void initFromPrsObject(VISU::PrsMerger_i* thePrs); + int storeToPrsObject(VISU::PrsMerger_i* thePrs); private: void keyPressEvent( QKeyEvent* e ); @@ -216,6 +262,7 @@ class VisuGUI_ScalarBarDlg : public QDialog protected: VisuGUI_ScalarBarPane* myScalarPane; + VisuGUI_GroupSelectPane* myGroupPane; }; #endif // VISUGUI_SCALARBARDLG_H diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 91d6fd39..46e66c08 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -649,7 +649,7 @@ void SetupDlg::onFieldChange (int theIndex) } switch (aData.myPrsType) { - case VISU::TSCALARMAP: //Scalar Map + case VISU::TPRSMERGER: //Scalar Map myTypeCombo->setCurrentItem(myTypeId2ComboId[TSCALARMAP_ITEM]); break; case VISU::TISOSURFACE: //Iso Surfaces @@ -690,7 +690,7 @@ void SetupDlg::onTypeChanged (int theIndex) int aType = myComboId2TypeId[theIndex]; switch (aType) { case TSCALARMAP_ITEM: //Scalar Map - aData.myPrsType = VISU::TSCALARMAP; + aData.myPrsType = VISU::TPRSMERGER; break; case TISOSURFACE_ITEM: //Iso Surfaces aData.myPrsType = VISU::TISOSURFACE; @@ -764,7 +764,7 @@ void SetupDlg::onPreferencesDlg() switch (aType) { case TSCALARMAP_ITEM: //Scalar Map c.suspend(); - EditPrs(myModule,aData); + EditPrs(myModule,aData); break; case TISOSURFACE_ITEM: //Iso Surfaces c.suspend(); diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 1ffbc399..763de11a 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -1156,7 +1156,7 @@ namespace VISU if (!CORBA::is_nil(aVisuObj)) { VISU::VISUType aType = aVisuObj->GetType(); switch (aType) { - case VISU::TSCALARMAP: + case VISU::TPRSMERGER: case VISU::TISOSURFACE: case VISU::TDEFORMEDSHAPE: case VISU::TCUTPLANES: -- 2.39.2