Salome HOME
Curve setup dialog box restored (without resources)
authorsan <san@opencascade.com>
Thu, 9 Jun 2005 13:52:32 +0000 (13:52 +0000)
committersan <san@opencascade.com>
Thu, 9 Jun 2005 13:52:32 +0000 (13:52 +0000)
src/SPlot2d/Makefile.in
src/SPlot2d/SPlot2d_Curve.cxx
src/SPlot2d/SPlot2d_Curve.h
src/SPlot2d/SPlot2d_CurveContainer.cxx [deleted file]
src/SPlot2d/SPlot2d_CurveContainer.h [deleted file]
src/SPlot2d/SPlot2d_SetupPlot2dDlg.cxx [new file with mode: 0644]
src/SPlot2d/SPlot2d_SetupPlot2dDlg.h [new file with mode: 0644]

index 0d0c094e1fce2fd2556f39abe0fa8446d42a7c97..3b1004d30d5b42c48817e0b8b50175ace17754a0 100644 (file)
@@ -10,9 +10,9 @@ VPATH=.:@srcdir@:@top_srcdir@/idl
 EXPORT_HEADERS = \
            SPlot2d.h \
            SPlot2d_Curve.h \
-           SPlot2d_CurveContainer.h \
           SPlot2d_Prs.h \
-          SPlot2d_ViewModel.h
+          SPlot2d_ViewModel.h \
+          SPlot2d_SetupPlot2dDlg.h
 
 # .po files to transform in .qm
 #PO_FILES = \
@@ -22,23 +22,25 @@ EXPORT_HEADERS = \
 LIB = libSPlot2d.la
 LIB_SRC =        \
            SPlot2d_Curve.cxx \
-           SPlot2d_CurveContainer.cxx \
           SPlot2d_Prs.cxx \
-          SPlot2d_ViewModel.cxx
+          SPlot2d_ViewModel.cxx \
+          SPlot2d_SetupPlot2dDlg.cxx
 
 LIB_MOC = \
-          SPlot2d_ViewModel.h
+          SPlot2d_ViewModel.h \
+          SPlot2d_SetupPlot2dDlg.h
 
 
-LIB_CLIENT_IDL = SALOMEDS.idl \
-                SALOME_ModuleCatalog.idl \
-                SALOME_Component.idl \
-                SALOME_ContainerManager.idl \
-                SALOME_Exception.idl \
-                SALOME_GenericObj.idl
+#LIB_CLIENT_IDL = SALOMEDS.idl \
+#               SALOME_ModuleCatalog.idl \
+#               SALOME_Component.idl \
+#               SALOME_ContainerManager.idl \
+#               SALOME_Exception.idl \
+#               SALOME_GenericObj.idl
 
-CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(OGL_INCLUDES) $(PYTHON_INCLUDES) $(QWT_INCLUDES) $(BOOST_CPPFLAGS) -I$(KERNEL_ROOT_DIR)/include/salome
-LDFLAGS+=$(QT_MT_LIBS) $(OGL_LIBS) $(QWT_LIBS) -L$(KERNEL_ROOT_DIR)/lib/salome -lsuit -lPlot2d -lSalomePrs
+#CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(OGL_INCLUDES) $(PYTHON_INCLUDES) $(QWT_INCLUDES) $(BOOST_CPPFLAGS) -I$(KERNEL_ROOT_DIR)/include/salome
+CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(QWT_INCLUDES) $(BOOST_CPPFLAGS) -I$(KERNEL_ROOT_DIR)/include/salome
+LDFLAGS+=$(QT_MT_LIBS) $(QWT_LIBS) -L$(KERNEL_ROOT_DIR)/lib/salome -lsuit -lPlot2d -lSalomePrs
 
 
 @CONCLUDE@
index 3e6bc0324aef812aab76f08d160b7bb0c597a507..3a1c8cece14db204321d1b5d23dc2eebb60f4f91 100644 (file)
@@ -59,11 +59,3 @@ SPlot2d_Curve& SPlot2d_Curve::operator=( const SPlot2d_Curve& curve )
   return *this;
 }
 
-/*!
-  Sets curve's data. 
-*/
-void SPlot2d_Curve::setData( const double* hData, const double* vData, long size )
-{
-  clearAllPoints();
-  for(long i = 0; i < size; i++) addPoint(hData[i], vData[i]);
-}
index 512d217c113e21e37a0ddf1d4ae5df2785aa27d8..28eff47b0807447638631f86ec409cf7dc646078 100644 (file)
@@ -26,8 +26,6 @@ public:
   SPlot2d_Curve( const SPlot2d_Curve& curve );
   SPlot2d_Curve& operator= ( const SPlot2d_Curve& curve );
 
