From: asl Date: Tue, 22 Aug 2006 05:32:21 +0000 (+0000) Subject: PAL13244 - tooltips over curve points must show assigned value X-Git-Tag: mergefrom_BR_For_OCT_611_04Sep06~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8f33cd7b4e9bab1b9c87196eab7ea75a7874e015;p=modules%2Fvisu.git PAL13244 - tooltips over curve points must show assigned value --- diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 4bb0aece..2f1d27f9 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -1594,6 +1594,16 @@ module VISU { * \param VRow Index of the row in the table: ordinate of the point. */ Curve CreateCurve(in Table theTable, in long theHRow, in long theVRow); + + /*! + * 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). + */ + Curve CreateCurveWithZ( in Table theTable, in long theHRow, in long theVRow, in long theZRow ); /*! * 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 3798473e..0563dad2 100644 --- a/src/ENGINE/VISU_Engine_i.cc +++ b/src/ENGINE/VISU_Engine_i.cc @@ -334,6 +334,14 @@ namespace VISU{ return myVisuGen->CreateCurve(theTable,theHRow,theVRow); } + Curve_ptr VISU_Gen_i::CreateCurveWithZ(Table_ptr theTable, + CORBA::Long theHRow, + CORBA::Long theVRow, + CORBA::Long theZRow) + { + return myVisuGen->CreateCurveWithZ(theTable,theHRow,theVRow,theZRow); + } + 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 223a5996..3f605b43 100644 --- a/src/ENGINE/VISU_Engine_i.hh +++ b/src/ENGINE/VISU_Engine_i.hh @@ -108,6 +108,7 @@ namespace VISU{ //Create Digital Presentation 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 Container_ptr CreateContainer(); virtual Animation_ptr CreateAnimation(View3D_ptr theView3d); diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index c5683bd1..eebc49c8 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -1194,6 +1194,9 @@ msgstr "Attributes" msgid "AXIS_LBL" msgstr "Axis" +msgid "ASSIGNED" +msgstr "Assigned" + #: VisuGUI_SetupPlot2dDlg.cxx:69 msgid "DATA_LBL" msgstr "Data" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 82afc07c..8266ce94 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -1214,8 +1214,8 @@ OnPlotData() // 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; - QValueList verIndices; - dlg->getCurvesSource( horIndex, verIndices ); + QValueList verIndices, zIndices; + dlg->getCurvesSource( horIndex, verIndices, zIndices ); if ( horIndex >= 0 && verIndices.count() > 0 ) { CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer(); if( !CORBA::is_nil( aContainer ) ) { @@ -1224,7 +1224,7 @@ OnPlotData() if ( pContainer ) { for ( int i = 0; i < verIndices.count(); i++ ) { CORBA::Object_var aNewCurve = - GetVisuGen(this)->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 ); + GetVisuGen(this)->CreateCurveWithZ( table->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1 ); if( !CORBA::is_nil( aNewCurve ) ) { VISU::Curve_i* pCrv = dynamic_cast(VISU::GetServant(aNewCurve).in()); @@ -1284,8 +1284,8 @@ OnPlotData() // 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; - QValueList verIndices; - dlg->getCurvesSource( horIndex, verIndices ); + QValueList verIndices, zIndices; + dlg->getCurvesSource( horIndex, verIndices, zIndices ); if ( horIndex >= 0 && verIndices.count() > 0 ) { CORBA::Object_var aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() ); CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer(); @@ -1295,8 +1295,8 @@ OnPlotData() if ( pContainer && pTable ) { for ( int i = 0; i < verIndices.count(); i++ ) { - CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurve - ( pTable->_this(), horIndex+1, verIndices[i]+1 ); + CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurveWithZ + ( pTable->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1 ); if( !CORBA::is_nil( aNewCurve ) ) { VISU::Curve_i* pCrv = dynamic_cast(VISU::GetServant(aNewCurve).in()); if ( pCrv ) { diff --git a/src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx b/src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx index 1c185b41..81e8fcc1 100644 --- a/src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx +++ b/src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx @@ -88,15 +88,18 @@ VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, QWidget* p QFrame* lin; QLabel* labAxis = new QLabel( tr( "AXIS_LBL" ), frame ); + QLabel* labAssigned = new QLabel( tr( "ASSIGNED" ), frame ); QLabel* labData = new QLabel( tr( "DATA_LBL" ), frame ); QLabel* labUnit = new QLabel( tr( "UNITS_LBL" ), frame ); QLabel* labAttr = new QLabel( tr( "ATTRIBUTES_LBL" ), frame ); labAxis->setAlignment( AlignCenter ); + labAssigned->setAlignment( AlignCenter ); labData->setAlignment( AlignCenter ); labUnit->setAlignment( AlignCenter ); labAttr->setAlignment( AlignCenter ); QFont font = labAxis->font(); font.setBold( true ); labAxis->setFont( font ); + labAssigned->setFont( font ); labData->setFont( font ); labUnit->setFont( font ); labAttr->setFont( font ); @@ -104,16 +107,21 @@ VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, QWidget* p frameLayout->addMultiCellWidget( labAxis, 0, 0, 0, 1 ); lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); frameLayout->addWidget( lin, 0, 2 ); - frameLayout->addWidget( labData, 0, 3 ); + + frameLayout->addWidget( labAssigned, 0, 3 ); lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); frameLayout->addWidget( lin, 0, 4 ); - frameLayout->addWidget( labUnit, 0, 5 ); + + frameLayout->addWidget( labData, 0, 5 ); lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); frameLayout->addWidget( lin, 0, 6 ); - frameLayout->addMultiCellWidget( labAttr, 0, 0, 7, 11 ); - frameLayout->setColStretch( 12, 5 ); + frameLayout->addWidget( labUnit, 0, 7 ); + lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); + frameLayout->addWidget( lin, 0, 8 ); + frameLayout->addMultiCellWidget( labAttr, 0, 0, 9, 13 ); + frameLayout->setColStretch( 14, 5 ); lin = new QFrame( frame ); lin->setFrameStyle( QFrame::HLine | QFrame::Sunken ); - frameLayout->addMultiCellWidget( lin, 1, 1, 0, 12 ); + frameLayout->addMultiCellWidget( lin, 1, 1, 0, 14 ); int row = 2; _PTR(GenericAttribute) anAttr; @@ -128,22 +136,28 @@ VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, QWidget* p int nbRows = tblIntAttr->GetNbRows() ; vector rowTitles = tblIntAttr->GetRowTitles(); vector rowUnits = tblIntAttr->GetRowUnits(); + QStringList rows; + for ( int i = 0; i < nbRows; i++ ) + rows.append( rowTitles[i] ); + for ( int i = 0; i < nbRows; i++ ) { VisuGUI_ItemContainer* item = new VisuGUI_ItemContainer( this ); - item->createWidgets( frame ); + item->createWidgets( frame, rows ); frameLayout->addWidget( item->myHBtn, row, 0 ); frameLayout->addWidget( item->myVBtn, row, 1 ); - frameLayout->addWidget( item->myTitleLab, row, 3 ); + frameLayout->addWidget( item->myAssigned, row, 3 ); + + frameLayout->addWidget( item->myTitleLab, row, 5 ); if ( rowTitles.size() > 0 ) item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) ); - frameLayout->addWidget( item->myUnitLab, row, 5 ); + frameLayout->addWidget( item->myUnitLab, row, 7 ); if ( rowUnits.size() > 0 ) item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) ); - frameLayout->addWidget( item->myAutoCheck, row, 7 ); - frameLayout->addWidget( item->myLineCombo, row, 8 ); - frameLayout->addWidget( item->myLineSpin, row, 9 ); - frameLayout->addWidget( item->myMarkerCombo, row, 10 ); - frameLayout->addWidget( item->myColorBtn, row, 11 ); + 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 ); connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) ); connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) ); myItems.append( item ); @@ -163,22 +177,28 @@ VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, QWidget* p int nbRows = tblRealAttr->GetNbRows() ; vector rowTitles = tblRealAttr->GetRowTitles(); vector rowUnits = tblRealAttr->GetRowUnits(); + QStringList rows; + for ( int i = 0; i < nbRows; i++ ) + rows.append( rowTitles[i] ); + for ( int i = 0; i < nbRows; i++ ) { VisuGUI_ItemContainer* item = new VisuGUI_ItemContainer( this ); - item->createWidgets( frame ); + item->createWidgets( frame, rows ); frameLayout->addWidget( item->myHBtn, row, 0 ); frameLayout->addWidget( item->myVBtn, row, 1 ); - frameLayout->addWidget( item->myTitleLab, row, 3 ); + frameLayout->addWidget( item->myAssigned, row, 3 ); + + frameLayout->addWidget( item->myTitleLab, row, 5 ); if ( rowTitles.size() > 0 ) item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) ); - frameLayout->addWidget( item->myUnitLab, row, 5 ); + frameLayout->addWidget( item->myUnitLab, row, 7 ); if ( rowUnits.size() > 0 ) item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) ); - frameLayout->addWidget( item->myAutoCheck, row, 7 ); - frameLayout->addWidget( item->myLineCombo, row, 8 ); - frameLayout->addWidget( item->myLineSpin, row, 9 ); - frameLayout->addWidget( item->myMarkerCombo, row, 10 ); - frameLayout->addWidget( item->myColorBtn, row, 11 ); + 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 ); connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) ); connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) ); myItems.append( item ); @@ -237,7 +257,8 @@ 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, QValueList& verIndexes ) +void VisuGUI_SetupPlot2dDlg::getCurvesSource( int& horIndex, QValueList& verIndexes, + QValueList& zIndices ) { /* collecting horizontal and vertical axis items */ horIndex = -1; @@ -248,7 +269,9 @@ void VisuGUI_SetupPlot2dDlg::getCurvesSource( int& horIndex, QValueList& ve } else if ( myItems.at( i )->isVerticalOn() ) { verIndexes.append( i ); + zIndices.append( myItems.at( i )->assigned() ); } + } } /*! @@ -286,8 +309,8 @@ void VisuGUI_SetupPlot2dDlg::getCurves( QPtrList& container ) /* collecting horizontal and vertical axis items */ int horIndex; int i, j; - QValueList verIndex; - getCurvesSource( horIndex, verIndex ); + QValueList verIndex, zIndices; + getCurvesSource( horIndex, verIndex, zIndices ); if ( horIndex < 0 || verIndex.isEmpty() ) /* no curves can be created */ return; @@ -321,13 +344,15 @@ void VisuGUI_SetupPlot2dDlg::getCurves( QPtrList& container ) if ( nbPoints > 0 ) { double* xList = new double[ nbPoints ]; double* yList = new double[ nbPoints ]; + QStringList zList; for ( j = 1; j <= nbCols; j++ ) { if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) ) { xList[j-1] = tblIntAttr->GetValue( horIndex +1, j ); yList[j-1] = tblIntAttr->GetValue( verIndex[i]+1, j ); + zList.append( QString( "%1" ).arg( tblIntAttr->GetValue( zIndices[i]+1, j ) ) ); } } - curve->setData( xList, yList, nbPoints ); + curve->setData( xList, yList, nbPoints, zList ); } // curve attributes curve->setLine( (Plot2d_Curve::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() ); @@ -373,13 +398,15 @@ void VisuGUI_SetupPlot2dDlg::getCurves( QPtrList& container ) if ( nbPoints > 0 ) { double* xList = new double[ nbPoints ]; double* yList = new double[ nbPoints ]; + QStringList zList; for ( j = 1; j <= nbCols; j++ ) { if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) ) { xList[j-1] = tblRealAttr->GetValue( horIndex +1, j ); yList[j-1] = tblRealAttr->GetValue( verIndex[i]+1, j ); + zList.append( QString( "%1" ).arg( tblIntAttr->GetValue( zIndices[i]+1, j ) ) ); } } - curve->setData( xList, yList, nbPoints ); + curve->setData( xList, yList, nbPoints, zList ); } // curve attributes curve->setLine( (Plot2d_Curve::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() ); @@ -418,6 +445,7 @@ void VisuGUI_SetupPlot2dDlg::onVBtnToggled( bool on ) VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender(); QPtrList itemList; itemList.setAutoDelete( false ); + item->myAssigned->setEnabled( on ); int i; if ( on ) { int totalOn = 0; @@ -521,7 +549,7 @@ VisuGUI_ItemContainer::VisuGUI_ItemContainer( QObject* parent, const char* name /*! Creates widgets */ -void VisuGUI_ItemContainer::createWidgets( QWidget* parentWidget ) +void VisuGUI_ItemContainer::createWidgets( QWidget* parentWidget, const QStringList& lst ) { myHBtn = new QToolButton( parentWidget ); myHBtn->setText( tr( "H" ) ); @@ -567,6 +595,13 @@ void VisuGUI_ItemContainer::createWidgets( QWidget* parentWidget ) myColorBtn = new QToolButton( parentWidget ); myColorBtn->setMinimumWidth( 20 ); + + myAssigned = new QComboBox( false, parentWidget ); + myAssigned->insertItem( "" ); + QStringList::const_iterator anIt = lst.begin(), aLast = lst.end(); + for( ; anIt!=aLast; anIt++ ) + myAssigned->insertItem( *anIt ); + myAssigned->setEnabled( false ); connect( myAutoCheck, SIGNAL( clicked() ), this, SLOT( onAutoChanged() ) ); connect( myColorBtn, SIGNAL( clicked() ), this, SLOT( onColorChanged() ) ); @@ -738,3 +773,14 @@ void VisuGUI_ItemContainer::onHVToggled( bool on ) emit verToggled( on ); } } + +/*! + \return index of assigned row (0, if there is no assigned row) +*/ +int VisuGUI_ItemContainer::assigned() const +{ + if( isVerticalOn() ) + return myAssigned->currentItem()-1; + else + return -1; +} diff --git a/src/VISUGUI/VisuGUI_SetupPlot2dDlg.h b/src/VISUGUI/VisuGUI_SetupPlot2dDlg.h index dd8a0f9d..234a2870 100644 --- a/src/VISUGUI/VisuGUI_SetupPlot2dDlg.h +++ b/src/VISUGUI/VisuGUI_SetupPlot2dDlg.h @@ -54,7 +54,7 @@ public: ~VisuGUI_SetupPlot2dDlg(); void getCurves( QPtrList& container ); - void getCurvesSource( int& horIndex, QValueList& verIndexes ); + void getCurvesSource( int& horIndex, QValueList& verIndexes, QValueList& zIndexes ); bool getCurveAttributes( const int vIndex, bool& isAuto, int& marker, int& line, int& lineWidth, QColor& color); private: @@ -83,7 +83,7 @@ class VisuGUI_ItemContainer : public QObject public: VisuGUI_ItemContainer( QObject* parent = 0, const char* name = 0 ); - void createWidgets( QWidget* parentWidget ); + void createWidgets( QWidget* parentWidget, const QStringList& ); void enableWidgets( bool enable ); void setHorizontalOn( bool on ); @@ -99,6 +99,7 @@ public: int getMarker() const; void setColor( const QColor& color ); QColor getColor() const; + int assigned() const; protected: void updateState(); @@ -122,7 +123,7 @@ public: QCheckBox* myAutoCheck; QComboBox* myLineCombo; QSpinBox* myLineSpin; - QComboBox* myMarkerCombo; + QComboBox* myMarkerCombo, *myAssigned; QToolButton* myColorBtn; }; diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 11f1c654..f9ea32df 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -825,9 +825,10 @@ namespace VISU plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() ); double* xList = 0; double* yList = 0; - int nbPoints = theCurve->GetData( xList, yList ); + QStringList zList; + int nbPoints = theCurve->GetData( xList, yList, zList ); if ( nbPoints > 0 && xList && yList ) { - plotCurve->setData( xList, yList, nbPoints ); + plotCurve->setData( xList, yList, nbPoints, zList ); } if ( !theCurve->IsAuto() ) { plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() ); diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc index 2a97ac82..a2e810a8 100644 --- a/src/VISU_I/VISU_DumpPython.cc +++ b/src/VISU_I/VISU_DumpPython.cc @@ -967,11 +967,19 @@ namespace VISU case VISU::TCURVE: if(Curve_i* aServant = dynamic_cast(GetServant(anObj).in())) { - theStr << thePrefix << "aName2ObjectMap['" << aName << "'] = visu.CreateCurve(" << + bool withZ = aServant->GetZRow()>0; + + theStr << thePrefix << "aName2ObjectMap['" << aName << "'] = visu.CreateCurve"; + if( withZ ) + theStr << "WithZ"; + theStr << "(" << theArgumentName<< // table ","<GetHRow()<< // H row - ","<GetVRow()<< // V row - ",'"<GetTitle()<<"'"; // title + ","<GetVRow(); // V row + if( withZ ) + theStr << "," << aServant->GetZRow(); // Z row + + theStr << ",'"<GetTitle()<<"'"; // title SALOMEDS::Color aColor = aServant->GetColor(); theStr << ",SALOMEDS.Color("<< aColor.R<<","<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); + Curve_i* pPresent = new Curve_i(myStudyDocument,pTable,theHRow,theVRow,theZRow); if(pPresent->Create() != NULL) return pPresent->_this(); else{ diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index 1a90cd8e..1a5f6f82 100644 --- a/src/VISU_I/VISU_Gen_i.hh +++ b/src/VISU_I/VISU_Gen_i.hh @@ -285,6 +285,12 @@ 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); virtual Container_ptr diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index 4713feda..cb642126 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -329,8 +329,11 @@ const char* VISU::Curve_i::GetComment() const Constructor NB : theHRow, theVRow are the indexes of rows in the Table object and numbered from the 1 to GetNbRows() */ -VISU::Curve_i::Curve_i(SALOMEDS::Study_ptr theStudy, Table_i* theTable, CORBA::Long theHRow, CORBA::Long theVRow ) - : PrsObject_i(theStudy), myTable( theTable ), myHRow( theHRow ), myVRow( theVRow ) +VISU::Curve_i::Curve_i( SALOMEDS::Study_ptr theStudy, Table_i* theTable, + CORBA::Long theHRow, CORBA::Long theVRow, + CORBA::Long theZRow ) +: PrsObject_i(theStudy), myTable( theTable ), myHRow( theHRow ), + myVRow( theVRow ), myZRow( theZRow ) { myAuto = true; myLine = VISU::Curve::SOLIDLINE; @@ -533,7 +536,7 @@ string VISU::Curve_i::GetVerUnits() /*! Gets curve data */ -int VISU::Curve_i::GetData( double*& theHorList, double*& theVerList ) +int VISU::Curve_i::GetData( double*& theHorList, double*& theVerList, QStringList& zList ) { theHorList = 0; theVerList = 0; // getting table SObject by it's entry @@ -542,10 +545,13 @@ int VISU::Curve_i::GetData( double*& theHorList, double*& theVerList ) SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeTableOfInteger_var anInt; SALOMEDS::AttributeTableOfReal_var aReal; + + QString tip = "%1: %2", z_data; + if ( !SO->_is_nil() ) { if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) { anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr ); - int nbCols = anInt->GetNbColumns() ; + int nbCols = anInt->GetNbColumns(), nbRows = anInt->GetNbRows(); if ( nbCols > 0 && myHRow > 0 && myHRow <= anInt->GetNbRows() && myVRow > 0 && myVRow <= anInt->GetNbRows() ) { int nbPoints = 0; for ( int j = 1; j <= nbCols; j++ ) { @@ -556,10 +562,24 @@ int VISU::Curve_i::GetData( double*& theHorList, double*& theVerList ) theHorList = new double[ nbPoints ]; theVerList = new double[ nbPoints ]; int k = 0; + + SALOMEDS::StringSeq_var rowTitles = anInt->GetRowTitles(); + for ( int j = 1; j <= nbCols; j++ ) { if ( anInt->HasValue( myHRow, j ) && anInt->HasValue( myVRow, j ) ) { theHorList[k] = anInt->GetValue( myHRow, j ); theVerList[k] = anInt->GetValue( myVRow, j ); + + z_data = tip.arg( GetHorTitle().c_str() ).arg( theHorList[k] ) + "\n"; + z_data += tip.arg( GetVerTitle().c_str() ).arg( theVerList[k] ); + + if( myZRow>0 && myZRow<=nbRows && anInt->HasValue( myZRow, j ) ) + { + string title; + title = rowTitles[ myZRow-1 ]; + z_data += "\n" + tip.arg( title.c_str() ).arg( anInt->GetValue( myZRow, j ) ); + } + zList.append( z_data ); k++; } } @@ -569,7 +589,7 @@ int VISU::Curve_i::GetData( double*& theHorList, double*& theVerList ) } else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) { aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr ); - int nbCols = aReal->GetNbColumns() ; + int nbCols = aReal->GetNbColumns(), nbRows = aReal->GetNbRows(); if ( nbCols > 0 && myHRow > 0 && myHRow <= aReal->GetNbRows() && myVRow > 0 && myVRow <= aReal->GetNbRows() ) { int nbPoints = 0; for ( int j = 1; j <= nbCols; j++ ) { @@ -580,10 +600,24 @@ int VISU::Curve_i::GetData( double*& theHorList, double*& theVerList ) theHorList = new double[ nbPoints ]; theVerList = new double[ nbPoints ]; int k = 0; + + SALOMEDS::StringSeq_var rowTitles = aReal->GetRowTitles(); + for ( int j = 1; j <= nbCols; j++ ) { if ( aReal->HasValue( myHRow, j ) && aReal->HasValue( myVRow, j ) ) { theHorList[k] = aReal->GetValue( myHRow, j ); theVerList[k] = aReal->GetValue( myVRow, j ); + + z_data = tip.arg( GetHorTitle().c_str() ).arg( theHorList[k] ) + "\n"; + z_data += tip.arg( GetVerTitle().c_str() ).arg( theVerList[k] ); + + if( myZRow>0 && myZRow<=nbRows && aReal->HasValue( myZRow, j ) ) + { + string title; + title = rowTitles[ myZRow-1 ]; + z_data += "\n" + tip.arg( title.c_str() ).arg( aReal->GetValue( myZRow, j ) ); + } + zList.append( z_data ); k++; } } @@ -611,9 +645,10 @@ SPlot2d_Curve* VISU::Curve_i::CreatePresentation() crv->setVerUnits( GetVerUnits().c_str() ); double* xList = 0; double* yList = 0; - int nbPoints = GetData( xList, yList ); + QStringList zList; + int nbPoints = GetData( xList, yList, zList ); if ( nbPoints > 0 && xList && yList ) { - crv->setData( xList, yList, nbPoints ); + crv->setData( xList, yList, nbPoints, zList ); } //cout << "********** Number of points: " << nbPoints <GetStudy(); VISU::Table_i* pTable = GetTable(aStudy, theSObject->GetFather()); if( pTable != NULL ) { - VISU::Curve_i* pResent = new VISU::Curve_i( aStudy, pTable, 0, 0 ); + VISU::Curve_i* pResent = new VISU::Curve_i( aStudy, pTable, 0, 0, 0 ); 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 80d2a11f..ceb9eade 100644 --- a/src/VISU_I/VISU_Table_i.hh +++ b/src/VISU_I/VISU_Table_i.hh @@ -91,7 +91,8 @@ namespace VISU{ Curve_i(); Curve_i( const Curve_i& ); public: - Curve_i( SALOMEDS::Study_ptr theStudy, Table_i* theTable, CORBA::Long theHRow, CORBA::Long theVRow ); + Curve_i( SALOMEDS::Study_ptr theStudy, Table_i* theTable, + CORBA::Long theHRow, CORBA::Long theVRow, CORBA::Long theZRow ); virtual ~Curve_i(); virtual VISU::VISUType GetType() { return VISU::TCURVE;}; @@ -120,6 +121,7 @@ namespace VISU{ Table_i* myTable; int myHRow; int myVRow; + int myZRow; struct SALOMEDS::Color myColor; VISU::Curve::MarkerType myMarker; VISU::Curve::LineType myLine; @@ -133,6 +135,7 @@ namespace VISU{ int GetHRow() const { return myHRow;} int GetVRow() const { return myVRow;} + int GetZRow() const { return myZRow;} virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr theSO); @@ -152,7 +155,7 @@ namespace VISU{ virtual std::string GetVerTitle(); virtual std::string GetHorUnits(); virtual std::string GetVerUnits(); - virtual int GetData( double*& theHorList, double*& theVerList ); + virtual int GetData( double*& theHorList, double*& theVerList, QStringList& ); virtual SPlot2d_Curve* CreatePresentation(); }; diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index 29c69d21..cb6425f4 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -360,9 +360,10 @@ namespace VISU { aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() ); double* xList = 0; double* yList = 0; - int nbPoints = theCurve->GetData( xList, yList ); + QStringList zList; + int nbPoints = theCurve->GetData( xList, yList, zList ); if (nbPoints > 0 && xList && yList) { - aSPlot2dC->setData( xList, yList, nbPoints ); + aSPlot2dC->setData( xList, yList, nbPoints, zList ); } if (!theCurve->IsAuto()) { aSPlot2dC->setLine((Plot2d_Curve::LineType)theCurve->GetLine(), @@ -408,9 +409,10 @@ namespace VISU { aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() ); double* xList = 0; double* yList = 0; - int nbPoints = theCurve->GetData( xList, yList ); + QStringList zList; + int nbPoints = theCurve->GetData( xList, yList, zList ); if ( nbPoints > 0 && xList && yList ) { - aSPlot2dC->setData( xList, yList, nbPoints ); + aSPlot2dC->setData( xList, yList, nbPoints, zList ); } if ( !theCurve->IsAuto() ) { aSPlot2dC->setLine((Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth());