From: apo Date: Fri, 27 Apr 2007 15:14:38 +0000 (+0000) Subject: Debug the PrsMerger functionality X-Git-Tag: mergeto_BR_Dev_For_4_0_21May07~34 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=339ffbfdccc6b9b01d38c15fff323a196edea914;p=modules%2Fvisu.git Debug the PrsMerger functionality --- diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index 14068d04..085eb2f8 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -90,11 +90,55 @@ VISU_ScalarMapPL //---------------------------------------------------------------------------- void VISU_ScalarMapPL +::DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput) +{ + Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); + if(this != thePipeLine){ + if(VISU_ScalarMapPL *aPipeLine = dynamic_cast(thePipeLine)){ + if(aPipeLine->IsExternalGeometryUsed()){ + ClearGeometry(); + int aNbOfGeometry = aPipeLine->GetNumberOfGeometry(); + for(int aGeomNumber = 0; aGeomNumber < aNbOfGeometry; aGeomNumber++) + AddGeometry(aPipeLine->GetGeometry(aGeomNumber)); + }else + SetSourceGeometry(); + } + } +} + + +//---------------------------------------------------------------------------- +void +VISU_ScalarMapPL +::SetSourceGeometry() +{ + if(IsExternalGeometryUsed()){ + ClearGeometry(); + myAppendFilter->AddInput(Superclass::InsertCustomPL()); + } +} + + +//---------------------------------------------------------------------------- +int +VISU_ScalarMapPL ::AddGeometry(vtkDataSet* theGeometry) { myAppendFilter->AddInput(theGeometry); + return GetNumberOfGeometry(); } + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_ScalarMapPL +::GetGeometry(int theGeomNumber) +{ + return vtkDataSet::SafeDownCast(myAppendFilter->GetInput(theGeomNumber)); +} + + //---------------------------------------------------------------------------- int VISU_ScalarMapPL @@ -103,6 +147,17 @@ VISU_ScalarMapPL return myAppendFilter->GetNumberOfInputConnections(0); } + +//---------------------------------------------------------------------------- +bool +VISU_ScalarMapPL +::IsExternalGeometryUsed() +{ + vtkDataObject* aDataObject = myAppendFilter->GetInput(); + return aDataObject && aDataObject != Superclass::InsertCustomPL(); +} + + //---------------------------------------------------------------------------- void VISU_ScalarMapPL @@ -111,6 +166,7 @@ VISU_ScalarMapPL myAppendFilter->RemoveAllInputs(); } + //---------------------------------------------------------------------------- vtkDataSet* VISU_ScalarMapPL diff --git a/src/PIPELINE/VISU_ScalarMapPL.hxx b/src/PIPELINE/VISU_ScalarMapPL.hxx index de035fba..01c6ab66 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.hxx +++ b/src/PIPELINE/VISU_ScalarMapPL.hxx @@ -50,12 +50,23 @@ public: virtual void + SetSourceGeometry(); + + virtual + int AddGeometry(vtkDataSet* theGeometry); + virtual + vtkDataSet* + GetGeometry(int theGeomNumber); + virtual int GetNumberOfGeometry(); + bool + IsExternalGeometryUsed(); + virtual void ClearGeometry(); @@ -80,6 +91,11 @@ protected: void Build(); + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput); + private: vtkSmartPointer myAppendFilter; vtkSmartPointer myMergeFilter; diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index ac0d608f..0b492744 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -120,9 +120,6 @@ msgstr "Height:" msgid "VISU_PREF_SECOND_TAB" msgstr "Scalar range, Sweep, MED import, Shading" -msgid "PRS_ON_GROUPS" -msgstr "Build presentation on groups" - msgid "NO_GROUPS" msgstr "No groups in the mesh" @@ -763,8 +760,11 @@ msgstr "Z :" #: VisuGUI_InputPane.cxx +msgid "VisuGUI_InputPane::PRS_DATA_SOUIRCE" +msgstr "Data Source" + msgid "VisuGUI_InputPane::MED_FILE" -msgstr "Med File :" +msgstr "Source File :" msgid "VisuGUI_InputPane::MESH" msgstr "Mesh :" @@ -779,8 +779,10 @@ msgid "VisuGUI_InputPane::TIME_STAMP" msgstr "Time Stamp :" msgid "VisuGUI_InputPane::REINITIALIZE" -msgstr "Reinitialize" +msgstr "Auto Update" +msgid "PRS_ON_GROUPS" +msgstr "Use Only Groups" #: VisuGUI_ScalarBarDlg.cxx diff --git a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx index eaa5a418..898b62a3 100644 --- a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx @@ -325,27 +325,18 @@ void VisuGUI_CutLinesDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, bool if( !theInit ) return; - if( myPrsCopy->IsTimeStampFixed() ) - myTabBox->removePage( myInputPane ); - else - { - myInputPane->initFromPrsObject( myPrsCopy ); - myTabBox->showPage( myInputPane ); - } + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->setCurrentPage( 0 ); } //------------------------------------------------------------------------------ int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) { - myScalarPane->storeToPrsObject(myPrsCopy); - - if( !myPrsCopy->IsTimeStampFixed() ) - { - if( !myInputPane->check() ) - return 0; - myInputPane->storeToPrsObject( myPrsCopy ); - } + if(!myInputPane->check() || !myScalarPane->check()) + return 0; + + int anIsOk = myInputPane->storeToPrsObject( myPrsCopy ); + anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy ); myPrsCopy->SetOrientation(getOrientaion(), myRotXSpn->value()*PI/180., @@ -372,7 +363,7 @@ int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); - return 1; + return anIsOk; } //------------------------------------------------------------------------------ diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx index 22ae148d..d332917b 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx @@ -546,32 +546,22 @@ void VisuGUI_CutPlanesDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, bool myScalarPane->initFromPrsObject(myPrsCopy); myCutPane->initFromPrsObject(myPrsCopy); - if( myPrsCopy->IsTimeStampFixed() ) - myTabBox->removePage( myInputPane ); - else - { - myInputPane->initFromPrsObject( myPrsCopy ); - myTabBox->showPage( myInputPane ); - } + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->setCurrentPage( 0 ); } int VisuGUI_CutPlanesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) { - int ok = 1; - if( !myPrsCopy->IsTimeStampFixed() ) - { - if( !myInputPane->check() ) - return 0; - - ok = myInputPane->storeToPrsObject(myPrsCopy); - } + if(!myInputPane->check() || !myScalarPane->check()) + return 0; - ok = ok && myScalarPane->storeToPrsObject(myPrsCopy) && myCutPane->storeToPrsObject(myPrsCopy); + int anIsOk = myInputPane->storeToPrsObject(myPrsCopy); + anIsOk &= myScalarPane->storeToPrsObject(myPrsCopy); + anIsOk &= myCutPane->storeToPrsObject(myPrsCopy); VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); - return ok; + return anIsOk; } void VisuGUI_CutPlanesDlg::accept() diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx index 94a559a3..ad81e44c 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx @@ -151,32 +151,24 @@ void VisuGUI_DeformedShapeDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, if( !theInit ) return; - if( myPrsCopy->IsTimeStampFixed() ) - myTabBox->removePage( myInputPane ); - else - { - myInputPane->initFromPrsObject( myPrsCopy ); - myTabBox->showPage( myInputPane ); - } + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->setCurrentPage( 0 ); } -int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { - myScalarPane->storeToPrsObject(myPrsCopy); +int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) +{ + if(!myInputPane->check() || !myScalarPane->check()) + return 0; - if( !myPrsCopy->IsTimeStampFixed() ) - { - if( !myInputPane->check() ) - return 0; - myInputPane->storeToPrsObject( myPrsCopy ); - } + int anIsOk = myInputPane->storeToPrsObject( myPrsCopy ); + anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy ); myPrsCopy->SetScale(getFactor()); myPrsCopy->ShowColored(isColored()); VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); - return 1; + return anIsOk; } void VisuGUI_DeformedShapeDlg::accept() { diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index 6639a3d7..8097d468 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -690,18 +690,18 @@ void VisuGUI_GaussPointsDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, boo if( !theInit ) return; - if( myPrsCopy->IsTimeStampFixed() ) - myTabBox->removePage( myInputPane ); - else - { - myInputPane->initFromPrsObject( myPrsCopy ); - myTabBox->showPage( myInputPane ); - } + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->setCurrentPage( 0 ); } int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) { + if(!myInputPane->check()) + return 0; + + int anIsOk = myInputPane->storeToPrsObject( myPrsCopy ); + anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy ); + myPrsCopy->SetIsDeformed( myDefShapeButton->isChecked() ); myPrsCopy->SetScaleFactor( myScaleSpinBox->value() ); @@ -739,19 +739,9 @@ int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) myPrsCopy->SetMagnification( mySizeBox->getMagnification() ); myPrsCopy->SetMagnificationIncrement( mySizeBox->getIncrement() ); - int ok = 1; - if( !myPrsCopy->IsTimeStampFixed() ) - { - if( !myInputPane->check() ) - return 0; - - ok = myInputPane->storeToPrsObject( myPrsCopy ); - } - ok = ok && myScalarPane->storeToPrsObject( myPrsCopy ); - VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); - return ok; + return anIsOk; } void VisuGUI_GaussPointsDlg::onToggleDefShape( bool on ) diff --git a/src/VISUGUI/VisuGUI_InputPane.cxx b/src/VISUGUI/VisuGUI_InputPane.cxx index efdcdbdb..980fd139 100644 --- a/src/VISUGUI/VisuGUI_InputPane.cxx +++ b/src/VISUGUI/VisuGUI_InputPane.cxx @@ -32,7 +32,9 @@ #include "VisuGUI_Tools.h" #include "VISU_ColoredPrs3d_i.hh" +#include "VISU_ScalarMap_i.hh" #include "VISU_Result_i.hh" +#include "VISU_Convertor.hxx" #include "SUIT_ResourceMgr.h" @@ -46,56 +48,161 @@ #include "SALOMEDSClient_AttributeString.hxx" #include "SALOMEDSClient_AttributeName.hxx" +#include "QtxListBox.h" + #include #include +#include #include #include #include -using namespace VISU; +//--------------------------------------------------------------- +class VisuGUI_ListBox: public QtxListBox +{ + public: + VisuGUI_ListBox( QWidget * parent = 0, const char * name = 0, WFlags f = 0 ): + QtxListBox(parent, name, f) + {}; + + virtual QSize sizeHint() const + { + return minimumSizeHint(); } + ; +}; + + +//--------------------------------------------------------------- VisuGUI_InputPane::VisuGUI_InputPane( VISU::VISUType theType, SalomeApp_Module* theModule, VisuGUI_Prs3dDlg* theDialog ) : - QGroupBox( 2, Qt::Horizontal, theDialog ), + QGroupBox( theDialog ), myModule( theModule ), myDialog( theDialog ), myPrs( NULL ) { - setFrameStyle( QFrame::Box | QFrame::Sunken ); + setFrameStyle( QFrame::NoFrame ); - connect( GetSelectionMgr( theModule ), SIGNAL( selectionChanged() ), SLOT( onSelectionChanged() ) ); + connect( VISU::GetSelectionMgr( theModule ), SIGNAL( selectionChanged() ), SLOT( onSelectionChanged() ) ); - new QLabel( tr( "MED_FILE" ), this ); - myMedFile = new QLineEdit( this ); - myMedFile->setReadOnly( true ); - myMedFile->setEnabled( false ); - myMedFile->setPaletteForegroundColor( Qt::black ); + QGridLayout* aMainLayout = new QGridLayout( this, 1, 1, 11, 6 ); - new QLabel( tr( "MESH" ), this ); - myMeshName = new QLineEdit( this ); - myMeshName->setReadOnly( true ); - myMeshName->setEnabled( false ); - myMeshName->setPaletteForegroundColor( Qt::black ); + // Definition of data source + myDataSourceGroupBox = new QGroupBox( this ); + aMainLayout->addWidget( myDataSourceGroupBox, 0, 0 ); + myDataSourceGroupBox->setTitle( tr( "PRS_DATA_SOUIRCE" ) ); + { + QGroupBox* aGroupBox = myDataSourceGroupBox; + aGroupBox->setColumnLayout(0, Qt::Vertical ); + aGroupBox->layout()->setSpacing( 6 ); + aGroupBox->layout()->setMargin( 11 ); - new QLabel( tr( "ENTITY" ), this ); - myEntityName = new QLineEdit( this ); - myEntityName->setReadOnly( true ); - myEntityName->setEnabled( false ); - myEntityName->setPaletteForegroundColor( Qt::black ); + QGridLayout* aGroupBoxLayout = new QGridLayout( aGroupBox->layout() ); + aGroupBoxLayout->setAlignment( Qt::AlignTop ); + { + QLabel* aLabel = new QLabel( tr( "MED_FILE" ), aGroupBox ); + aGroupBoxLayout->addWidget( aLabel, 0, 0 ); + + myMedFile = new QLineEdit( aGroupBox ); + myMedFile->setReadOnly( true ); + myMedFile->setEnabled( false ); + myMedFile->setPaletteForegroundColor( Qt::black ); + aGroupBoxLayout->addWidget( myMedFile, 0, 1 ); + } + { + QLabel* aLabel = new QLabel( tr( "MESH" ), aGroupBox ); + aGroupBoxLayout->addWidget( aLabel, 1, 0 ); + + myMeshName = new QLineEdit( aGroupBox ); + myMeshName->setReadOnly( true ); + myMeshName->setEnabled( false ); + myMeshName->setPaletteForegroundColor( Qt::black ); + aGroupBoxLayout->addWidget( myMeshName, 1, 1 ); + } + { + QLabel* aLabel = new QLabel( tr( "ENTITY" ), aGroupBox ); + aGroupBoxLayout->addWidget( aLabel, 2, 0 ); + + myEntityName = new QLineEdit( aGroupBox ); + myEntityName->setReadOnly( true ); + myEntityName->setEnabled( false ); + myEntityName->setPaletteForegroundColor( Qt::black ); + aGroupBoxLayout->addWidget( myEntityName, 2, 1 ); + } + { + QLabel* aLabel = new QLabel( tr( "FIELD" ), aGroupBox ); + aGroupBoxLayout->addWidget( aLabel, 3, 0 ); + + myFieldName = new QLineEdit( aGroupBox ); + myFieldName->setReadOnly( true ); + aGroupBoxLayout->addWidget( myFieldName, 3, 1 ); + } + { + QLabel* aLabel = new QLabel( tr( "TIME_STAMP" ), aGroupBox ); + aGroupBoxLayout->addWidget( aLabel, 4, 0 ); + + myTimeStamps = new QComboBox( aGroupBox ); + aGroupBoxLayout->addWidget( myTimeStamps, 4, 1 ); + } - new QLabel( tr( "FIELD" ), this ); - myFieldName = new QLineEdit( this ); - myFieldName->setReadOnly( true ); + myReInit = new QCheckBox( tr( "REINITIALIZE" ), aGroupBox ); + myReInit->setChecked( true ); + aGroupBoxLayout->addWidget( myReInit, 5, 1 ); + } - new QLabel( tr( "TIME_STAMP" ), this ); - myTimeStamps = new QComboBox( this ); + // Definition of used groups + myUseGroupsGroupBox = new QGroupBox( this ); + aMainLayout->addWidget( myUseGroupsGroupBox, 1, 0 ); + myUseGroupsGroupBox->setTitle( tr( "PRS_ON_GROUPS" ) ); + myUseGroupsGroupBox->setCheckable( TRUE ); + { + QGroupBox* aGroupBox = myUseGroupsGroupBox; + aGroupBox->setColumnLayout(0, Qt::Vertical ); + aGroupBox->layout()->setSpacing( 6 ); + aGroupBox->layout()->setMargin( 11 ); - myReInit = new QCheckBox( tr( "REINITIALIZE" ), this ); - myReInit->setChecked( true ); + QGridLayout* aGroupBoxLayout = new QGridLayout( aGroupBox->layout() ); + aGroupBoxLayout->setAlignment( Qt::AlignTop ); + { + myAllGroups = new VisuGUI_ListBox(aGroupBox, "myAllGroups"); + myAllGroups->setSelectionMode(QListBox::Extended); + aGroupBoxLayout->addMultiCellWidget( myAllGroups, 0, 3, 0, 0 ); + } + { + mySelectedGroups = new VisuGUI_ListBox(aGroupBox, "mySelectedGroups"); + mySelectedGroups->setSelectionMode(QListBox::Extended); + mySelectedGroups->installEventFilter(this); + aGroupBoxLayout->addMultiCellWidget( mySelectedGroups, 0, 3, 2, 2 ); + } + { + myAddButton = new QToolButton(aGroupBox); + myAddButton->setPixmap( VISU::GetResourceMgr()->loadPixmap("VISU", tr("ICON_ADD")) ); + aGroupBoxLayout->addWidget( myAddButton, 1, 1 ); + } + { + myRemoveButton = new QToolButton(aGroupBox); + myRemoveButton->setPixmap( VISU::GetResourceMgr()->loadPixmap("VISU", tr("ICON_REMOVE")) ); + aGroupBoxLayout->addWidget( myRemoveButton, 2, 1 ); + } + { + QSpacerItem* aSpacer = new QSpacerItem( 20, 51, QSizePolicy::Minimum, QSizePolicy::Expanding ); + aGroupBoxLayout->addItem( aSpacer, 0, 1 ); + } + { + QSpacerItem* aSpacer = new QSpacerItem( 20, 61, QSizePolicy::Minimum, QSizePolicy::Expanding ); + aGroupBoxLayout->addItem( aSpacer, 3, 1 ); + } + } connect( myReInit, SIGNAL( toggled( bool ) ), SLOT( onReInitialize( bool ) ) ); + connect( myUseGroupsGroupBox, 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())); + onTypeChanged(); onSelectionChanged(); myFieldFilter = new VisuGUI_FieldFilter( theType ); @@ -103,20 +210,114 @@ VisuGUI_InputPane::VisuGUI_InputPane( VISU::VISUType theType, hide(); } + +//--------------------------------------------------------------- VisuGUI_InputPane::~VisuGUI_InputPane() { if( myFieldFilter ) { - GetSelectionMgr( myModule )->removeFilter( myFieldFilter ); + VISU::GetSelectionMgr( myModule )->removeFilter( myFieldFilter ); delete myFieldFilter; } } + +//--------------------------------------------------------------- +/*! + Event filter +*/ +bool VisuGUI_InputPane::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); +} + + +//--------------------------------------------------------------- +/*! + Called when the checkbox is toggled +*/ +void VisuGUI_InputPane::onTypeChanged( ) +{ + bool toEnable = myUseGroupsGroupBox->isChecked(); + if (!toEnable) + { + myAllGroups->clearSelection(); + mySelectedGroups->clearSelection(); + } + myAllGroups->setEnabled( toEnable ); + mySelectedGroups->setEnabled( toEnable ); + myAddButton->setEnabled( toEnable ); + myRemoveButton->setEnabled( toEnable ); +} + + +//--------------------------------------------------------------- +/*! + Called when add button is clicked, adds item to choosen groups +*/ +void VisuGUI_InputPane::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_InputPane::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_InputPane::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; +} + + +//--------------------------------------------------------------- bool VisuGUI_InputPane::check() { return myTimeStamps->count() != 0; } + +//--------------------------------------------------------------- void VisuGUI_InputPane::clear() { myMedFile->clear(); @@ -126,19 +327,21 @@ void VisuGUI_InputPane::clear() myTimeStamps->clear(); } + +//--------------------------------------------------------------- void VisuGUI_InputPane::onSelectionChanged() { //clear(); SALOME_ListIO aListIO; - GetSelectionMgr( myModule )->selectedObjects(aListIO); + VISU::GetSelectionMgr( myModule )->selectedObjects(aListIO); if (aListIO.Extent() != 1) return; const Handle(SALOME_InteractiveObject)& anIO = aListIO.First(); - _PTR(Study) aCStudy = GetCStudy(GetAppStudy(myModule)); + _PTR(Study) aCStudy = VISU::GetCStudy(VISU::GetAppStudy(myModule)); _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry()); if (!aSObject) return; @@ -186,7 +389,7 @@ void VisuGUI_InputPane::onSelectionChanged() } } - myResult = FindResult( VISU::GetSObject( aSObject ).in() ); + myResult = VISU::FindResult( VISU::GetSObject( aSObject ).in() ); myEntity = VISU::getValue( aSObject, "myEntityId" ).toInt(); @@ -214,12 +417,16 @@ void VisuGUI_InputPane::onSelectionChanged() } } + +//--------------------------------------------------------------- void VisuGUI_InputPane::onReInitialize( bool on ) { if( on ) onSelectionChanged(); } + +//--------------------------------------------------------------- void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs ) { if( myPrs == thePrs ) @@ -249,10 +456,18 @@ void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs ) QString anEntityName; switch( myEntity ) { - case NODE_ENTITY: anEntityName = "onNodes"; break; - case EDGE_ENTITY: anEntityName = "onEdges"; break; - case FACE_ENTITY: anEntityName = "onFaces"; break; - case CELL_ENTITY: anEntityName = "onCells"; break; + case VISU::NODE_ENTITY: + anEntityName = "onNodes"; + break; + case VISU::EDGE_ENTITY: + anEntityName = "onEdges"; + break; + case VISU::FACE_ENTITY: + anEntityName = "onFaces"; + break; + case VISU::CELL_ENTITY: + anEntityName = "onCells"; + break; default: break; } myEntityName->setText( anEntityName ); @@ -262,11 +477,54 @@ void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs ) myTimeStamps->setCurrentItem( thePrs->GetTimeStampIndexByNumber( aTimeStampNumber ) ); myFieldFilter->setPrs3dEntry( thePrs->GetHolderEntry() ); - GetSelectionMgr( myModule )->installFilter( myFieldFilter ); + bool anIsTimeStampFixed = myPrs->IsTimeStampFixed(); + myDataSourceGroupBox->setEnabled(!anIsTimeStampFixed); + if(!anIsTimeStampFixed) + VISU::GetSelectionMgr( myModule )->installFilter( myFieldFilter ); + + // type of presentation and groups + VISU_Convertor* anInput = aResult->GetInput(); + const VISU::TMeshMap& aMeshMap = anInput->GetMeshMap(); + std::string aMeshName = thePrs->GetCMeshName(); + VISU::TMeshMap::const_iterator aMeshIter = aMeshMap.find(aMeshName); + if(aMeshIter != aMeshMap.end()){ + const VISU::PMesh& aMesh = aMeshIter->second; + const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; + VISU::TGroupMap::const_iterator aGroupIter = aGroupMap.begin(); + for(; aGroupIter != aGroupMap.end(); aGroupIter++){ + const std::string& aGroupName = aGroupIter->first; + myAllGroups->insertItem(QString(aGroupName)); + } + } + + if(myAllGroups->count() < 1){ + myAllGroups->insertItem( tr("NO_GROUPS") ); + myUseGroupsGroupBox->setEnabled(false); + }else if(VISU::ScalarMap_i* aPrs = dynamic_cast(thePrs)){ + const VISU::ScalarMap_i::TGroupNames& aGroupNames = aPrs->GetGroupNames(); + VISU::ScalarMap_i::TGroupNames::const_iterator anIter = aGroupNames.begin(); + for(; anIter != aGroupNames.end(); anIter++){ + const std::string aGroupName = *anIter; + mySelectedGroups->insertItem(QString(aGroupName)); + } + } + myUseGroupsGroupBox->setChecked(mySelectedGroups->count() > 0); } + +//--------------------------------------------------------------- int VisuGUI_InputPane::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) { + if(VISU::ScalarMap_i* aPrs = dynamic_cast(thePrs)){ + if(myUseGroupsGroupBox->isChecked()){ + aPrs->RemoveAllGeom(); + std::string aMeshName = aPrs->GetCMeshName(); + for(int i = 0; i < mySelectedGroups->count(); i++) + aPrs->AddMeshOnGroup( aMeshName.c_str() , mySelectedGroups->text(i) ); + }else + aPrs->SetSourceGeometry(); + } + thePrs->SetResultObject( myResult ); thePrs->SetMeshName( myMeshName->text().latin1() ); @@ -275,3 +533,6 @@ int VisuGUI_InputPane::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) thePrs->SetTimeStampNumber( thePrs->GetTimeStampNumberByIndex( myTimeStamps->currentItem() ) ); return ( int )thePrs->Apply( false ); } + + +//--------------------------------------------------------------- diff --git a/src/VISUGUI/VisuGUI_InputPane.h b/src/VISUGUI/VisuGUI_InputPane.h index 279ff14f..e5e3fb30 100644 --- a/src/VISUGUI/VisuGUI_InputPane.h +++ b/src/VISUGUI/VisuGUI_InputPane.h @@ -35,10 +35,13 @@ class QCheckBox; class QComboBox; class QLineEdit; +class QListBoxItem; +class QToolButton; class SalomeApp_Module; class LightApp_SelectionMgr; +class VisuGUI_ListBox; class VisuGUI_Prs3dDlg; class VisuGUI_FieldFilter; @@ -65,15 +68,30 @@ public: void initFromPrsObject( VISU::ColoredPrs3d_i* ); int storeToPrsObject( VISU::ColoredPrs3d_i* ); + bool eventFilter (QObject* object, QEvent* event); + public slots: virtual void onSelectionChanged(); virtual void onReInitialize( bool ); +private slots: + void onTypeChanged(); + void onListDoubleClicked( QListBoxItem* theItem ); + void onAdd(); + void onRemove(); + private: SalomeApp_Module* myModule; - VisuGUI_Prs3dDlg* myDialog; + VisuGUI_Prs3dDlg* myDialog; VISU::ColoredPrs3d_i* myPrs; + QGroupBox* myUseGroupsGroupBox; + VisuGUI_ListBox* myAllGroups; + VisuGUI_ListBox* mySelectedGroups; + QToolButton* myAddButton; + QToolButton* myRemoveButton; + + QGroupBox* myDataSourceGroupBox; QLineEdit* myMedFile; QLineEdit* myMeshName; QLineEdit* myEntityName; diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx index 1963b443..9b629c45 100644 --- a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx @@ -248,32 +248,22 @@ void VisuGUI_IsoSurfacesDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, boo if( !theInit ) return; - if( myPrsCopy->IsTimeStampFixed() ) - myTabBox->removePage( myInputPane ); - else - { - myInputPane->initFromPrsObject( myPrsCopy ); - myTabBox->showPage( myInputPane ); - } + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->setCurrentPage( 0 ); } int VisuGUI_IsoSurfacesDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { - int ok = 1; - if( !myPrsCopy->IsTimeStampFixed() ) - { - if( !myInputPane->check() ) - return 0; - - ok = myInputPane->storeToPrsObject( myPrsCopy ); - } - - ok = ok && myScalarPane->storeToPrsObject( myPrsCopy ) && myIsoPane->storeToPrsObject(myPrsCopy); + if(!myInputPane->check() || !myScalarPane->check()) + return 0; + + int anIsOk = myInputPane->storeToPrsObject( myPrsCopy ); + anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy ); + anIsOk &= myIsoPane->storeToPrsObject( myPrsCopy ); VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); - return ok; + return anIsOk; } void VisuGUI_IsoSurfacesDlg::onHelp() diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx index 08c5cb97..a7d454c8 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx @@ -642,13 +642,7 @@ void VisuGUI_Plot3DDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool the if( !theInit ) return; - if( myPrsCopy->IsTimeStampFixed() ) - myTabBox->removePage( myInputPane ); - else - { - myInputPane->initFromPrsObject( myPrsCopy ); - myTabBox->showPage( myInputPane ); - } + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->setCurrentPage( 0 ); } @@ -658,19 +652,16 @@ void VisuGUI_Plot3DDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool the //======================================================================= int VisuGUI_Plot3DDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) { - int ok = 1; - if( !myPrsCopy->IsTimeStampFixed() ) - { - if( !myInputPane->check() ) - return 0; - - ok = myInputPane->storeToPrsObject( myPrsCopy ); - } - ok = ok && myScalarPane->storeToPrsObject(myPrsCopy) && myIsoPane->storeToPrsObject(myPrsCopy); + if(!myInputPane->check() || !myScalarPane->check()) + return 0; + + int anIsOk = myInputPane->storeToPrsObject( myPrsCopy ); + anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy ); + anIsOk &= myIsoPane->storeToPrsObject( myPrsCopy ); VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); - return ok; + return anIsOk; } //======================================================================= diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index 8455b972..76e5dcaf 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -171,13 +171,7 @@ void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool if( !theInit ) return; - if( myPrsCopy->IsTimeStampFixed() ) - myTabBox->removePage( myInputPane ); - else - { - myInputPane->initFromPrsObject( myPrsCopy ); - myTabBox->showPage( myInputPane ); - } + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->setCurrentPage( 0 ); } @@ -186,20 +180,15 @@ void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool */ int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { - int ok = 1; - if( !myPrsCopy->IsTimeStampFixed() ) - { - if( !myInputPane->check() ) - return 0; - - ok = myInputPane->storeToPrsObject( myPrsCopy ); - } - - ok = ok && myScalarPane->storeToPrsObject( myPrsCopy ); - + if(!myInputPane->check() || !myScalarPane->check()) + return 0; + + int anIsOk = myInputPane->storeToPrsObject( myPrsCopy ); + anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy ); + VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); - - return ok; + + return anIsOk; } /*! diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx index 816da47b..3d1b7afd 100644 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx @@ -308,13 +308,7 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject(VISU::ColoredPrs3d_i if( !theInit ) return; - if( myPrsCopy->IsTimeStampFixed() ) - myTabBox->removePage( myInputPane ); - else - { - myInputPane->initFromPrsObject( myPrsCopy ); - myTabBox->showPage( myInputPane ); - } + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->setCurrentPage( 0 ); } @@ -322,6 +316,12 @@ int VisuGUI_ScalarMapOnDeformedShapeDlg ::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { + if(!myInputPane->check() || !myScalarPane->check()) + return 0; + + int anIsOk = myInputPane->storeToPrsObject( myPrsCopy ); + anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy ); + myPrsCopy->SetScale(getFactor()); CORBA::String_var aMeshName = myPrsCopy->GetMeshName(); @@ -335,18 +335,9 @@ VisuGUI_ScalarMapOnDeformedShapeDlg myPrsCopy->ShowColored(true); - myScalarPane->storeToPrsObject(myPrsCopy); - - if( !myPrsCopy->IsTimeStampFixed() ) - { - if( !myInputPane->check() ) - return 0; - myInputPane->storeToPrsObject( myPrsCopy ); - } - VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); - return 1; + return anIsOk; } int VisuGUI_ScalarMapOnDeformedShapeDlg::getCurrentScalarFieldNamePos(){ diff --git a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx index 0a0e87fb..ed02c77b 100644 --- a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx @@ -388,29 +388,20 @@ void VisuGUI_StreamLinesDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, bo if( !theInit ) return; - if( myPrsCopy->IsTimeStampFixed() ) - myTabBox->removePage( myInputPane ); - else - { - myInputPane->initFromPrsObject( myPrsCopy ); - myTabBox->showPage( myInputPane ); - } + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->setCurrentPage( 0 ); } int VisuGUI_StreamLinesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) { - bool isAccepted = myScalarPane->storeToPrsObject(myPrsCopy); - - if( isAccepted && !myPrsCopy->IsTimeStampFixed() ) - { - if( !myInputPane->check() ) - return 0; - isAccepted = myInputPane->storeToPrsObject( myPrsCopy ); - } - - if (isAccepted) { + if(!myInputPane->check() || !myScalarPane->check()) + return 0; + + int anIsOk = myInputPane->storeToPrsObject( myPrsCopy ); + anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy ); + + if (anIsOk) { myPrsCopy->ShowColored(myUseScalar->isChecked()); if (!myPrsCopy->IsColored()) { SALOMEDS::Color aColor; @@ -462,7 +453,7 @@ int VisuGUI_StreamLinesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) aPrs = createMesh(aType, aName); } } - isAccepted = myPrsCopy->SetParams(myIntegStepLen->value(), + anIsOk &= myPrsCopy->SetParams(myIntegStepLen->value(), myPropTime->value(), myStepLen->value(), aPrs, @@ -476,7 +467,7 @@ int VisuGUI_StreamLinesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); - return isAccepted; + return anIsOk; } /*! diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.cxx b/src/VISUGUI/VisuGUI_VectorsDlg.cxx index 03ef0f9f..4a77ad49 100644 --- a/src/VISUGUI/VisuGUI_VectorsDlg.cxx +++ b/src/VISUGUI/VisuGUI_VectorsDlg.cxx @@ -227,25 +227,19 @@ void VisuGUI_VectorsDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool th if( !theInit ) return; - if( myPrsCopy->IsTimeStampFixed() ) - myTabBox->removePage( myInputPane ); - else - { - myInputPane->initFromPrsObject( myPrsCopy ); - myTabBox->showPage( myInputPane ); - } + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->setCurrentPage( 0 ); } -int VisuGUI_VectorsDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { - myScalarPane->storeToPrsObject(myPrsCopy); - if( !myPrsCopy->IsTimeStampFixed() ) - { - if( !myInputPane->check() ) - return 0; - myInputPane->storeToPrsObject( myPrsCopy ); - } +int VisuGUI_VectorsDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) +{ + if(!myInputPane->check() || !myScalarPane->check()) + return 0; + + int anIsOk = myInputPane->storeToPrsObject( myPrsCopy ); + anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy ); + myPrsCopy->SetScale(getScaleFactor()); myPrsCopy->SetLineWidth(getLineWidth()); myPrsCopy->ShowColored(getUseMagnColor()); @@ -264,7 +258,7 @@ int VisuGUI_VectorsDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); - return 1; + return anIsOk; } diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index 995c7aa9..5985f815 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -128,12 +128,14 @@ void VISU::ScalarMap_i ::UpdateIcon() { + SALOMEDS::SObject_var aSObject = GetSObject(); + if(CORBA::is_nil(aSObject)) + return; + SALOMEDS::Study_var aStudyDocument = GetStudyDocument(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudyDocument->NewBuilder(); // Check if the icon needs to be updated, update if necessary - SALOMEDS::SObject_var aSObject = GetSObject(); - SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributePixMap"); SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); @@ -188,6 +190,8 @@ VISU::ScalarMap_i SetScaling(anOrigin->GetScaling()); + myGroupNames = anOrigin->GetGroupNames(); + Update(); } } @@ -252,6 +256,18 @@ VISU::ScalarMap_i UseFixedRange(VISU::Storable::FindValue(theMap,"myIsFixedRange").toInt()); + QString aGeomNames = VISU::Storable::FindValue(theMap, "myGeomNameList"); + QStringList aGeomNameList = QStringList::split("|", aGeomNames); + int aNbOfGroups = aGeomNameList.count(); + if(aNbOfGroups > 0){ + RemoveAllGeom(); + std::string aMeshName = GetCMeshName(); + for(int aGroupNum = 0; aGroupNum < aNbOfGroups; aGroupNum++){ + QString aGroupName = aGeomNameList[aGroupNum]; + AddMeshOnGroup(aMeshName.c_str(), aGroupName.latin1()); + } + } + return this; } @@ -266,6 +282,16 @@ VISU::ScalarMap_i Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() ); Storable::DataToStream( theStr, "myIsFixedRange", IsRangeFixed() ); Storable::DataToStream( theStr, "myScaling", GetScaling() ); + + std::ostringstream aGeomNameList; + std::string aMeshName = GetCMeshName(); + const TGroupNames& aGroupNames = GetGroupNames(); + TGroupNames::const_iterator anIter = aGroupNames.begin(); + for(; anIter != aGroupNames.end(); anIter++){ + const std::string& aGroupName = *anIter; + aGeomNameList<SetSourceGeometry(); + myGroupNames.clear(); + UpdateIcon(); + } +} + +//---------------------------------------------------------------------------- +void +VISU::ScalarMap_i +::AddMeshOnGroup(const char* theMeshName, + const char* theGroupName) { VISU::Result_i::TInput* anInput = GetCResult()->GetInput(); VISU::PUnstructuredGridIDMapper anIDMapper = anInput->GetMeshOnGroup(theMeshName, theGroupName); if(anIDMapper){ int aNbGroups = myGroupNames.size(); - if(myGroupNames.find(theGroupName) != myGroupNames.end()){ + if(myGroupNames.find(theGroupName) == myGroupNames.end()){ GetSpecificPL()->AddGeometry(anIDMapper->GetOutput()); myGroupNames.insert(theGroupName); if(aNbGroups == 0) @@ -359,11 +398,10 @@ VISU::ScalarMap_i ::RemoveAllGeom() { int aNbGroups = myGroupNames.size(); - if(aNbGroups != 0){ - GetSpecificPL()->ClearGeometry(); - myGroupNames.clear(); + GetSpecificPL()->ClearGeometry(); + myGroupNames.clear(); + if(aNbGroups != 0) UpdateIcon(); - } } diff --git a/src/VISU_I/VISU_ScalarMap_i.hh b/src/VISU_I/VISU_ScalarMap_i.hh index b5d1bc7d..fbe67364 100644 --- a/src/VISU_I/VISU_ScalarMap_i.hh +++ b/src/VISU_I/VISU_ScalarMap_i.hh @@ -94,6 +94,11 @@ namespace VISU GetBarOrientation(); //---------------------------------------------------------------------------- + //! Sets initial source geometry + virtual + void + SetSourceGeometry(); + //! Add geometry of mesh as group. \retval the id of added group. virtual void