-  void setData( const double* hData, const double* vData, long size );
-
   virtual bool                             hasIO() { return !myIO.IsNull(); }
   virtual Handle(SALOME_InteractiveObject) getIO() const { return myIO; }
   virtual void                             setIO( const Handle(SALOME_InteractiveObject)& io ) { myIO = io; }
diff --git a/src/SPlot2d/SPlot2d_CurveContainer.cxx b/src/SPlot2d/SPlot2d_CurveContainer.cxx
deleted file mode 100644 (file)
index 93d3e98..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-//  File   : SPlot2d_CurveContainer.cxx
-//  Author : Sergey RUIN
-//  Module : SUIT
-
-#include "SPlot2d_CurveContainer.h"
-using namespace std;
-
-/*!
-  Constructor
-*/
-SPlot2d_CurveContainer::SPlot2d_CurveContainer()
-{
-  myCurves.setAutoDelete( false );
-}
-/*!
-  Destructor
-*/
-SPlot2d_CurveContainer::~SPlot2d_CurveContainer()
-{
-  
-}
-/*!
-  Adds curve if not exist yet in the container
-*/
-void SPlot2d_CurveContainer::addCurve( Plot2d_Curve* curve )
-{
-  if ( myCurves.find( curve ) < 0 )
-    myCurves.append( curve );
-}
-/*!
-  Removes curve form the container ( and deletes it if <alsoDelete> is true )
-*/
-void SPlot2d_CurveContainer::removeCurve( const int index, bool alsoDelete )
-{
-  Plot2d_Curve* curve = myCurves.take( index );
-  if ( curve && alsoDelete )
-    delete curve;
-}
-/*!
-  Clears container contents ( removes and deletes all curves )
-*/
-void SPlot2d_CurveContainer::clear( bool alsoDelete )
-{
-  while( myCurves.count() > 0 ) {
-    Plot2d_Curve* curve = myCurves.take( 0 );
-    if ( curve && alsoDelete )
-      delete curve;
-  }
-}
-/*!
-  Gets nb of curves in container
-*/
-int SPlot2d_CurveContainer::count()
-{
-  return myCurves.count();
-}
-/*!
-  Returns true if contains no curves
-*/
-bool SPlot2d_CurveContainer::isEmpty() const
-{
-  return myCurves.isEmpty();
-}
-/*!
-  Gets curve by index
-*/
-Plot2d_Curve* SPlot2d_CurveContainer::curve( const int index )
-{
-  return myCurves.at( index );
-}
-
-
diff --git a/src/SPlot2d/SPlot2d_CurveContainer.h b/src/SPlot2d/SPlot2d_CurveContainer.h
deleted file mode 100644 (file)
index 796391a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-//  File   : SPlot2d_CurveContainer.h
-//  Author : Sergey RUIN
-//  Module : SUIT
-
-#ifndef SPlot2d_CurveContainer_h
-#define SPlot2d_CurveContainer_h
-
-#include "SPlot2d.h"  
-
-#include "Plot2d_Curve.h"
-#include <qlist.h>
-
-class SPLOT2D_EXPORT SPlot2d_CurveContainer 
-{
-public:
-  SPlot2d_CurveContainer();
-  ~SPlot2d_CurveContainer();
-
-  void                addCurve( Plot2d_Curve* curve );
-  void                removeCurve( const int index, bool alsoDelete = false ) ;
-  void                clear( bool alsoDelete = false );
-  int                 count();
-  bool                isEmpty() const;
-  Plot2d_Curve*       curve( const int index );
-
-private:
-  QList<Plot2d_Curve>  myCurves;
-};
-
-#endif // SPlot2d_CurveContainer_h
-
-
diff --git a/src/SPlot2d/SPlot2d_SetupPlot2dDlg.cxx b/src/SPlot2d/SPlot2d_SetupPlot2dDlg.cxx
new file mode 100644 (file)
index 0000000..415d33d
--- /dev/null
@@ -0,0 +1,682 @@
+//  Copyright (C) 2003  CEA/DEN, EDF R&D
+//
+//
+//
+//  File   : Plot2d_SetupPlot2dDlg.cxx
+//  Author : Vadim SANDLER
+//  Module : SALOME
+//  $Header$
+
+#include "SPlot2d_SetupPlot2dDlg.h"
+#include "SPlot2d_Curve.h"
+
+#include "SUIT_Tools.h"
+#include "SUIT_MessageBox.h"
+
+#include <SALOMEDSClient_AttributeTableOfInteger.hxx>
+#include <SALOMEDSClient_AttributeTableOfReal.hxx>
+
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qcheckbox.h>
+#include <qtoolbutton.h>
+#include <qcombobox.h>
+#include <qscrollview.h>
+#include <qlayout.h>
+#include <qcolordialog.h>
+#include <qspinbox.h>
+
+#include <vector>
+#include <string>
+
+#include "utilities.h"
+
+using namespace std;
+
+#define DLG_SIZE_WIDTH    500 
+#define DLG_SIZE_HEIGHT   400
+#define MAX_LINE_WIDTH    100
+#define MARGIN_SIZE       11
+#define SPACING_SIZE      6
+
+/*!
+  Constructor
+*/
+SPlot2d_SetupPlot2dDlg::SPlot2d_SetupPlot2dDlg( _PTR(SObject) object, QWidget* parent )
+    : QDialog( parent, 
+              "SPlot2d_SetupPlot2dDlg", 
+              true, 
+              WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+{
+  setCaption( tr("TLT_SETUP_PLOT2D") );
+  setSizeGripEnabled( TRUE );
+  QGridLayout* topLayout = new QGridLayout( this ); 
+  topLayout->setSpacing( SPACING_SIZE );
+  topLayout->setMargin( MARGIN_SIZE );
+
+  myItems.setAutoDelete( false );
+
+  myObject = object;
+
+  /* Top scroll view */
+  myView = new QScrollView( this );
+  QFrame* frame  = new QFrame( myView );
+  frame->setFrameStyle( QFrame::Plain | QFrame::NoFrame );
+  QGridLayout* frameLayout = new QGridLayout( frame, 1, 12 );
+  frameLayout->setMargin( MARGIN_SIZE ); frameLayout->setSpacing( SPACING_SIZE );
+  
+  QFrame* lin;
+
+  QLabel* labAxis = new QLabel( tr( "AXIS_LBL" ),       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 );
+  labData->setAlignment( AlignCenter );
+  labUnit->setAlignment( AlignCenter );
+  labAttr->setAlignment( AlignCenter );
+  QFont font = labAxis->font(); font.setBold( true );
+  labAxis->setFont( font );
+  labData->setFont( font );
+  labUnit->setFont( font );
+  labAttr->setFont( font );
+
+  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 );
+      lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
+      frameLayout->addWidget( lin,          0,     4 );
+  frameLayout->addWidget( labUnit,          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 );
+  lin = new QFrame( frame ); lin->setFrameStyle( QFrame::HLine | QFrame::Sunken );
+  frameLayout->addMultiCellWidget( lin, 1, 1, 0, 12 );
+
+  int row = 2;
+  _PTR(GenericAttribute)        anAttr;
+  _PTR(AttributeTableOfInteger) tblIntAttr;
+  _PTR(AttributeTableOfReal)    tblRealAttr;
+  
+  /* Try table of integer */
+  if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) {
+    tblIntAttr = anAttr;
+    if ( tblIntAttr ) {
+      try {
+       int nbRows = tblIntAttr->GetNbRows() ; 
+       vector<string> rowTitles = tblIntAttr->GetRowTitles();
+       vector<string> rowUnits  = tblIntAttr->GetRowUnits();
+       for ( int i = 0; i < nbRows; i++ ) {
+         SPlot2d_ItemContainer* item = new SPlot2d_ItemContainer( this );
+         item->createWidgets( frame );
+         frameLayout->addWidget( item->myHBtn,        row, 0 );
+         frameLayout->addWidget( item->myVBtn,        row, 1 );
+         frameLayout->addWidget( item->myTitleLab,    row, 3 );
+         if ( rowTitles.size() > 0 )
+           item->myTitleLab->setText( QString( rowTitles[ i ] ) );
+         frameLayout->addWidget( item->myUnitLab,     row, 5 );
+         if ( rowUnits.size() > 0 )
+           item->myUnitLab->setText( QString( rowUnits[ i ] ) );
+         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 );
+         connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
+         connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
+         myItems.append( item );
+         row++;
+       }
+      }
+      catch( ... ) {
+       MESSAGE("SPlot2d_SetupPlot2dDlg::SPlot2d_SetupPlot2dDlg : Exception has been caught (int)!!!");
+      }
+    }
+  }
+  /* Try table of real */
+  else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
+    tblRealAttr = anAttr;
+    if ( tblRealAttr ) {
+      try {
+       int nbRows = tblRealAttr->GetNbRows() ; 
+       vector<string> rowTitles = tblRealAttr->GetRowTitles();
+       vector<string> rowUnits  = tblRealAttr->GetRowUnits();
+       for ( int i = 0; i < nbRows; i++ ) {
+         SPlot2d_ItemContainer* item = new SPlot2d_ItemContainer( this );
+         item->createWidgets( frame );
+         frameLayout->addWidget( item->myHBtn,        row, 0 );
+         frameLayout->addWidget( item->myVBtn,        row, 1 );
+         frameLayout->addWidget( item->myTitleLab,    row, 3 );
+         if ( rowTitles.size() > 0 )
+           item->myTitleLab->setText( QString( rowTitles[ i ] ) );
+         frameLayout->addWidget( item->myUnitLab,     row, 5 );
+         if ( rowUnits.size() > 0 )
+           item->myUnitLab->setText( QString( rowUnits[ i ] ) );
+         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 );
+         connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
+         connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
+         myItems.append( item );
+         row++;
+       }
+      }
+      catch( ... ) {
+       MESSAGE("SPlot2d_SetupPlot2dDlg::SPlot2d_SetupPlot2dDlg : Exception has been caught (real)!!!");
+      }
+    }
+  }
+  lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
+  frameLayout->addMultiCellWidget( lin, 2, row+1, 2, 2 );
+  lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
+  frameLayout->addMultiCellWidget( lin, 2, row+1, 4, 4 );
+  lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
+  frameLayout->addMultiCellWidget( lin, 2, row+1, 6, 6 );
+  frameLayout->setRowStretch( row+1, 5 );
+
+  myView->addChild( frame, 0, 0 );
+  myView->setResizePolicy( QScrollView::AutoOneFit );
+  
+  myView->setMinimumWidth( frame->sizeHint().width() + MARGIN_SIZE * 2 );
+
+  /* OK/Cancel buttons */
+  myOkBtn = new QPushButton( tr( "BUT_OK" ), this, "buttonOk" );
+  myOkBtn->setAutoDefault( TRUE );
+  myOkBtn->setDefault( TRUE );
+  myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this, "buttonCancel" );
+  myCancelBtn->setAutoDefault( TRUE );
+
+  topLayout->addMultiCellWidget( myView, 0, 0, 0, 2 );
+  topLayout->addWidget( myOkBtn, 1, 0 );
+  topLayout->setColStretch( 1, 5 );
+  topLayout->addWidget( myCancelBtn, 1, 2 );
+
+  connect( myOkBtn,     SIGNAL( clicked() ), this, SLOT( accept() ) );
+  connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
+
+  enableControls();
+
+  /* Center widget inside it's parent widget */
+  resize( DLG_SIZE_WIDTH, DLG_SIZE_HEIGHT  );
+  SUIT_Tools::centerWidget( this, parentWidget() );
+}
+/*!
+  Destructor
+*/
+SPlot2d_SetupPlot2dDlg::~SPlot2d_SetupPlot2dDlg()
+{
+}
+/*!
+  Gets curves info ( indexes of row data in the table for horizontal and verical axes )
+*/
+void SPlot2d_SetupPlot2dDlg::getCurvesSource( int& horIndex, QValueList<int>& verIndexes )
+{
+  /* collecting horizontal and vertical axis items */
+  horIndex = -1;
+  int i, j;
+  for ( i = 0; i < myItems.count(); i++ ) {
+    if ( myItems.at( i )->isHorizontalOn() ) {
+      horIndex = i;
+    }
+    else if ( myItems.at( i )->isVerticalOn() ) {
+      verIndexes.append( i );
+    }
+  }
+}
+/*!
+  Gets curve attributes
+*/
+bool SPlot2d_SetupPlot2dDlg::getCurveAttributes( const int vIndex, 
+                                                  bool&     isAuto, 
+                                                  int&      marker, 
+                                                  int&      line, 
+                                                  int&      lineWidth, 
+                                                  QColor&   color)
+{
+  if ( vIndex >= 0 && vIndex < myItems.count() ) {
+    isAuto    = myItems.at( vIndex )->isAutoAssign();
+    marker    = myItems.at( vIndex )->getMarker();
+    line      = myItems.at( vIndex )->getLine();
+    lineWidth = myItems.at( vIndex )->getLineWidth();
+    color     = myItems.at( vIndex )->getColor();
+    return true;
+  }
+  return false;
+}
+/*!
+  Creates and returns curves presentations
+*/
+void SPlot2d_SetupPlot2dDlg::getCurves( QPtrList<Plot2d_Curve>& container )
+{
+  _PTR(GenericAttribute)        anAttr;
+  _PTR(AttributeTableOfInteger) tblIntAttr;
+  _PTR(AttributeTableOfReal)    tblRealAttr;
+  
+  /* clearing container contents */
+  container.clear();
+
+  /* collecting horizontal and vertical axis items */
+  int horIndex;
+  int i, j;
+  QValueList<int> verIndex;
+  getCurvesSource( horIndex, verIndex );
+  if ( horIndex < 0 || verIndex.isEmpty() ) /* no curves can be created */
+    return;
+    
+  /* Try table of integer */
+  if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) {
+    tblIntAttr = anAttr;
+    if ( tblIntAttr ) {
+      try {
+       int nbCols = tblIntAttr->GetNbColumns() ; 
+       vector<string> rowTitles = tblIntAttr->GetRowTitles();
+       vector<string> rowUnits  = tblIntAttr->GetRowUnits();
+
+       for ( i = 0; i < verIndex.count(); i++ ) {
+         SPlot2d_Curve* curve = new SPlot2d_Curve();
+         // curve titles
+         if ( rowTitles.size() > 0 ) {
+           curve->setHorTitle( QString( rowTitles[ horIndex ] ) );
+           curve->setVerTitle( QString( rowTitles[ verIndex[i] ] ) );
+         }
+         // curve units
+         if ( rowUnits.size() > 0 ) {
+           curve->setHorUnits( QString( rowUnits[ horIndex ] ) );
+           curve->setVerUnits( QString( rowUnits[ verIndex[i] ] ) );
+         }
+         // curve data
+         int nbPoints = 0;
+         for ( j = 1; j <= nbCols; j++ ) {
+           if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) )
+             nbPoints++;
+         }
+         if ( nbPoints > 0 ) {
+           double* xList = new double[ nbPoints ];
+           double* yList = new double[ nbPoints ];
+           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 );
+             }
+           }
+           curve->setData( xList, yList, nbPoints );
+         }
+         // curve attributes
+         curve->setLine( (Plot2d_Curve::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() );
+         curve->setMarker( (Plot2d_Curve::MarkerType)myItems.at( verIndex[i] )->getMarker() );
+         curve->setColor( myItems.at( verIndex[i] )->getColor() );
+         curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() );
+         // add curve into container
+         container.append( curve );
+       }
+      }
+      catch( ... ) {
+       MESSAGE("SPlot2d_SetupPlot2dDlg::getCurves : Exception has been caught (int)!!!");
+      }
+    }
+  }
+  /* Try table of real */
+  else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
+    tblRealAttr = anAttr;
+    if ( tblRealAttr ) {
+      try {
+       int nbCols = tblRealAttr->GetNbColumns() ; 
+       vector<string> rowTitles = tblRealAttr->GetRowTitles();
+       vector<string> rowUnits  = tblRealAttr->GetRowUnits();
+
+       for ( i = 0; i < verIndex.count(); i++ ) {
+         SPlot2d_Curve* curve = new SPlot2d_Curve();
+         // curve titles
+         if ( rowTitles.size() > 0 ) {
+           curve->setHorTitle( QString( rowTitles[ horIndex ] ) );
+           curve->setVerTitle( QString( rowTitles[ verIndex[i] ] ) );
+         }
+         // curve units
+         if ( rowUnits.size() > 0 ) {
+           curve->setHorUnits( QString( rowUnits[ horIndex ] ) );
+           curve->setVerUnits( QString( rowUnits[ verIndex[i] ] ) );
+         }
+         // curve data
+         int nbPoints = 0;
+         for ( j = 1; j <= nbCols; j++ ) {
+           if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) )
+             nbPoints++;
+         }
+         if ( nbPoints > 0 ) {
+           double* xList = new double[ nbPoints ];
+           double* yList = new double[ nbPoints ];
+           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 );
+             }
+           }
+           curve->setData( xList, yList, nbPoints );
+         }
+         // curve attributes
+         curve->setLine( (Plot2d_Curve::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() );
+         curve->setMarker( (Plot2d_Curve::MarkerType)myItems.at( verIndex[i] )->getMarker() );
+         curve->setColor( myItems.at( verIndex[i] )->getColor() );
+         curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() );
+         // add curve into container
+         container.append( curve );
+       }
+      }
+      catch( ... ) {
+       MESSAGE("SPlot2d_SetupPlot2dDlg::getCurves : Exception has been caught (real)!!!");
+      }
+    }
+  }
+}
+/*!
+  Slot, called when any <H> button is clicked
+*/
+void SPlot2d_SetupPlot2dDlg::onHBtnToggled( bool on )
+{
+  SPlot2d_ItemContainer* item = ( SPlot2d_ItemContainer* )sender();
+  if ( on ) {
+    for ( int i = 0; i < myItems.count(); i++ ) {
+      if ( myItems.at( i ) != item )
+       myItems.at( i )->setHorizontalOn( false );
+    }
+  }
+  enableControls();
+}
+/*!
+  Slot, called when any <V> button is clicked
+*/
+void SPlot2d_SetupPlot2dDlg::onVBtnToggled( bool on )
+{
+  SPlot2d_ItemContainer* item = ( SPlot2d_ItemContainer* )sender();
+  QPtrList<SPlot2d_ItemContainer> itemList;
+  itemList.setAutoDelete( false );
+  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 )->isVerticalOn() )
+           totalOn++;
+         else
+           itemList.append( myItems.at( i ) );
+       }
+       else {
+         myItems.at( i )->setVerticalOn( false );
+       }
+      }
+    }
+    if ( totalOn == 0 && !itemList.isEmpty() && 
+        SUIT_MessageBox::info2( this, 
+                               this->caption(), 
+                               tr( "QUE_WANT_SAME_UNITS" ),
+                               tr( "BUT_YES" ), 
+                               tr( "BUT_NO" ), 
+                               0, 1, 1 ) == 0 ) {
+      for ( i = 0; i < itemList.count(); i++ ) {
+       itemList.at( i )->blockSignals( true );
+       itemList.at( i )->setVerticalOn( true );
+       itemList.at( i )->blockSignals( false );
+      }
+    }
+  }
+  enableControls();
+}
+/*!
+  Enables/disables buttons 
+*/
+void SPlot2d_SetupPlot2dDlg::enableControls()
+{
+  bool bHSet = false;
+  bool bVSet = false;
+  for ( int i = 0; i < myItems.count(); i++ ) {
+    if ( myItems.at( i )->isHorizontalOn() ) {
+      bHSet = true;
+      break;
+    }
+  }
+  for ( int i = 0; i < myItems.count(); i++ ) {
+    if ( myItems.at( i )->isVerticalOn() )
+      bVSet = true;
+    myItems.at( i )->enableWidgets( bHSet && myItems.at( i )->isVerticalOn() );
+  }
+  myOkBtn->setEnabled( bHSet && bVSet );
+}
+
+// ====================================================================================
+/*!
+  Constructor
+*/
+SPlot2d_ItemContainer::SPlot2d_ItemContainer( QObject* parent, const char* name )
+     : QObject( parent, name ), 
+       myEnabled( true )
+{
+}
+/*!
+  Creates widgets
+*/
+void SPlot2d_ItemContainer::createWidgets( QWidget* parentWidget )
+{
+  myHBtn = new QToolButton( parentWidget );
+  myHBtn->setText( tr( " H " ) );
+  myHBtn->setToggleButton( true );
+  myHBtn->setOn( false );
+
+  myVBtn = new QToolButton( parentWidget );
+  myVBtn->setText( tr( " V " ) );
+  myVBtn->setToggleButton( true );
+  myVBtn->setOn( false );
+  
+  myTitleLab = new QLabel( parentWidget );
+  myUnitLab  = new QLabel( parentWidget );
+  myUnitLab->setAlignment( AlignCenter);
+  
+  myAutoCheck = new QCheckBox( tr( "AUTO_CHECK_LBL" ), parentWidget );
+  myAutoCheck->setChecked( true );
+
+  myLineCombo = new QComboBox( false, parentWidget );
+  myLineCombo->insertItem( tr( "NONE_LINE_LBL" ) );
+  myLineCombo->insertItem( tr( "SOLID_LINE_LBL" ) );
+  myLineCombo->insertItem( tr( "DASH_LINE_LBL" ) );
+  myLineCombo->insertItem( tr( "DOT_LINE_LBL" ) );
+  myLineCombo->insertItem( tr( "DASHDOT_LINE_LBL" ) );
+  myLineCombo->insertItem( tr( "DAHSDOTDOT_LINE_LBL" ) );
+  myLineCombo->setCurrentItem( 1 ); // SOLID by default
+
+  myLineSpin = new QSpinBox( 0, MAX_LINE_WIDTH, 1, parentWidget );
+  myLineSpin->setValue( 0 );        // width = 0 by default
+
+  myMarkerCombo = new QComboBox( false, parentWidget );
+  myMarkerCombo->insertItem( tr( "NONE_MARKER_LBL" ) );
+  myMarkerCombo->insertItem( tr( "CIRCLE_MARKER_LBL" ) );
+  myMarkerCombo->insertItem( tr( "RECTANGLE_MARKER_LBL" ) );
+  myMarkerCombo->insertItem( tr( "DIAMOND_MARKER_LBL" ) );
+  myMarkerCombo->insertItem( tr( "DTRIANGLE_MARKER_LBL" ) );
+  myMarkerCombo->insertItem( tr( "UTRIANGLE_MARKER_LBL" ) );
+  myMarkerCombo->insertItem( tr( "LTRIANGLE_MARKER_LBL" ) );
+  myMarkerCombo->insertItem( tr( "RTRIANGLE_MARKER_LBL" ) );
+  myMarkerCombo->insertItem( tr( "CROSS_MARKER_LBL" ) );
+  myMarkerCombo->insertItem( tr( "XCROSS_MARKER_LBL" ) );
+  myMarkerCombo->setCurrentItem( 1 ); // CIRCLE by default
+
+  myColorBtn = new QToolButton( parentWidget );
+
+  connect( myAutoCheck, SIGNAL( clicked() ),       this, SLOT( onAutoChanged() ) );
+  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 ) ) );
+  setColor( QColor( 0, 0, 0 ) );
+  updateState();
+}
+/*!
+  Enables attributes widgets
+*/
+void SPlot2d_ItemContainer::enableWidgets( bool enable )
+{
+  myEnabled = enable;
+  updateState();
+}
+/*!
+  Sets horizontal button's state on
+*/
+void SPlot2d_ItemContainer::setHorizontalOn( bool on )
+{
+  myHBtn->setOn( on );
+}
+/*!
+  Gets horizontal button's state
+*/
+bool SPlot2d_ItemContainer::isHorizontalOn() const
+{
+  return myHBtn->isOn();
+}
+/*!
+  Sets vertical button's state on
+*/
+void SPlot2d_ItemContainer::setVerticalOn( bool on )
+{
+  myVBtn->setOn( on );
+}
+/*!
+  Gets vertical button's state
+*/
+bool SPlot2d_ItemContainer::isVerticalOn() const
+{
+  return myVBtn->isOn();
+}
+/*!
+  Sets item AutoAssign flag state
+*/
+void SPlot2d_ItemContainer::setAutoAssign( bool on )
+{
+  myAutoCheck->setChecked( on );
+  updateState();
+}
+/*!
+  Gets item AutoAssign flag state
+*/
+bool SPlot2d_ItemContainer::isAutoAssign() const
+{
+  return myAutoCheck->isChecked();
+}
+/*!
+  Sets item line type and width
+*/
+void SPlot2d_ItemContainer::setLine( const int line, const int width )
+{
+  myLineCombo->setCurrentItem( line );
+}
+/*!
+  Gets item line type
+*/
+int SPlot2d_ItemContainer::getLine() const
+{
+  return myLineCombo->currentItem();
+}
+/*!
+  Gets item line width
+*/
+int SPlot2d_ItemContainer::getLineWidth() const
+{
+  return myLineSpin->value();
+}
+/*!
+  Sets item marker type
+*/
+void SPlot2d_ItemContainer::setMarker( const int marker )
+{
+  myMarkerCombo->setCurrentItem( marker );
+}
+/*!
+  Gets item marker type
+*/
+int SPlot2d_ItemContainer::getMarker() const
+{
+  return myMarkerCombo->currentItem();
+}
+/*!
+  Sets item color
+*/
+void SPlot2d_ItemContainer::setColor( const QColor& color )
+{
+  QPalette pal = myColorBtn->palette();
+  QColorGroup ca = pal.active();
+  ca.setColor( QColorGroup::Button, color );
+  QColorGroup ci = pal.inactive();
+  ci.setColor( QColorGroup::Button, color );
+  pal.setActive( ca );
+  pal.setInactive( ci );
+  myColorBtn->setPalette( pal );
+}
+/*!
+  Gets item color
+*/
+QColor SPlot2d_ItemContainer::getColor() const
+{
+  return myColorBtn->palette().active().button();
+}
+/*!
+  Enables/disables widgets
+*/
+void SPlot2d_ItemContainer::updateState()
+{
+  myAutoCheck->setEnabled( myEnabled );
+  myLineCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() ); 
+  myLineSpin->setEnabled( myEnabled && !myAutoCheck->isChecked() ); 
+  myMarkerCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() ); 
+  myColorBtn->setEnabled( myEnabled && !myAutoCheck->isChecked() ); 
+}
+/*!
+  Slot, called when user clickes <Auto assign> check box
+*/
+void SPlot2d_ItemContainer::onAutoChanged()
+{
+  updateState();
+  emit( autoClicked() );
+}
+/*!
+  <Color> button slot, invokes color selection dialog box
+*/
+void SPlot2d_ItemContainer::onColorChanged()
+{
+  QColor color = QColorDialog::getColor( getColor() );
+  if ( color.isValid() ) {
+    setColor( color );
+  }
+}
+/*!
+  <H> and <V> buttons slot
+*/
+void SPlot2d_ItemContainer::onHVToggled( bool on )
+{
+  const QObject* snd = sender();
+  if ( snd == myHBtn ) {
+    if ( on ) {
+      if ( myVBtn->isOn() ) {
+//     blockSignals( true );
+       myVBtn->setOn( false );
+//     blockSignals( false );
+      }
+    }
+    emit horToggled( on );
+  }
+  else {
+    if ( on ) {
+      if ( myHBtn->isOn() ) {
+//     blockSignals( true );
+       myHBtn->setOn( false );
+//     blockSignals( false );
+      }
+    }
+    emit verToggled( on );
+  }
+}
+
+
+
+
+
diff --git a/src/SPlot2d/SPlot2d_SetupPlot2dDlg.h b/src/SPlot2d/SPlot2d_SetupPlot2dDlg.h
new file mode 100644 (file)
index 0000000..99e3ae8
--- /dev/null
@@ -0,0 +1,111 @@
+//  Copyright (C) 2003  CEA/DEN, EDF R&D
+//
+//
+//
+//  File   : SPlot2d_SetupPlot2dDlg.h
+//  Author : Vadim SANDLER
+//  Module : SALOME
+//  $Header$
+
+#ifndef SPlot2d_SetupPlot2dDlg_H
+#define SPlot2d_SetupPlot2dDlg_H
+
+#include "Plot2d_Curve.h"
+
+#include <SALOMEDSClient_SObject.hxx>
+
+#include <qdialog.h>
+#include <qptrlist.h>
+
+//=================================================================================
+// class    : SPlot2d_SetupPlot2dDlg
+// purpose  : Dialog box for setup Plot2d view
+//=================================================================================
+
+class QScrollView;
+class QPushButton;
+class QLabel;
+class QCheckBox;
+class QComboBox;
+class QSpinBox;
+class QToolButton;
+class SPlot2d_ItemContainer;
+
+class SPlot2d_SetupPlot2dDlg : public QDialog
+{ 
+  Q_OBJECT
+
+public:
+  SPlot2d_SetupPlot2dDlg( _PTR(SObject) object, QWidget* parent = 0 );
+  ~SPlot2d_SetupPlot2dDlg();
+
+  void getCurves( QPtrList<Plot2d_Curve>& container );
+  void getCurvesSource( int& horIndex, QValueList<int>& verIndexes );
+  bool getCurveAttributes( const int vIndex, bool& isAuto, int& marker, int& line, int& lineWidth, QColor& color);
+
+private slots:
+  void onHBtnToggled( bool );
+  void onVBtnToggled( bool );
+  void enableControls();
+
+private:
+  QScrollView*                myView;
+  QPushButton*                myOkBtn;
+  QPushButton*                myCancelBtn;
+  QPtrList<SPlot2d_ItemContainer> myItems;
+
+  _PTR(SObject)               myObject;
+};
+
+class SPlot2d_ItemContainer : public QObject
+{
+  Q_OBJECT
+
+public:
+  SPlot2d_ItemContainer( QObject* parent = 0, const char* name = 0 );
+  
+  void   createWidgets( QWidget* parentWidget );
+  void   enableWidgets( bool enable );
+
+  void   setHorizontalOn( bool on );
+  bool   isHorizontalOn() const;
+  void   setVerticalOn( bool on );
+  bool   isVerticalOn() const;
+  bool   isAutoAssign() const;
+  void   setAutoAssign( bool on );
+  void   setLine( const int line, const int width );
+  int    getLine() const;
+  int    getLineWidth() const;
+  void   setMarker( const int marker );
+  int    getMarker() const;
+  void   setColor( const QColor& color );
+  QColor getColor() const;
+
+protected:
+  void   updateState();
+
+signals:
+  void   autoClicked();
+  void   horToggled( bool );
+  void   verToggled( bool );
+
+public slots:
+  void   onAutoChanged();
+  void   onColorChanged();
+  void   onHVToggled( bool );
+
+public:
+  bool                  myEnabled;
+  QToolButton*          myHBtn;
+  QToolButton*          myVBtn;
+  QLabel*               myTitleLab;
+  QLabel*               myUnitLab;
+  QCheckBox*            myAutoCheck;
+  QComboBox*            myLineCombo;
+  QSpinBox*             myLineSpin;
+  QComboBox*            myMarkerCombo;
+  QToolButton*          myColorBtn;
+};
+
+#endif // SPlot2d_SetupPlot2dDlg_H
+