From: ouv Date: Wed, 31 Mar 2010 08:00:36 +0000 (+0000) Subject: Issue 0020665: [CEA 388] VISU2D :: right Y axis X-Git-Tag: V5_1_main_20100401 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=861a197c1b09b6164ea53cdb45f8226bf64388b1;p=modules%2Fvisu.git Issue 0020665: [CEA 388] VISU2D :: right Y axis --- diff --git a/doc/salome/gui/VISU/images/axis_bottom_left.png b/doc/salome/gui/VISU/images/axis_bottom_left.png new file mode 100644 index 00000000..97a9a279 Binary files /dev/null and b/doc/salome/gui/VISU/images/axis_bottom_left.png differ diff --git a/doc/salome/gui/VISU/images/axis_bottom_right.png b/doc/salome/gui/VISU/images/axis_bottom_right.png new file mode 100644 index 00000000..a7d1f156 Binary files /dev/null and b/doc/salome/gui/VISU/images/axis_bottom_right.png differ diff --git a/doc/salome/gui/VISU/images/createcurves.png b/doc/salome/gui/VISU/images/createcurves.png index 20b93a38..6ae91d76 100644 Binary files a/doc/salome/gui/VISU/images/createcurves.png and b/doc/salome/gui/VISU/images/createcurves.png differ diff --git a/doc/salome/gui/VISU/input/creating_curves.doc b/doc/salome/gui/VISU/input/creating_curves.doc index 040eb240..71c6d5d0 100644 --- a/doc/salome/gui/VISU/input/creating_curves.doc +++ b/doc/salome/gui/VISU/input/creating_curves.doc @@ -24,12 +24,22 @@ the data table by checking them in the \b Axis part of the dialog box: The column \b Assigned allows to represent the values assigned to the -points of the curve (possible for V-rows only). Any row, even +points of the curve (possible for V- and V2-rows only). Any row, even coinciding with the current or empty (no values assigned), can be represented. All values are indicated with tool tips over the corresponding curve points in the Plot2d viewer. diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index c5e40f34..544dad9b 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -2478,8 +2478,8 @@ module VISU { /*! * Creates a curve on the basis of points, whose values are taken from the table. * \param theTable Table containing the data for construction of curves. - * \param HRow Index of the row in the table: abscissa of the point. - * \param VRow Index of the row in the table: ordinate of the point. + * \param theHRow Index of the row in the table: abscissa of the point. + * \param theVRow Index of the row in the table: ordinate of the point. */ Curve CreateCurve(in Table theTable, in long theHRow, in long theVRow); @@ -2487,12 +2487,25 @@ module VISU { * Creates a curve on the basis of points, whose values are taken from the table. * Each point has also assigned value, that will be shown as tooltip in Plot2d * \param theTable Table containing the data for construction of curves. - * \param HRow Index of the row in the table: abscissa of the point. - * \param VRow Index of the row in the table: ordinate of the point. - * \param ZRow Index of the row in the table: assigned value (so-called as Z). + * \param theHRow Index of the row in the table: abscissa of the point. + * \param theVRow Index of the row in the table: ordinate of the point. + * \param theZRow Index of the row in the table: assigned value (so-called as Z). */ Curve CreateCurveWithZ( in Table theTable, in long theHRow, in long theVRow, in long theZRow ); + /*! + * Creates a curve on the basis of points, whose values are taken from the table. + * Each point has also assigned value, that will be shown as tooltip in Plot2d. + * The curve can be displayed using right axis of Plot2d view. + * \param theTable Table containing the data for construction of curves. + * \param theHRow Index of the row in the table: abscissa of the point. + * \param theVRow Index of the row in the table: ordinate of the point. + * \param theZRow Index of the row in the table: assigned value (so-called as Z). + * \param theIsV2 Flag allowed to display the curve using right axis of Plot2d view. + */ + Curve CreateCurveWithZExt( in Table theTable, in long theHRow, in long theVRow, in long theZRow, + in boolean theIsV2 ); + /*! * Creates a presentation form containing an array of references to the curves. */ diff --git a/src/ENGINE/VISU_Engine_i.cc b/src/ENGINE/VISU_Engine_i.cc index 291258e4..ef22469f 100644 --- a/src/ENGINE/VISU_Engine_i.cc +++ b/src/ENGINE/VISU_Engine_i.cc @@ -406,6 +406,14 @@ namespace VISU{ return myVisuGen->CreateCurveWithZ(theTable,theHRow,theVRow,theZRow); } + Curve_ptr VISU_Gen_i::CreateCurveWithZExt(Table_ptr theTable, + CORBA::Long theHRow, + CORBA::Long theVRow, + CORBA::Long theZRow, + CORBA::Boolean theIsV2) + { + return myVisuGen->CreateCurveWithZExt(theTable,theHRow,theVRow,theZRow,theIsV2); + } Container_ptr VISU_Gen_i::CreateContainer(){ return myVisuGen->CreateContainer(); diff --git a/src/ENGINE/VISU_Engine_i.hh b/src/ENGINE/VISU_Engine_i.hh index ecf428c2..d921aa37 100644 --- a/src/ENGINE/VISU_Engine_i.hh +++ b/src/ENGINE/VISU_Engine_i.hh @@ -188,6 +188,8 @@ namespace VISU virtual Table_ptr CreateTable(const char* theTableEntry); virtual Curve_ptr CreateCurve(Table_ptr theTable, CORBA::Long theHRow, CORBA::Long theVRow); virtual Curve_ptr CreateCurveWithZ(Table_ptr theTable, CORBA::Long theHRow, CORBA::Long theVRow, CORBA::Long theZRow); + virtual Curve_ptr CreateCurveWithZExt(Table_ptr theTable, CORBA::Long theHRow, CORBA::Long theVRow, CORBA::Long theZRow, + CORBA::Boolean theIsV2); virtual Container_ptr CreateContainer(); virtual Animation_ptr CreateAnimation(View3D_ptr theView3d); virtual Evolution_ptr CreateEvolution(XYPlot_ptr theXYPlot); diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 330f6317..febb52c1 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -1744,14 +1744,16 @@ VisuGUI // if study is not locked - create new container, create curves and insert them // into container, then plot container if current viewer is of VIEW_PLOT2D type int horIndex; - QList verIndices, zIndices; - aDlg->getCurvesSource( horIndex, verIndices, zIndices ); + QList verIndices, ver1Indices, ver2Indices, zIndices; + aDlg->getCurvesSource( horIndex, ver1Indices, ver2Indices, zIndices ); + verIndices = ver1Indices + ver2Indices; if( horIndex >= 0 && verIndices.count() > 0 ){ CORBA::Object_var aContainerObj = GetVisuGen(this)->CreateContainer(); if(VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aContainerObj).in())){ for( int i = 0; i < verIndices.count(); i++ ){ + bool isV2 = ver2Indices.contains(verIndices[i]); VISU::Curve_var aCurveObject = - GetVisuGen(this)->CreateCurveWithZ(aTable->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1 ); + GetVisuGen(this)->CreateCurveWithZExt(aTable->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1, isV2 ); if(VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aCurveObject).in())){ bool isAuto; int marker, line, lineWidth; @@ -1807,16 +1809,18 @@ VisuGUI // if study is not locked - create new table and container objects, create curves // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type int horIndex; - QList verIndices, zIndices; - aDlg->getCurvesSource( horIndex, verIndices, zIndices ); + QList verIndices, ver1Indices, ver2Indices, zIndices; + aDlg->getCurvesSource( horIndex, verIndices, ver2Indices, zIndices ); + verIndices = ver1Indices + ver2Indices; if ( horIndex >= 0 && verIndices.count() > 0 ) { VISU::Table_var aTableObject = GetVisuGen(this)->CreateTable(aSObject->GetID().c_str()); if(!CORBA::is_nil(aTableObject)){ VISU::Container_var aContainerObject = GetVisuGen(this)->CreateContainer(); VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aContainerObject).in()); for ( int i = 0; i < verIndices.count(); i++ ) { - VISU::Curve_var aCurveObject = GetVisuGen(this)->CreateCurveWithZ - ( aTableObject, horIndex+1, verIndices[i]+1, zIndices[i]+1 ); + bool isV2 = ver2Indices.contains(verIndices[i]); + VISU::Curve_var aCurveObject = GetVisuGen(this)->CreateCurveWithZExt + ( aTableObject, horIndex+1, verIndices[i]+1, zIndices[i]+1, isV2 ); if(VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aCurveObject).in())){ bool isAuto; int marker, line, lineWidth; diff --git a/src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx b/src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx index a12fad46..2ac7f567 100644 --- a/src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx +++ b/src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx @@ -108,24 +108,24 @@ VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, QWidget* p labUnit->setFont( font ); labAttr->setFont( font ); - frameLayout->addWidget( labAxis, 0, 0, 1, 2 ); + frameLayout->addWidget( labAxis, 0, 0, 1, 3 ); lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); - frameLayout->addWidget( lin, 0, 2 ); + frameLayout->addWidget( lin, 0, 3 ); - frameLayout->addWidget( labAssigned, 0, 3 ); + frameLayout->addWidget( labAssigned, 0, 4 ); lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); - frameLayout->addWidget( lin, 0, 4 ); + frameLayout->addWidget( lin, 0, 5 ); - frameLayout->addWidget( labData, 0, 5 ); + frameLayout->addWidget( labData, 0, 6 ); lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); - frameLayout->addWidget( lin, 0, 6 ); - frameLayout->addWidget( labUnit, 0, 7 ); + frameLayout->addWidget( lin, 0, 7 ); + frameLayout->addWidget( labUnit, 0, 8 ); lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); - frameLayout->addWidget( lin, 0, 8 ); - frameLayout->addWidget( labAttr, 0, 9, 1, 5 ); - //frameLayout->setColStretch( 14, 5 ); + frameLayout->addWidget( lin, 0, 9 ); + frameLayout->addWidget( labAttr, 0, 10, 1, 5 ); + //frameLayout->setColStretch( 15, 5 ); lin = new QFrame( frame ); lin->setFrameStyle( QFrame::HLine | QFrame::Sunken ); - frameLayout->addWidget( lin, 1, 0, 1, 15 ); + frameLayout->addWidget( lin, 1, 0, 1, 16 ); int row = 2; _PTR(GenericAttribute) anAttr; @@ -149,21 +149,23 @@ VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, QWidget* p item->createWidgets( frame, rows ); frameLayout->addWidget( item->myHBtn, row, 0 ); frameLayout->addWidget( item->myVBtn, row, 1 ); - frameLayout->addWidget( item->myAssigned, row, 3 ); + frameLayout->addWidget( item->myV2Btn, row, 2 ); + frameLayout->addWidget( item->myAssigned, row, 4 ); - frameLayout->addWidget( item->myTitleLab, row, 5 ); + frameLayout->addWidget( item->myTitleLab, row, 6 ); if ( rowTitles.size() > 0 ) item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) ); - frameLayout->addWidget( item->myUnitLab, row, 7 ); + frameLayout->addWidget( item->myUnitLab, row, 8 ); if ( rowUnits.size() > 0 ) item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) ); - frameLayout->addWidget( item->myAutoCheck, row, 9 ); - frameLayout->addWidget( item->myLineCombo, row, 10 ); - frameLayout->addWidget( item->myLineSpin, row, 11 ); - frameLayout->addWidget( item->myMarkerCombo, row, 12 ); - frameLayout->addWidget( item->myColorBtn, row, 13 ); + frameLayout->addWidget( item->myAutoCheck, row, 10 ); + frameLayout->addWidget( item->myLineCombo, row, 11 ); + frameLayout->addWidget( item->myLineSpin, row, 12 ); + frameLayout->addWidget( item->myMarkerCombo, row, 13 ); + frameLayout->addWidget( item->myColorBtn, row, 14 ); connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) ); connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) ); + connect( item, SIGNAL( ver2Toggled( bool ) ), this, SLOT( onV2BtnToggled( bool ) ) ); myItems.append( item ); row++; } @@ -190,21 +192,23 @@ VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, QWidget* p item->createWidgets( frame, rows ); frameLayout->addWidget( item->myHBtn, row, 0 ); frameLayout->addWidget( item->myVBtn, row, 1 ); - frameLayout->addWidget( item->myAssigned, row, 3 ); + frameLayout->addWidget( item->myV2Btn, row, 2 ); + frameLayout->addWidget( item->myAssigned, row, 4 ); - frameLayout->addWidget( item->myTitleLab, row, 5 ); + frameLayout->addWidget( item->myTitleLab, row, 6 ); if ( rowTitles.size() > 0 ) item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) ); - frameLayout->addWidget( item->myUnitLab, row, 7 ); + frameLayout->addWidget( item->myUnitLab, row, 8 ); if ( rowUnits.size() > 0 ) item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) ); - frameLayout->addWidget( item->myAutoCheck, row, 9 ); - frameLayout->addWidget( item->myLineCombo, row, 10 ); - frameLayout->addWidget( item->myLineSpin, row, 11 ); - frameLayout->addWidget( item->myMarkerCombo, row, 12 ); - frameLayout->addWidget( item->myColorBtn, row, 13 ); + frameLayout->addWidget( item->myAutoCheck, row, 10 ); + frameLayout->addWidget( item->myLineCombo, row, 11 ); + frameLayout->addWidget( item->myLineSpin, row, 12 ); + frameLayout->addWidget( item->myMarkerCombo, row, 13 ); + frameLayout->addWidget( item->myColorBtn, row, 14 ); connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) ); connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) ); + connect( item, SIGNAL( ver2Toggled( bool ) ), this, SLOT( onV2BtnToggled( bool ) ) ); myItems.append( item ); row++; } @@ -215,11 +219,11 @@ VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, QWidget* p } } lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); - frameLayout->addWidget( lin, 2, 2, row, 1 ); + frameLayout->addWidget( lin, 2, 3, row, 1 ); lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); - frameLayout->addWidget( lin, 2, 4, row, 1 ); + frameLayout->addWidget( lin, 2, 5, row, 1 ); lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); - frameLayout->addWidget( lin, 2, 6, row, 1 ); + frameLayout->addWidget( lin, 2, 7, row, 1 ); //frameLayout->setRowStretch( row+1, 5 ); myView->setWidget( frame ); @@ -263,7 +267,7 @@ VisuGUI_SetupPlot2dDlg::~VisuGUI_SetupPlot2dDlg() Gets curves info ( indexes of row data in the table for horizontal and verical axes ) */ void VisuGUI_SetupPlot2dDlg::getCurvesSource( int& horIndex, QList& verIndexes, - QList& zIndices ) + QList& ver2Indexes, QList& zIndices ) { /* collecting horizontal and vertical axis items */ horIndex = -1; @@ -272,11 +276,15 @@ void VisuGUI_SetupPlot2dDlg::getCurvesSource( int& horIndex, QList& verInde if ( myItems.at( i )->isHorizontalOn() ) { horIndex = i; } - else if ( myItems.at( i )->isVerticalOn() ) { - verIndexes.append( i ); + else { + if ( myItems.at( i )->isVerticalOn() ) { + verIndexes.append( i ); + } + else if ( myItems.at( i )->isVertical2On() ) { + ver2Indexes.append( i ); + } zIndices.append( myItems.at( i )->assigned() ); } - } } /*! @@ -314,9 +322,9 @@ void VisuGUI_SetupPlot2dDlg::getCurves( QList& container ) /* collecting horizontal and vertical axis items */ int horIndex; int i, j; - QList verIndex, zIndices; - getCurvesSource( horIndex, verIndex, zIndices ); - if ( horIndex < 0 || verIndex.isEmpty() ) /* no curves can be created */ + QList verIndex, ver2Index, zIndices; + getCurvesSource( horIndex, verIndex, ver2Index, zIndices ); + if ( horIndex < 0 || verIndex.isEmpty() && ver2Index.isEmpty() ) /* no curves can be created */ return; /* Try table of integer */ @@ -484,6 +492,48 @@ void VisuGUI_SetupPlot2dDlg::onVBtnToggled( bool on ) } enableControls(); } +/*! + Slot, called when any button is clicked +*/ +void VisuGUI_SetupPlot2dDlg::onV2BtnToggled( bool on ) +{ + VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender(); + QList itemList; + //itemList.setAutoDelete( false ); + item->myAssigned->setEnabled( on ); + int i; + if ( on ) { + int totalOn = 0; + for ( i = 0; i < myItems.count(); i++ ) { + if ( myItems.at( i ) != item && !myItems.at( i )->isHorizontalOn() ) { + if ( myItems.at( i )->myUnitLab->text() == item->myUnitLab->text() ) { + if ( myItems.at( i )->isVertical2On() ) + totalOn++; + else + itemList.append( myItems.at( i ) ); + } + else { + myItems.at( i )->setVertical2On( false ); + } + } + } + if ( totalOn == 0 && !itemList.isEmpty() && + SUIT_MessageBox::information( this, + this->windowTitle(), + tr( "QUE_WANT_SAME_UNITS" ), + tr( "BUT_YES" ), + tr( "BUT_NO" ), + 1, 1 ) == 0 ) + { + for ( i = 0; i < itemList.count(); i++ ) { + itemList.at( i )->blockSignals( true ); + itemList.at( i )->setVertical2On( true ); + itemList.at( i )->blockSignals( false ); + } + } + } + enableControls(); +} /*! Slot, called when button is clicked */ @@ -522,9 +572,10 @@ void VisuGUI_SetupPlot2dDlg::enableControls() } } for ( int i = 0; i < myItems.count(); i++ ) { - if ( myItems.at( i )->isVerticalOn() ) + bool isVOn = myItems.at( i )->isVerticalOn() || myItems.at( i )->isVertical2On(); + if ( isVOn ) bVSet = true; - myItems.at( i )->enableWidgets( bHSet && myItems.at( i )->isVerticalOn() ); + myItems.at( i )->enableWidgets( bHSet && isVOn ); } myOkBtn->setEnabled( bHSet && bVSet ); } @@ -569,6 +620,11 @@ void VisuGUI_ItemContainer::createWidgets( QWidget* parentWidget, const QStringL myVBtn->setCheckable( true ); myVBtn->setChecked( false ); + myV2Btn = new QToolButton( parentWidget ); + myV2Btn->setText( tr( "V2" ) ); + myV2Btn->setCheckable( true ); + myV2Btn->setChecked( false ); + myTitleLab = new QLabel( parentWidget ); myUnitLab = new QLabel( parentWidget ); myUnitLab->setAlignment( Qt::AlignCenter); @@ -618,6 +674,7 @@ void VisuGUI_ItemContainer::createWidgets( QWidget* parentWidget, const QStringL //connect( myColorBtn, SIGNAL( clicked() ), this, SLOT( onColorChanged() ) ); connect( myHBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) ); connect( myVBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) ); + connect( myV2Btn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) ); setColor( QColor( 0, 0, 0 ) ); updateState(); } @@ -644,19 +701,33 @@ bool VisuGUI_ItemContainer::isHorizontalOn() const return myHBtn->isChecked(); } /*! - Sets vertical button's state on + Sets first vertical button's state on */ void VisuGUI_ItemContainer::setVerticalOn( bool on ) { myVBtn->setChecked( on ); } /*! - Gets vertical button's state + Gets first vertical button's state */ bool VisuGUI_ItemContainer::isVerticalOn() const { return myVBtn->isChecked(); } +/*! + Sets second vertical button's state on +*/ +void VisuGUI_ItemContainer::setVertical2On( bool on ) +{ + myV2Btn->setChecked( on ); +} +/*! + Gets second vertical button's state +*/ +bool VisuGUI_ItemContainer::isVertical2On() const +{ + return myV2Btn->isChecked(); +} /*! Sets item AutoAssign flag state */ @@ -764,21 +835,46 @@ void VisuGUI_ItemContainer::onHVToggled( bool on ) if ( myVBtn->isChecked() ) { // blockSignals( true ); myVBtn->setChecked( false ); +// blockSignals( false ); + } + else if ( myV2Btn->isChecked() ) { +// blockSignals( true ); + myV2Btn->setChecked( false ); // blockSignals( false ); } } emit horToggled( on ); } - else { + else if ( snd == myVBtn ) { if ( on ) { if ( myHBtn->isChecked() ) { // blockSignals( true ); myHBtn->setChecked( false ); +// blockSignals( false ); + } + else if ( myV2Btn->isChecked() ) { +// blockSignals( true ); + myV2Btn->setChecked( false ); // blockSignals( false ); } } emit verToggled( on ); } + else { + if ( on ) { + if ( myHBtn->isChecked() ) { +// blockSignals( true ); + myHBtn->setChecked( false ); +// blockSignals( false ); + } + else if ( myVBtn->isChecked() ) { +// blockSignals( true ); + myVBtn->setChecked( false ); +// blockSignals( false ); + } + } + emit ver2Toggled( on ); + } } /*! @@ -786,7 +882,7 @@ void VisuGUI_ItemContainer::onHVToggled( bool on ) */ int VisuGUI_ItemContainer::assigned() const { - if( isVerticalOn() ) + if( isVerticalOn() || isVertical2On() ) return myAssigned->currentIndex()-1; else return -1; diff --git a/src/VISUGUI/VisuGUI_SetupPlot2dDlg.h b/src/VISUGUI/VisuGUI_SetupPlot2dDlg.h index 985c34f7..d530402e 100644 --- a/src/VISUGUI/VisuGUI_SetupPlot2dDlg.h +++ b/src/VISUGUI/VisuGUI_SetupPlot2dDlg.h @@ -57,7 +57,7 @@ public: ~VisuGUI_SetupPlot2dDlg(); void getCurves( QList& container ); - void getCurvesSource( int& horIndex, QList& verIndexes, QList& zIndexes ); + void getCurvesSource( int& horIndex, QList& verIndexes, QList& ver2Indexes, QList& zIndexes ); bool getCurveAttributes( const int vIndex, bool& isAuto, int& marker, int& line, int& lineWidth, QColor& color); private: @@ -66,6 +66,7 @@ private: private slots: void onHBtnToggled( bool ); void onVBtnToggled( bool ); + void onV2BtnToggled( bool ); void onHelp(); void enableControls(); @@ -93,6 +94,8 @@ public: bool isHorizontalOn() const; void setVerticalOn( bool on ); bool isVerticalOn() const; + void setVertical2On( bool on ); + bool isVertical2On() const; bool isAutoAssign() const; void setAutoAssign( bool on ); void setLine( const int line, const int width ); @@ -111,6 +114,7 @@ signals: void autoClicked(); void horToggled( bool ); void verToggled( bool ); + void ver2Toggled( bool ); public slots: void onAutoChanged(); @@ -121,6 +125,7 @@ public: bool myEnabled; QToolButton* myHBtn; QToolButton* myVBtn; + QToolButton* myV2Btn; QLabel* myTitleLab; QLabel* myUnitLab; QCheckBox* myAutoCheck; diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc index 6ef7dee1..aafb1b5e 100644 --- a/src/VISU_I/VISU_DumpPython.cc +++ b/src/VISU_I/VISU_DumpPython.cc @@ -1560,16 +1560,21 @@ namespace VISU if(Curve_i* aServant = dynamic_cast(GetServant(anObj).in())) { bool withZ = aServant->GetZRow()>0; + bool isV2 = aServant->GetIsV2(); theStr << thePrefix << "aName2ObjectMap['" << aName << "'] = visu.CreateCurve"; - if( withZ ) + if( isV2 ) + theStr << "WithZExt"; + else if( withZ ) theStr << "WithZ"; theStr << "(" << theArgumentName<< // table - ", "<GetHRow()<< // H row - ", "<GetVRow(); // V row - if( withZ ) + ", "<GetHRow()<< // H row + ", "<GetVRow(); // V row + if( withZ || isV2 ) theStr << ", " << aServant->GetZRow(); // Z row + if( isV2 ) + theStr << ", " << aServant->GetIsV2(); // right axis theStr << ", '"<GetTitle()<<"'"; // title SALOMEDS::Color aColor = aServant->GetColor(); diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index 657ab889..c61da4cd 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -1435,7 +1435,7 @@ namespace VISU CORBA::Long theHRow, CORBA::Long theVRow) { - return CreateCurveWithZ( theTable, theHRow, theVRow, 0 ); + return CreateCurveWithZExt( theTable, theHRow, theVRow, 0, false ); } @@ -1446,13 +1446,26 @@ namespace VISU CORBA::Long theHRow, CORBA::Long theVRow, CORBA::Long theZRow) + { + return CreateCurveWithZExt( theTable, theHRow, theVRow, theZRow, false ); + } + + + //--------------------------------------------------------------- + Curve_ptr + VISU_Gen_i + ::CreateCurveWithZExt(Table_ptr theTable, + CORBA::Long theHRow, + CORBA::Long theVRow, + CORBA::Long theZRow, + CORBA::Boolean theIsV2) { if(myStudyDocument->GetProperties()->IsLocked()) return Curve::_nil(); Mutex mt(myMutex); PortableServer::POA_ptr aPOA = GetPOA(); Table_i* pTable = dynamic_cast(aPOA->reference_to_servant(theTable)); - Curve_i* pPresent = new Curve_i(myStudyDocument,pTable,theHRow,theVRow,theZRow); + Curve_i* pPresent = new Curve_i(myStudyDocument,pTable,theHRow,theVRow,theZRow,theIsV2); if(pPresent->Create() != NULL) return pPresent->_this(); else{ @@ -1462,7 +1475,6 @@ namespace VISU } - //--------------------------------------------------------------- Container_ptr VISU_Gen_i diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index 216f0601..b66db20a 100644 --- a/src/VISU_I/VISU_Gen_i.hh +++ b/src/VISU_I/VISU_Gen_i.hh @@ -273,12 +273,21 @@ namespace VISU CreateCurve(Table_ptr theTable, CORBA::Long theHRow, CORBA::Long theVRow); + virtual Curve_ptr CreateCurveWithZ(Table_ptr theTable, - CORBA::Long theHRow, - CORBA::Long theVRow, - CORBA::Long theZRow); + CORBA::Long theHRow, + CORBA::Long theVRow, + CORBA::Long theZRow); + + virtual + Curve_ptr + CreateCurveWithZExt(Table_ptr theTable, + CORBA::Long theHRow, + CORBA::Long theVRow, + CORBA::Long theZRow, + CORBA::Boolean theIsV2); virtual Container_ptr diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index bad23432..530704d8 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -388,9 +388,9 @@ const char* VISU::Curve_i::GetComment() const */ VISU::Curve_i::Curve_i( SALOMEDS::Study_ptr theStudy, Table_i* theTable, CORBA::Long theHRow, CORBA::Long theVRow, - CORBA::Long theZRow ) + CORBA::Long theZRow, CORBA::Boolean theIsV2 ) : PrsObject_i(theStudy), myTable( theTable ), myHRow( theHRow ), - myVRow( theVRow ), myZRow( theZRow ) + myVRow( theVRow ), myZRow( theZRow ), myIsV2( theIsV2 ) { myAuto = true; myLine = VISU::Curve::SOLIDLINE; @@ -777,6 +777,7 @@ int VISU::Curve_i::GetData( double*& theHorList, double*& theVerList, QStringLis SPlot2d_Curve* VISU::Curve_i::CreatePresentation() { SPlot2d_Curve* crv = new SPlot2d_Curve(); + crv->setYAxis( myIsV2 ? QwtPlot::yRight : QwtPlot::yLeft ); crv->setHorTitle( GetHorTitle().c_str() ); string tlt = GetTitle(); if ( tlt.length() <= 0 ) @@ -821,6 +822,9 @@ VISU::Storable* VISU::Curve_i::Restore( const Storable::TRestoringMap& theMap, S bool ok = false; QString z_str = VISU::Storable::FindValue(theMap,"myZRow", &ok); myZRow = ok ? z_str.toInt() : 0; + ok = false; + QString v2_str = VISU::Storable::FindValue(theMap,"myIsV2", &ok); + myIsV2 = ok ? v2_str.toInt() : false; myColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble(); myColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble(); @@ -840,6 +844,7 @@ void VISU::Curve_i::ToStream( std::ostringstream& theStr ) Storable::DataToStream( theStr, "myHRow", myHRow ); Storable::DataToStream( theStr, "myVRow", myVRow ); Storable::DataToStream( theStr, "myZRow", myZRow ); + Storable::DataToStream( theStr, "myIsV2", myIsV2 ); Storable::DataToStream( theStr, "myColor.R", myColor.R ); Storable::DataToStream( theStr, "myColor.G", myColor.G ); Storable::DataToStream( theStr, "myColor.B", myColor.B ); @@ -865,7 +870,7 @@ VISU::Storable* VISU::Curve_i::StorableEngine(SALOMEDS::SObject_ptr theSObject, SALOMEDS::Study_var aStudy = theSObject->GetStudy(); VISU::Table_i* pTable = GetTable(aStudy, theSObject->GetFather()); if( pTable != NULL ) { - VISU::Curve_i* pResent = new VISU::Curve_i( aStudy, pTable, 0, 0, 0 ); + VISU::Curve_i* pResent = new VISU::Curve_i( aStudy, pTable, 0, 0, 0, false ); return pResent->Restore( theMap, theSObject); } return NULL; diff --git a/src/VISU_I/VISU_Table_i.hh b/src/VISU_I/VISU_Table_i.hh index 78c6776a..ca35887d 100644 --- a/src/VISU_I/VISU_Table_i.hh +++ b/src/VISU_I/VISU_Table_i.hh @@ -96,7 +96,8 @@ namespace VISU{ Curve_i( const Curve_i& ); public: Curve_i( SALOMEDS::Study_ptr theStudy, Table_i* theTable, - CORBA::Long theHRow, CORBA::Long theVRow, CORBA::Long theZRow ); + CORBA::Long theHRow, CORBA::Long theVRow, CORBA::Long theZRow, + CORBA::Boolean theIsV2 ); virtual ~Curve_i(); virtual VISU::VISUType GetType() { return VISU::TCURVE;}; @@ -125,6 +126,7 @@ namespace VISU{ int myHRow; int myVRow; int myZRow; + bool myIsV2; struct SALOMEDS::Color myColor; VISU::Curve::MarkerType myMarker; VISU::Curve::LineType myLine; @@ -139,6 +141,7 @@ namespace VISU{ int GetHRow() const { return myHRow;} int GetVRow() const { return myVRow;} int GetZRow() const { return myZRow;} + int GetIsV2() const { return myIsV2;} virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr theSO); diff --git a/src/VISU_SWIG/Makefile.am b/src/VISU_SWIG/Makefile.am index db0513ea..c093a267 100644 --- a/src/VISU_SWIG/Makefile.am +++ b/src/VISU_SWIG/Makefile.am @@ -63,7 +63,8 @@ dist_salomescript_DATA = batchmode_visu.py batchmode_visu_table.py batchmode_vis visu_succcessive_animation.py visu_apply_properties.py visu_apply_properties_successive.py \ batchmode_visu_view.py visu_cache.py visu_pointmap3d.py visu_view3d_parameters.py visu_evolution.py \ VISU_Example_01.py VISU_Example_02.py VISU_Example_03.py VISU_Example_04.py \ - VISU_Example_05.py VISU_Example_06.py VISU_Example_07.py VISU_Example_08.py + VISU_Example_05.py VISU_Example_06.py VISU_Example_07.py VISU_Example_08.py \ + VISU_Example_09.py nodist_salomescript_DATA = libVISU_Swig.py diff --git a/src/VISU_SWIG/VISU_Example_09.py b/src/VISU_SWIG/VISU_Example_09.py new file mode 100644 index 00000000..8e588018 --- /dev/null +++ b/src/VISU_SWIG/VISU_Example_09.py @@ -0,0 +1,89 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Displaying curves attached to different Y axes of Plot2d view +# +import salome +import time +import SALOMEDS +import VISU + +sleep_delay = 1 + +# >>> Getting study builder +myStudy = salome.myStudy +myBuilder = myStudy.NewBuilder() + +# >>> Getting (loading) VISU component +myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") +myComponent = myStudy.FindComponent("VISU") +myVisu.SetCurrentStudy(myStudy) +if not myComponent: + myComponent = myBuilder.NewComponent("VISU") + aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName") + aName.SetValue( salome.sg.getComponentUserName("VISU") ) + + A2 = myBuilder.FindOrCreateAttribute(myComponent, "AttributePixMap"); + aPixmap = A2._narrow(SALOMEDS.AttributePixMap); + aPixmap.SetPixMap( "ICON_OBJBROWSER_Visu" ); + + myBuilder.DefineComponentInstance(myComponent,myVisu) + +# >>> Creating object with Table +aTableObject = myBuilder.NewObject(myComponent) +aTableName = myBuilder.FindOrCreateAttribute(aTableObject, "AttributeName") +aTableName.SetValue("TestTable") +aTable = myBuilder.FindOrCreateAttribute(aTableObject, "AttributeTableOfReal") + +aTable.AddRow([0,1,2,3,4,5,6,7,8,9,10]) +aTable.AddRow([2000,1900,1800,1700,1600,1500,1400,1300,1200,1100,1000]) +aTable.AddRow([1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0]) +aTable.SetTitle("Test table") +aTable.SetRowTitle(1,"Time") +aTable.SetRowUnit(1,"s") +aTable.SetRowTitle(2,"Mass") +aTable.SetRowUnit(2,"kg") +aTable.SetRowTitle(3,"Temperature") +aTable.SetRowUnit(3,"K") + +# >>> Create table of integer +aVisuTable = myVisu.CreateTable(aTableObject.GetID()) + +# >>> Create curve attached to the left axis +aCurve1 = myVisu.CreateCurveWithZExt(aVisuTable, 1, 2, 0, False) + +# >>> Create curve attached to the right axis +aCurve2 = myVisu.CreateCurveWithZExt(aVisuTable, 1, 3, 1, True) + +# >>> Create container and insert curves +aContainer = myVisu.CreateContainer() +aContainer.AddCurve(aCurve1) +aContainer.AddCurve(aCurve2) + +# >>> Create XY plot and display container +myViewManager = myVisu.GetViewManager(); +myView = myViewManager.CreateXYPlot(); +myView.SetTitle("The viewer for curves") +myView.Display(aContainer) + +# >>> Update Object Browser +salome.sg.updateObjBrowser(1) diff --git a/src/VISU_SWIG/visu.py b/src/VISU_SWIG/visu.py index 50a3aea7..ba3f2422 100644 --- a/src/VISU_SWIG/visu.py +++ b/src/VISU_SWIG/visu.py @@ -1181,3 +1181,25 @@ def CreateCurve( theTable, theHRow, theVRow, theTitle, theColor, theMarker, theL curve.SetLine( theLineType, theLineWidth ) pass return curve + +def CreateCurveWithZ( theTable, theHRow, theVRow, theZRow, theTitle, theColor, theMarker, theLineType, theLineWidth ): + if theTitle is None: return + curve = myLocalVisu.CreateCurveWithZ( theTable, theHRow, theVRow, theZRow ); + if curve: + curve.SetTitle( theTitle ) + curve.SetColor( theColor ) + curve.SetMarker( theMarker ) + curve.SetLine( theLineType, theLineWidth ) + pass + return curve + +def CreateCurveWithZExt( theTable, theHRow, theVRow, theZRow, theIsV2, theTitle, theColor, theMarker, theLineType, theLineWidth ): + if theTitle is None: return + curve = myLocalVisu.CreateCurveWithZExt( theTable, theHRow, theVRow, theZRow, theIsV2 ); + if curve: + curve.SetTitle( theTitle ) + curve.SetColor( theColor ) + curve.SetMarker( theMarker ) + curve.SetLine( theLineType, theLineWidth ) + pass + return curve