From: ouv Date: Thu, 22 Apr 2010 11:10:58 +0000 (+0000) Subject: Issue 0020465: [CEA 335] sort tables in visualisation mode X-Git-Tag: V5_1_4rc1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c22b2d04fe67985a4fbd7ee5dc460bbba50b76c1;p=modules%2Fvisu.git Issue 0020465: [CEA 335] sort tables in visualisation mode --- diff --git a/doc/salome/gui/VISU/images/viewtable.png b/doc/salome/gui/VISU/images/viewtable.png index 13a0e5da..697cdd31 100644 Binary files a/doc/salome/gui/VISU/images/viewtable.png and b/doc/salome/gui/VISU/images/viewtable.png differ diff --git a/doc/salome/gui/VISU/input/table_presentations.doc b/doc/salome/gui/VISU/input/table_presentations.doc index 82dc0c96..44a153bf 100644 --- a/doc/salome/gui/VISU/input/table_presentations.doc +++ b/doc/salome/gui/VISU/input/table_presentations.doc @@ -27,6 +27,26 @@ in the context menu. \image html viewtable.png +When the Enable editing option is checked, contents of the table +are editable. +\note At the current moment this mode allows to sort table data only. +Sorting is performed by clicking on header of the column, by which the data +has to be sorted. + +Sort policy option allows to specify how the empty cells will be processed +during the sort procedure. The following options are available: + + +Adjust Cells button allows to adjust size of the table cells according +to their contents. + It is also possible to create \subpage table_3d_page "Table 3D presentation" basing on the table data and display it in the VTK viewer. diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index 91c71b58..74dc330c 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -72,6 +72,8 @@ + + diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index ea430b44..7c4cfd7a 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -421,6 +421,42 @@ number of time stamps or number of components is not the same! VISU_SWEEPING_PREF Sweeping preferences + + VISU_TABLES + Tables + + + VISU_TABLES_EDITING_PROPS + Tables editing properties + + + VISU_TABLES_ENABLE_EDITING + Enable editing + + + VISU_TABLES_SORT_POLICY + Sort policy + + + VISU_TABLES_EMPTY_LOWEST + Empty cells are considered as lowest values + + + VISU_TABLES_EMPTY_HIGHEST + Empty cells are considered as highest values + + + VISU_TABLES_EMPTY_FIRST + Empty cells are always first + + + VISU_TABLES_EMPTY_LAST + Empty cells are always last + + + VISU_TABLES_EMPTY_IGNORE + Empty cells are ignored + VISU_TIME_STAMP_FREQUENCY Time stamp frequency (for AVI generation) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 600c00f4..8cc895f5 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -4215,9 +4215,6 @@ void VisuGUI::createPreferences() setPreferenceProperty( scalar_def_represent, "indexes", indices1 ); addPreference( tr( "VISU_SHRINK" ), representGr, LightApp_Preferences::Bool, "VISU", "scalar_def_shrink" ); - addPreference( "", representGr, LightApp_Preferences::Space ); - - int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), representGr, LightApp_Preferences::Selector, "VISU", "quadratic_mode" ); QStringList quadraticModes; quadraticModes.append("Lines"); @@ -4285,6 +4282,30 @@ void VisuGUI::createPreferences() addPreference( tr( "VISU_AUTOMATIC_FIT_ALL" ), representGr, LightApp_Preferences::Bool, "VISU", "automatic_fit_all" ); + // TAB: Tables ; group: "Tables editing properties" + int tablesTab = addPreference( tr( "VISU_TABLES" ) ); + + int tablesGr = addPreference( tr( "VISU_TABLES_EDITING_PROPS" ), tablesTab ); + setPreferenceProperty( tablesGr, "columns", 1 ); + + addPreference( tr( "VISU_TABLES_ENABLE_EDITING" ), tablesGr, LightApp_Preferences::Bool, "VISU", "tables_enable_editing" ); + + int sortPolicyPref = addPreference( tr( "VISU_TABLES_SORT_POLICY" ), tablesGr, LightApp_Preferences::Selector, "VISU", "tables_sort_policy" ); + QStringList policies; + policies.append( tr( "VISU_TABLES_EMPTY_LOWEST" ) ); + policies.append( tr( "VISU_TABLES_EMPTY_HIGHEST" ) ); + policies.append( tr( "VISU_TABLES_EMPTY_FIRST" ) ); + policies.append( tr( "VISU_TABLES_EMPTY_LAST" ) ); + policies.append( tr( "VISU_TABLES_EMPTY_IGNORE" ) ); + indices.clear(); + indices.append( 0 ); + indices.append( 1 ); + indices.append( 2 ); + indices.append( 3 ); + indices.append( 4 ); + setPreferenceProperty( sortPolicyPref, "strings", policies ); + setPreferenceProperty( sortPolicyPref, "indexes", indices ); + // TAB: Feature edges ; group: "Feature edges properties" int featureEdgesTab = addPreference( tr( "VISU_FEATURE_EDGES" ) ); diff --git a/src/VISU_I/VISU_TableDlg.cxx b/src/VISU_I/VISU_TableDlg.cxx index 6fc4d5e2..46a6b993 100644 --- a/src/VISU_I/VISU_TableDlg.cxx +++ b/src/VISU_I/VISU_TableDlg.cxx @@ -52,6 +52,7 @@ #include #include #include +#include #include "utilities.h" @@ -289,6 +290,11 @@ VISU_TableDlg::VISU_TableDlg( QWidget* parent, checkLayout->addWidget( myEditCheck ); checkLayout->addWidget( myUpdateCheck ); mainLayout->addLayout( checkLayout ); + + if ( LightApp_Application* app = ( LightApp_Application* )SUIT_Session::session()->activeApplication() ) { + int anEnableEditing = app->resourceMgr()->booleanValue( "VISU", "tables_enable_editing", false ); + myEditCheck->setChecked( anEnableEditing ); + } } mainLayout->addWidget( top ); mainLayout->addLayout( btnLayout ); @@ -471,7 +477,7 @@ void VISU_TableDlg::keyPressEvent( QKeyEvent* e ) Constructor */ VISU_TableDlg::TableWidget::TableWidget( QWidget* parent, - Qt::Orientation orientation ) + Qt::Orientation orientation ) : QWidget( parent ), myOrientation( orientation ) { myTitleEdit = new QLineEdit( this ); @@ -491,7 +497,21 @@ VISU_TableDlg::TableWidget::TableWidget( QWidget* parent, myAddColBtn = new QPushButton( VISU_TableDlg::tr( "ADD_COLUMN_BTN" ), this ); myDelColBtn = new QPushButton( VISU_TableDlg::tr( "REMOVE_COLUMN_BTN" ), this ); mySelectAllBtn = new QPushButton( VISU_TableDlg::tr( "SELECT_ALL_BTN" ), this ); - myClearBtn = new QPushButton( VISU_TableDlg::tr( "CLEAR_BTN"), this ); + myClearBtn = new QPushButton( VISU_TableDlg::tr( "CLEAR_BTN" ), this ); + + mySortPolicyLabel = new QLabel( VISU_TableDlg::tr( "VISU_TABLES_SORT_POLICY" ), this ); + mySortPolicyCombo = new QComboBox( this ); + mySortPolicyCombo->insertItems( 0, QStringList() << + VISU_TableDlg::tr( "VISU_TABLES_EMPTY_LOWEST" ) << + VISU_TableDlg::tr( "VISU_TABLES_EMPTY_HIGHEST" ) << + VISU_TableDlg::tr( "VISU_TABLES_EMPTY_FIRST" ) << + VISU_TableDlg::tr( "VISU_TABLES_EMPTY_LAST" ) << + VISU_TableDlg::tr( "VISU_TABLES_EMPTY_IGNORE" ) ); + + if ( LightApp_Application* app = ( LightApp_Application* )SUIT_Session::session()->activeApplication() ) { + int aSortPolicy = app->resourceMgr()->integerValue( "VISU", "tables_sort_policy", 3 ); + mySortPolicyCombo->setCurrentIndex( aSortPolicy ); + } // the features has been temporarily disabled myAddRowBtn->hide(); @@ -514,12 +534,20 @@ VISU_TableDlg::TableWidget::TableWidget( QWidget* parent, btnLayout->addWidget( mySelectAllBtn ); btnLayout->addWidget( myClearBtn ); + QHBoxLayout* sortLayout = new QHBoxLayout; + sortLayout->setMargin( 0 ); + sortLayout->setSpacing( SPACING_SIZE ); + sortLayout->addWidget( mySortPolicyLabel ); + sortLayout->addWidget( mySortPolicyCombo ); + sortLayout->addStretch( 1 ); + QGridLayout* mainLayout = new QGridLayout( this ); mainLayout->setMargin( 0 ); mainLayout->setSpacing( SPACING_SIZE ); mainLayout->addWidget( myTitleEdit, 0, 0, 1, 2 ); - mainLayout->addWidget( myTable, 1, 0 ); - mainLayout->addLayout( btnLayout, 1, 1 ); + mainLayout->addWidget( myTable, 1, 0 ); + mainLayout->addLayout( btnLayout, 1, 1 ); + mainLayout->addLayout( sortLayout, 2, 0, 1, 2 ); connect( myTable, SIGNAL( itemSelectionChanged() ), this, SLOT( updateButtonsState() ) ); @@ -532,6 +560,10 @@ VISU_TableDlg::TableWidget::TableWidget( QWidget* parent, connect( myAdjustBtn, SIGNAL( clicked() ), this, SLOT( adjustTable() ) ); connect( mySelectAllBtn, SIGNAL( clicked() ), this, SLOT( selectAll() ) ); connect( myClearBtn, SIGNAL( clicked() ), this, SLOT( clearTable() ) ); + connect( myTable->horizontalHeader(), SIGNAL( sectionClicked( int ) ), + this, SLOT( columnClicked( int ) ) ); + connect( myTable->verticalHeader(), SIGNAL( sectionClicked( int ) ), + this, SLOT( rowClicked( int ) ) ); myTable->horizontalHeader()->installEventFilter( this ); myTable->verticalHeader()->installEventFilter( this ); myTable->installEventFilter( this ); @@ -559,6 +591,12 @@ void VISU_TableDlg::TableWidget::initialize( _PTR(Study) study, VISU::Table_i* t setEditEnabled( false ); showColumnTitles( false ); + updateTableFromServant(); + updateButtonsState(); +} + +void VISU_TableDlg::TableWidget::updateTableFromServant() +{ _PTR(SObject) aSObject = myStudy->FindObjectID( myTableObj->GetObjectEntry() ); if ( aSObject ) { int i, j; @@ -683,7 +721,6 @@ void VISU_TableDlg::TableWidget::initialize( _PTR(Study) study, VISU::Table_i* t break; } } - updateButtonsState(); } /*! @@ -691,7 +728,16 @@ void VISU_TableDlg::TableWidget::initialize( _PTR(Study) study, VISU::Table_i* t */ void VISU_TableDlg::TableWidget::setEditEnabled( bool enable ) { - // the feature has been temporarily disabled + if( !enable ) { + myTable->horizontalHeader()->setSortIndicatorShown( false ); + myTable->verticalHeader()->setSortIndicatorShown( false ); + adjustTable(); + } + + mySortPolicyLabel->setEnabled( enable ); + mySortPolicyCombo->setEnabled( enable ); + + // the rest features have been temporarily disabled enable = false; myTitleEdit->setReadOnly( !enable ); @@ -1089,6 +1135,36 @@ void VISU_TableDlg::TableWidget::clearTable() myTable->clearContents(); updateButtonsState(); } +/*! + Column clicked slot +*/ +void VISU_TableDlg::TableWidget::columnClicked( int column ) +{ + if ( myTableObj && mySortPolicyCombo->isEnabled() ) { + myTableObj->SortByRow( column + 1, + ( VISU::SortOrder )myTable->horizontalHeader()->sortIndicatorOrder(), + ( VISU::SortPolicy )mySortPolicyCombo->currentIndex() ); + myTable->horizontalHeader()->setSortIndicatorShown( true ); + myTable->verticalHeader()->setSortIndicatorShown( false ); + updateTableFromServant(); + } +} +/*! + Row clicked slot +*/ +void VISU_TableDlg::TableWidget::rowClicked( int row ) +{ + /* the feature has been temporarily disabled + if ( myTableObj && mySortPolicyCombo->isEnabled() && row > 0 ) { // first row contains units + myTableObj->SortByColumn( row, + ( VISU::SortOrder )myTable->verticalHeader()->sortIndicatorOrder(), + ( VISU::SortPolicy )mySortPolicyCombo->currentIndex() ); + myTable->horizontalHeader()->setSortIndicatorShown( false ); + myTable->verticalHeader()->setSortIndicatorShown( true ); + updateTableFromServant(); + } + */ +} /*! Event filter - handles titles editing */ diff --git a/src/VISU_I/VISU_TableDlg.h b/src/VISU_I/VISU_TableDlg.h index df63250b..a911a6ce 100644 --- a/src/VISU_I/VISU_TableDlg.h +++ b/src/VISU_I/VISU_TableDlg.h @@ -32,9 +32,11 @@ #include #include +class QLabel; class QLineEdit; class QPushButton; class QCheckBox; +class QComboBox; class QTableWidget; namespace VISU @@ -135,6 +137,12 @@ public slots: void selectAll(); void clearTable(); + void columnClicked( int ); + void rowClicked( int ); + +protected: + void updateTableFromServant(); + private: _PTR(Study) myStudy; VISU::Table_i* myTableObj; @@ -150,6 +158,8 @@ private: QPushButton* myAdjustBtn; QPushButton* mySelectAllBtn; QPushButton* myClearBtn; + QLabel* mySortPolicyLabel; + QComboBox* mySortPolicyCombo; Qt::Orientation myOrientation; }; diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index ffc9a055..22166fd5 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -138,7 +138,7 @@ VISU::Table_i aReal->SortRow( theRow, (SALOMEDS::AttributeTable::SortOrder)theSortOrder, (SALOMEDS::AttributeTable::SortPolicy)theSortPolicy ); } - UpdateCurves(); + UpdateCurves( std::map() ); } } @@ -161,7 +161,7 @@ VISU::Table_i aReal->SortColumn( theColumn, (SALOMEDS::AttributeTable::SortOrder)theSortOrder, (SALOMEDS::AttributeTable::SortPolicy)theSortPolicy ); } - UpdateCurves(); + UpdateCurves( std::map() ); } } @@ -184,7 +184,7 @@ VISU::Table_i aReal->SortByRow( theRow, (SALOMEDS::AttributeTable::SortOrder)theSortOrder, (SALOMEDS::AttributeTable::SortPolicy)theSortPolicy ); } - UpdateCurves(); + UpdateCurves( std::map() ); } } @@ -196,25 +196,29 @@ VISU::Table_i SALOMEDS::SObject_var SO = mySObj; SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); if ( !SO->_is_nil() ) { + SALOMEDS::LongSeq_var aRowIndices; SALOMEDS::GenericAttribute_var anAttr; if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) { SALOMEDS::AttributeTableOfInteger_var anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr ); - anInt->SortByColumn( theColumn, (SALOMEDS::AttributeTable::SortOrder)theSortOrder, - (SALOMEDS::AttributeTable::SortPolicy)theSortPolicy ); + aRowIndices = anInt->SortByColumn( theColumn, (SALOMEDS::AttributeTable::SortOrder)theSortOrder, + (SALOMEDS::AttributeTable::SortPolicy)theSortPolicy ); } else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) { SALOMEDS::AttributeTableOfReal_var aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr ); - aReal->SortByColumn( theColumn, (SALOMEDS::AttributeTable::SortOrder)theSortOrder, - (SALOMEDS::AttributeTable::SortPolicy)theSortPolicy ); + aRowIndices = aReal->SortByColumn( theColumn, (SALOMEDS::AttributeTable::SortOrder)theSortOrder, + (SALOMEDS::AttributeTable::SortPolicy)theSortPolicy ); } - UpdateCurves(); + std::map aMixData; + for ( int i = 0, n = aRowIndices->length(); i < n; i++ ) + aMixData[ aRowIndices[i] ] = i+1; + UpdateCurves( aMixData ); } } //---------------------------------------------------------------------------- void VISU::Table_i -::UpdateCurves() +::UpdateCurves(std::map theMixData) { SALOMEDS::SObject_var SO = mySObj; SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); @@ -222,9 +226,16 @@ VISU::Table_i for ( CI->InitEx( true ); CI->More(); CI->Next() ) { CORBA::Object_var anObj = SObjectToObject( CI->Value() ); VISU::Curve_var aCurve = VISU::Curve::_narrow( anObj ); - if ( !aCurve->_is_nil() ) - if( VISU::Curve_i* pCurve = dynamic_cast( GetServant( aCurve ).in() ) ) - UpdatePlot2d( NULL, eDisplay, pCurve ); // first parameter is null to update curves in all views + if ( !aCurve->_is_nil() ) { + if ( VISU::Curve_i* pCurve = dynamic_cast( GetServant( aCurve ).in() ) ) { + int aHRow = pCurve->GetHRow(), aVRow = pCurve->GetVRow(); + if ( theMixData.find( aHRow ) != theMixData.end() ) + pCurve->SetHRow( theMixData[ aHRow ] ); + if ( theMixData.find( aVRow ) != theMixData.end() ) + pCurve->SetVRow( theMixData[ aVRow ] ); + UpdatePlot2d( pCurve, eUpdateData ); + } + } } } diff --git a/src/VISU_I/VISU_Table_i.hh b/src/VISU_I/VISU_Table_i.hh index d385b1cb..3db4f3b5 100644 --- a/src/VISU_I/VISU_Table_i.hh +++ b/src/VISU_I/VISU_Table_i.hh @@ -64,7 +64,7 @@ namespace VISU{ protected: Storable* Build(int theRestoring); - void UpdateCurves(); + void UpdateCurves(std::map theMixData); protected: VISU::Table::Orientation myOrientation; @@ -145,10 +145,17 @@ namespace VISU{ public: virtual Storable* Create(); - int GetHRow() const { return myHRow;} - int GetVRow() const { return myVRow;} - int GetZRow() const { return myZRow;} - int GetIsV2() const { return myIsV2;} + int GetHRow() const { return myHRow; } + void SetHRow( const int theHRow ) { myHRow = theHRow; } + + int GetVRow() const { return myVRow; } + void SetVRow( const int theVRow ) { myVRow = theVRow; } + + int GetZRow() const { return myZRow; } + void SetZRow( const int theZRow ) { myZRow = theZRow; } + + int GetIsV2() const { return myIsV2; } + void SetIsV2( const int theIsV2 ) { myIsV2 = theIsV2; } virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr theSO); diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index 07293528..e591ba5a 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -95,19 +95,19 @@ namespace VISU { QList anApplications = aSession->applications(); QList::Iterator anIter = anApplications.begin(); while ( anIter != anApplications.end() ) { - SUIT_Application* anApp = *anIter; - if (SUIT_Study* aSStudy = anApp->activeStudy()) { - if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { + SUIT_Application* anApp = *anIter; + if (SUIT_Study* aSStudy = anApp->activeStudy()) { + if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { if (_PTR(Study) aCStudy = aStudy->studyDS()) { //if (myStudyName == aCStudy->Name()) { if (myStudyId == aCStudy->StudyId()) { - myResult = dynamic_cast(anApp); - break; - } - } - } - } - anIter++; + myResult = dynamic_cast(anApp); + break; + } + } + } + } + anIter++; } if (!myResult) { //MESSAGE("Error: application is not found for study : " << myStudyName); @@ -151,7 +151,7 @@ namespace VISU { { VISU::View3D_i* aView = new View3D_i (myApplication); if (aView->Create(0)) - myResult = aView->_this(); + myResult = aView->_this(); } }; @@ -179,11 +179,11 @@ namespace VISU { { //if (CheckStudy(myStudyDocument)) { if (myApplication) { - TViewFrame* pView = new TViewFrame (myApplication); - if (pView->Create(1)) { - myResult = pView->_this(); - qApp->processEvents(); // Fix for bug 9929 - } + TViewFrame* pView = new TViewFrame (myApplication); + if (pView->Create(1)) { + myResult = pView->_this(); + qApp->processEvents(); // Fix for bug 9929 + } } } }; @@ -216,7 +216,7 @@ namespace VISU { Table_ptr myTable; public: TCreateTableViewFrameEvent (SalomeApp_Application* theApplication, - Table_ptr theTable): + Table_ptr theTable): TCreateViewEvent(theApplication), myTable(theTable), myResult(VISU::TableView::_nil()) @@ -225,9 +225,9 @@ namespace VISU { virtual void Execute() { //if (CheckStudy(myStudyDocument)) { - VISU::TableView_i* pView = new TableView_i (myApplication); - if (pView->Create(myTable) != NULL) - myResult = pView->_this(); + VISU::TableView_i* pView = new TableView_i (myApplication); + if (pView->Create(myTable) != NULL) + myResult = pView->_this(); //} } typedef VISU::TableView_ptr TResult; @@ -247,15 +247,15 @@ namespace VISU { View_ptr myView; public: TEvent(View_ptr theView): - myView(theView) + myView(theView) {} virtual void Execute(){ - if (!CORBA::is_nil(myView)) { - if (VISU::View_i* pView = dynamic_cast(VISU::GetServant(myView).in())) { - pView->Close(); - pView->_remove_ref(); - } - } + if (!CORBA::is_nil(myView)) { + if (VISU::View_i* pView = dynamic_cast(VISU::GetServant(myView).in())) { + pView->Close(); + pView->_remove_ref(); + } + } } }; @@ -298,19 +298,19 @@ namespace VISU { VISU_Actor *anVISUActor = NULL, *aResActor = NULL; for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;){ if(anActor->IsA("VISU_Actor")){ - anVISUActor = VISU_Actor::SafeDownCast(anActor); - if (thePrs == anVISUActor->GetPrs3d()) { - aResActor = anVISUActor; - if(theDisplaing < eErase) - aResActor->VisibilityOn(); - else - aResActor->VisibilityOff(); - } else { - if(theDisplaing == eEraseAll || theDisplaing == eDisplayOnly) - anVISUActor->VisibilityOff(); - else if ( theDisplaing == eDisplayAll ) - anVISUActor->VisibilityOn(); - } + anVISUActor = VISU_Actor::SafeDownCast(anActor); + if (thePrs == anVISUActor->GetPrs3d()) { + aResActor = anVISUActor; + if(theDisplaing < eErase) + aResActor->VisibilityOn(); + else + aResActor->VisibilityOff(); + } else { + if(theDisplaing == eEraseAll || theDisplaing == eDisplayOnly) + anVISUActor->VisibilityOff(); + else if ( theDisplaing == eDisplayAll ) + anVISUActor->VisibilityOn(); + } } } if (aResActor) { @@ -319,14 +319,14 @@ namespace VISU { } if(thePrs != NULL && theDisplaing < eErase){ try{ - anVISUActor = thePrs->CreateActor(); - vf->AddActor(anVISUActor); + anVISUActor = thePrs->CreateActor(); + vf->AddActor(anVISUActor); }catch(std::exception& exc){ - if(MYDEBUG) INFOS(exc.what()); - return NULL; + if(MYDEBUG) INFOS(exc.what()); + return NULL; }catch(...){ - if(MYDEBUG) INFOS("Unknown exception was occured!!!"); - return NULL; + if(MYDEBUG) INFOS("Unknown exception was occured!!!"); + return NULL; } } RepaintView(theViewWindow); @@ -335,12 +335,12 @@ namespace VISU { struct TUpdatePlot2dEvent: public SALOME_Event { - int myDisplaying; Curve_i* myCurve; + int myDisplaying; - TUpdatePlot2dEvent (const int theDisplaying, Curve_i* theCurve): - myDisplaying(theDisplaying), - myCurve(theCurve) + TUpdatePlot2dEvent (Curve_i* theCurve, const int theDisplaying): + myCurve(theCurve), + myDisplaying(theDisplaying) {} virtual void Execute() @@ -375,7 +375,7 @@ namespace VISU { if (Plot2d_ViewManager* aManager = dynamic_cast(aViewManager)) { if (SPlot2d_Viewer* aViewer = dynamic_cast(aManager->getViewModel())) { if (Plot2d_ViewFrame* aViewFrame = aViewer->getActiveViewFrame()) { - UpdatePlot2d(aViewFrame, myDisplaying, myCurve); + UpdatePlot2d(myCurve, myDisplaying, aViewFrame); } } } @@ -383,128 +383,93 @@ namespace VISU { } }; - void UpdatePlot2d (Plot2d_ViewFrame *theView,int theDisplaying, Curve_i* theCurve) + void UpdatePlot2d (Curve_i* theCurve, int theDisplaying, Plot2d_ViewFrame* theView) { if(MYDEBUG) MESSAGE("UpdatePlot2d - theDisplaying = " << theDisplaying); if (!theView) { // update all views - ProcessVoidEvent(new TUpdatePlot2dEvent(theDisplaying, theCurve)); + ProcessVoidEvent(new TUpdatePlot2dEvent(theCurve, theDisplaying)); return; } QList clist; theView->getCurves(clist); if (theDisplaying == eEraseAll) { for (int i = 0; i < clist.count(); i++) { - if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing all : curve - " << clist.at(i)); - theView->eraseCurve(clist.at(i)); + if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing all : curve - " << clist.at(i)); + theView->eraseCurve(clist.at(i)); } } else if (theDisplaying == eErase) { if (theCurve) { - for (int i = 0; i < clist.count(); i++) { - SPlot2d_Curve* aSPlot2dC = dynamic_cast(clist.at(i)); - if (aSPlot2dC->hasIO() && - !strcmp(theCurve->GetEntry().c_str(), aSPlot2dC->getIO()->getEntry())) { - if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - " << aSPlot2dC); - theView->eraseCurve(aSPlot2dC); - } - } - } - } else if (theDisplaying == eDisplay) { - if (theCurve) { - bool bFound = false; - for (int i = 0; i < clist.count(); i++) { - SPlot2d_Curve* aSPlot2dC = dynamic_cast(clist.at(i)); - if (aSPlot2dC->hasIO() && - !strcmp(theCurve->GetEntry().c_str(), aSPlot2dC->getIO()->getEntry())) { - if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - " << aSPlot2dC); - aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() ); - aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() ); - aSPlot2dC->setHorUnits( theCurve->GetHorUnits().c_str() ); - aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() ); - double* xList = 0; - double* yList = 0; - QStringList zList; - int nbPoints = theCurve->GetData( xList, yList, zList ); - if (nbPoints > 0 && xList && yList) { - aSPlot2dC->setData( xList, yList, nbPoints, zList ); - } - if (!theCurve->IsAuto()) { - aSPlot2dC->setLine((Plot2d::LineType)theCurve->GetLine(), - theCurve->GetLineWidth()); - aSPlot2dC->setMarker((Plot2d::MarkerType)theCurve->GetMarker()); - SALOMEDS::Color color = theCurve->GetColor(); - aSPlot2dC->setColor(QColor((int)(color.R*255.), - (int)(color.G*255.), - (int)(color.B*255.))); - } - aSPlot2dC->setAutoAssign(theCurve->IsAuto()); - theView->displayCurve(aSPlot2dC); - bFound = true; - } - } - if (!bFound) { - Plot2d_Curve* crv = theCurve->CreatePresentation(); - if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<displayCurve( crv ); - theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() ); - theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker()); - SALOMEDS::Color newColor; - newColor.R = crv->getColor().red()/255.; - newColor.G = crv->getColor().green()/255.; - newColor.B = crv->getColor().blue()/255.; - theCurve->SetColor( newColor ); - crv->setAutoAssign( theCurve->IsAuto() ); - } - } + for (int i = 0; i < clist.count(); i++) { + SPlot2d_Curve* aSPlot2dC = dynamic_cast(clist.at(i)); + if (aSPlot2dC->hasIO() && + !strcmp(theCurve->GetEntry().c_str(), aSPlot2dC->getIO()->getEntry())) { + if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - " << aSPlot2dC); + theView->eraseCurve(aSPlot2dC); + } + } } - } else if (theDisplaying == eDisplayOnly) { + } else if (theDisplaying == eDisplay || + theDisplaying == eDisplayOnly || + theDisplaying == eUpdateData) { if (theCurve) { - bool bFound = false; - for (int i = 0; i < clist.count(); i++) { - SPlot2d_Curve* aSPlot2dC = dynamic_cast(clist.at(i)); - if (aSPlot2dC->hasIO() && - !strcmp(theCurve->GetEntry().c_str(), aSPlot2dC->getIO()->getEntry())) { - if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - " << aSPlot2dC); - aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() ); - aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() ); - aSPlot2dC->setHorUnits( theCurve->GetHorUnits().c_str() ); - aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() ); - double* xList = 0; - double* yList = 0; - QStringList zList; - int nbPoints = theCurve->GetData( xList, yList, zList ); - if ( nbPoints > 0 && xList && yList ) { - aSPlot2dC->setData( xList, yList, nbPoints, zList ); - } - if ( !theCurve->IsAuto() ) { - aSPlot2dC->setLine((Plot2d::LineType)theCurve->GetLine(), theCurve->GetLineWidth()); - aSPlot2dC->setMarker((Plot2d::MarkerType)theCurve->GetMarker()); - SALOMEDS::Color color = theCurve->GetColor(); - aSPlot2dC->setColor(QColor((int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.))); - } - aSPlot2dC->setAutoAssign(theCurve->IsAuto()); - theView->displayCurve(aSPlot2dC); - bFound = true; - } else { - theView->eraseCurve(aSPlot2dC); - } - } - if (!bFound) { - Plot2d_Curve* crv = theCurve->CreatePresentation(); - if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - " << crv); - if (crv) { - theView->displayCurve(crv); - theCurve->SetLine((VISU::Curve::LineType)crv->getLine(), crv->getLineWidth()); - theCurve->SetMarker((VISU::Curve::MarkerType)crv->getMarker()); - SALOMEDS::Color newColor; - newColor.R = crv->getColor().red()/255.; - newColor.G = crv->getColor().green()/255.; - newColor.B = crv->getColor().blue()/255.; - theCurve->SetColor(newColor); - crv->setAutoAssign(theCurve->IsAuto()); - } - } + bool bFound = false; + for (int i = 0; i < clist.count(); i++) { + SPlot2d_Curve* aSPlot2dC = dynamic_cast(clist.at(i)); + if (aSPlot2dC->hasIO() && + !strcmp(theCurve->GetEntry().c_str(), aSPlot2dC->getIO()->getEntry())) { + if (theDisplaying == eUpdateData) { + if(MYDEBUG) MESSAGE("UpdatePlot2d - updating data : curve - " << aSPlot2dC); + } + else { + if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - " << aSPlot2dC); + } + double* xList = 0; + double* yList = 0; + QStringList zList; + int nbPoints = theCurve->GetData( xList, yList, zList ); + if (nbPoints > 0 && xList && yList) { + aSPlot2dC->setData( xList, yList, nbPoints, zList ); + } + if (theDisplaying == eUpdateData) { + theView->updateCurve(aSPlot2dC, true); + } else { + aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() ); + aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() ); + aSPlot2dC->setHorUnits( theCurve->GetHorUnits().c_str() ); + aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() ); + if (!theCurve->IsAuto()) { + aSPlot2dC->setLine((Plot2d::LineType)theCurve->GetLine(), + theCurve->GetLineWidth()); + aSPlot2dC->setMarker((Plot2d::MarkerType)theCurve->GetMarker()); + SALOMEDS::Color color = theCurve->GetColor(); + aSPlot2dC->setColor(QColor((int)(color.R*255.), + (int)(color.G*255.), + (int)(color.B*255.))); + } + aSPlot2dC->setAutoAssign(theCurve->IsAuto()); + theView->displayCurve(aSPlot2dC); + bFound = true; + } + } else if (theDisplaying == eDisplayOnly) { + theView->eraseCurve(aSPlot2dC); + } + } + if (!bFound && theDisplaying != eUpdateData) { + Plot2d_Curve* crv = theCurve->CreatePresentation(); + if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<displayCurve( crv ); + theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() ); + theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker()); + SALOMEDS::Color newColor; + newColor.R = crv->getColor().red()/255.; + newColor.G = crv->getColor().green()/255.; + newColor.B = crv->getColor().blue()/255.; + theCurve->SetColor( newColor ); + crv->setAutoAssign( theCurve->IsAuto() ); + } + } } } } @@ -595,18 +560,18 @@ namespace VISU { QList anApplications = aSession->applications(); QList::Iterator anIter = anApplications.begin(); while ( anIter != anApplications.end() ) { - SUIT_Application* aSUITApp = *anIter; - if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) { + SUIT_Application* aSUITApp = *anIter; + if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) { if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { if (_PTR(Study) aCStudy = aStudy->studyDS()) { if (aStudyName == aCStudy->Name()) { anApp = dynamic_cast(aSUITApp); - break; - } - } - } + break; + } + } + } } - anIter++; + anIter++; } if (!anApp) return; @@ -636,23 +601,23 @@ namespace VISU { QList::Iterator anVMIter = aViewManagerList.begin(); for (; anVMIter != aViewManagerList.end(); anVMIter++ ) { SUIT_ViewManager* aViewManager = *anVMIter; - QVector aViews = aViewManager->getViews(); - for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) { - if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) { - if (Plot2d_ViewWindow* vw = dynamic_cast(aViewWindow)) { + QVector aViews = aViewManager->getViews(); + for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) { + if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) { + if (Plot2d_ViewWindow* vw = dynamic_cast(aViewWindow)) { Plot2d_ViewFrame* vf = vw->getViewFrame(); - QList clist; - vf->getCurves(clist); - for (int i = 0; i < clist.count(); i++) { + QList clist; + vf->getCurves(clist); + for (int i = 0; i < clist.count(); i++) { if (SPlot2d_Curve* cu = dynamic_cast(clist.at(i))) { - if (cu->hasIO() && - strcmp(myPrs->GetEntry().c_str(), cu->getIO()->getEntry())) { - vf->eraseCurve(cu); - } - } - } - vf->Repaint(); - //jfa tmp:aViewFrame->unHighlightAll(); + if (cu->hasIO() && + strcmp(myPrs->GetEntry().c_str(), cu->getIO()->getEntry())) { + vf->eraseCurve(cu); + } + } + } + vf->Repaint(); + //jfa tmp:aViewFrame->unHighlightAll(); } } } @@ -680,10 +645,10 @@ namespace VISU { if (_PTR(Study) aCStudy = aStudy->studyDS()) { if (aStudyName == aCStudy->Name()) { anApp = dynamic_cast(aSUITApp); - break; - } - } - } + break; + } + } + } } } if (!anApp) @@ -716,21 +681,21 @@ namespace VISU { SUIT_ViewManager* aViewManager = anVMIter.current(); QPtrVector aViews = aViewManager->getViews(); for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) { - if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) { - if (Plot2d_ViewWindow* vw = dynamic_cast(aViewWindow)) { + if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) { + if (Plot2d_ViewWindow* vw = dynamic_cast(aViewWindow)) { Plot2d_ViewFrame* vf = vw->getViewFrame(); QList clist; vf->getCurves(clist); - for (int i = 0; i < clist.count(); i++) { + for (int i = 0; i < clist.count(); i++) { if (SPlot2d_Curve* cu = dynamic_cast(clist.at(i))) { - if (cu->hasIO() && - strcmp(cu->getIO()->getEntry(), thePrs->GetEntry()) == 0) { - vf->eraseCurve(cu); - } - } - } - vf->Repaint(); - //jfa tmp:aViewFrame->unHighlightAll(); + if (cu->hasIO() && + strcmp(cu->getIO()->getEntry(), thePrs->GetEntry()) == 0) { + vf->eraseCurve(cu); + } + } + } + vf->Repaint(); + //jfa tmp:aViewFrame->unHighlightAll(); } } } @@ -756,10 +721,10 @@ namespace VISU { if (_PTR(Study) aCStudy = aStudy->studyDS()) { if (aStudyName == aCStudy->Name()) { anApp = dynamic_cast(aSUITApp); - break; - } - } - } + break; + } + } + } } anIter++; } @@ -793,22 +758,22 @@ namespace VISU { SUIT_ViewManager* aViewManager = *anVMIter; QVector aViews = aViewManager->getViews(); for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) { - if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) { - if (SVTK_ViewWindow* vw = dynamic_cast(aViewWindow)) { + if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) { + if (SVTK_ViewWindow* vw = dynamic_cast(aViewWindow)) { VISU_Actor* anActor = NULL; - VTK::ActorCollectionCopy aCopy(vw->getRenderer()->GetActors()); + VTK::ActorCollectionCopy aCopy(vw->getRenderer()->GetActors()); vtkActorCollection *anActColl = aCopy.GetActors(); - anActColl->InitTraversal(); + anActColl->InitTraversal(); vtkActor *aVTKActor = anActColl->GetNextActor(); - for (; !anActor && aVTKActor; aVTKActor = anActColl->GetNextActor()) { + for (; !anActor && aVTKActor; aVTKActor = anActColl->GetNextActor()) { if (VISU_Actor* anVISUActor = dynamic_cast(aVTKActor)) { - if (thePrs == anVISUActor->GetPrs3d()) { - anActor = anVISUActor; + if (thePrs == anVISUActor->GetPrs3d()) { + anActor = anVISUActor; } } } if (anActor) { - vw->RemoveActor(anActor); + vw->RemoveActor(anActor); } } } diff --git a/src/VISU_I/VISU_ViewManager_i.hh b/src/VISU_I/VISU_ViewManager_i.hh index 6824f1c0..b951d461 100644 --- a/src/VISU_I/VISU_ViewManager_i.hh +++ b/src/VISU_I/VISU_ViewManager_i.hh @@ -72,9 +72,9 @@ namespace VISU { void RepaintView (SUIT_ViewWindow* theViewWindow); - enum Displaing {eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll}; + enum Displaing {eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll, eUpdateData}; VISU_I_EXPORT VISU_Actor* UpdateViewer (SUIT_ViewWindow* theViewWindow, int theDisplaing, Prs3d_i* thePrs = NULL); - void UpdatePlot2d (Plot2d_ViewFrame *theView, int theDisplaying, Curve_i* theCurve); + void UpdatePlot2d (Curve_i* theCurve, int theDisplaying, Plot2d_ViewFrame* theView = NULL); VISU_I_EXPORT VISU_Actor* FindActor(SVTK_ViewWindow* theViewWindow, VISU::Prs3d_i* thePrs3d); VISU_I_EXPORT VISU_ActorBase* FindActorBase(SVTK_ViewWindow* theViewWindow, VISU::TActorFactory* theActor); diff --git a/src/VISU_I/VISU_View_i.cc b/src/VISU_I/VISU_View_i.cc index 9ef00c68..51aed177 100644 --- a/src/VISU_I/VISU_View_i.cc +++ b/src/VISU_I/VISU_View_i.cc @@ -1336,7 +1336,7 @@ namespace VISU { { // is it Curve ? if (Curve_i* aCurve = dynamic_cast(VISU::GetServant(myPrsObj).in())) { - UpdatePlot2d(myView,myDisplaing,aCurve); + UpdatePlot2d(aCurve,myDisplaing,myView); } // is it Container ? if (Container_i* aContainer = dynamic_cast(VISU::GetServant(myPrsObj).in())) { @@ -1344,7 +1344,7 @@ namespace VISU { for ( int i = 1; i <= nbCurves; i++ ) { VISU::Curve_i* aCurve = aContainer->GetCurve( i ); if ( aCurve && aCurve->IsValid() ) { - UpdatePlot2d(myView,myDisplaing,aCurve); + UpdatePlot2d(aCurve,myDisplaing,myView); } } myView->Repaint(); @@ -1366,8 +1366,8 @@ namespace VISU { if (!CORBA::is_nil(childObject)) { CORBA::Object_ptr aCurve = VISU::Curve::_narrow(childObject); if (!CORBA::is_nil(aCurve)) - UpdatePlot2d(myView, myDisplaing, - dynamic_cast(VISU::GetServant(aCurve).in())); + UpdatePlot2d(dynamic_cast(VISU::GetServant(aCurve).in()), + myDisplaing, myView); } } myView->Repaint();