Salome HOME
SetupPlot2dDlg is moved to VISU
authorasl <asl@opencascade.com>
Tue, 8 Nov 2005 09:04:16 +0000 (09:04 +0000)
committerasl <asl@opencascade.com>
Tue, 8 Nov 2005 09:04:16 +0000 (09:04 +0000)
src/VISUGUI/Makefile.in
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx [new file with mode: 0644]
src/VISUGUI/VisuGUI_SetupPlot2dDlg.h [new file with mode: 0644]

index 2bcb2ea5fe03dab46f6cedfad31a400b660af564..805e692815f14aac7fd73c58baa9618cd0d00b66 100644 (file)
@@ -71,7 +71,8 @@ LIB_SRC =     VisuGUI.cxx \
                VisuGUI_StreamLinesDlg.cxx \
                VisuGUI_VectorsDlg.cxx \
                VisuGUI_DialogRunner.cxx \
-               VisuGUI_Displayer.cxx
+               VisuGUI_Displayer.cxx \
+               VisuGUI_SetupPlot2dDlg.cxx
 
 LIB_MOC =      VisuGUI.h \
                VisuGUI_Selection.h \
@@ -93,7 +94,8 @@ LIB_MOC =     VisuGUI.h \
                VisuGUI_CutPlanesDlg.h \
                VisuGUI_StreamLinesDlg.h \
                VisuGUI_VectorsDlg.h \
-               VisuGUI_DialogRunner.h
+               VisuGUI_DialogRunner.h \
+               VisuGUI_SetupPlot2dDlg.h
 
 LIB_CLIENT_IDL = SALOME_Exception.idl \
                 VISU_Gen.idl \
index 97b419714e0f85a8ca3be573a5b45e6a1cfca96b..c7f189885dea5673a0e46abc0b03fcd763663428 100644 (file)
@@ -60,7 +60,7 @@
 #include "SVTK_Functor.h"
 
 #include "SPlot2d_ViewModel.h"
-#include "SPlot2d_SetupPlot2dDlg.h"
+#include "VisuGUI_SetupPlot2dDlg.h"
 #include "Plot2d_SetupCurveDlg.h"
 
 #include "OB_Browser.h"
@@ -1192,7 +1192,7 @@ OnPlotData()
               aName = anAttr;
               SOName = QString( aName->Value().c_str() );
             }
-            SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
+            VisuGUI_SetupPlot2dDlg* dlg = new VisuGUI_SetupPlot2dDlg( SO, GetDesktop( this ) );
             if ( dlg->exec() == QDialog::Accepted ) {
               if ( !IsStudyLocked( aStudy ) ) {
                 // if study is not locked - create new container, create curves and insert them
@@ -1262,7 +1262,7 @@ OnPlotData()
         aName = anAttr;
         SOName = QString( aName->Value().c_str() );
       }
-      SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
+      VisuGUI_SetupPlot2dDlg* dlg = new VisuGUI_SetupPlot2dDlg( SO, GetDesktop( this ) );
       if ( dlg->exec() == QDialog::Accepted ) {
         if ( !IsStudyLocked( aStudy ) ) {
           // if study is not locked - create new table and container objects, create curves
diff --git a/src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx b/src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx
new file mode 100644 (file)
index 0000000..120785f
--- /dev/null
@@ -0,0 +1,687 @@
+//  Copyright (C) 2003  CEA/DEN, EDF R&D
+//
+//
+//
+//  File   : VisuGUI_SetupPlot2dDlg.cxx
+//  Author : Vadim SANDLER
+//  Module : SALOME
+//  $Header$
+
+#include "VisuGUI_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
+*/
+VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, QWidget* parent )
+    : QDialog( parent, 
+              "VisuGUI_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++ ) {
+         VisuGUI_ItemContainer* item = new VisuGUI_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 ].c_str() ) );
+         frameLayout->addWidget( item->myUnitLab,     row, 5 );
+         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 );
+         connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
+         connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
+         myItems.append( item );
+         row++;
+       }
+      }
+      catch( ... ) {
+       MESSAGE("VisuGUI_SetupPlot2dDlg::VisuGUI_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++ ) {
+         VisuGUI_ItemContainer* item = new VisuGUI_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 ].c_str() ) );
+         frameLayout->addWidget( item->myUnitLab,     row, 5 );
+         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 );
+         connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
+         connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
+         myItems.append( item );
+         row++;
+       }
+      }
+      catch( ... ) {
+       MESSAGE("VisuGUI_SetupPlot2dDlg::VisuGUI_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
+*/
+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<int>& verIndexes )
+{
+  /* collecting horizontal and vertical axis items */
+  horIndex = -1;
+  int i;
+  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 VisuGUI_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 VisuGUI_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 ].c_str() ) );
+           curve->setVerTitle( QString( rowTitles[ verIndex[i] ].c_str() ) );
+         }
+         // curve units
+         if ( rowUnits.size() > 0 ) {
+           curve->setHorUnits( QString( rowUnits[ horIndex ].c_str() ) );
+           curve->setVerUnits( QString( rowUnits[ verIndex[i] ].c_str() ) );
+         }
+         // 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("VisuGUI_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 ].c_str() ) );
+           curve->setVerTitle( QString( rowTitles[ verIndex[i] ].c_str() ) );
+         }
+         // curve units
+         if ( rowUnits.size() > 0 ) {
+           curve->setHorUnits( QString( rowUnits[ horIndex ].c_str() ) );
+           curve->setVerUnits( QString( rowUnits[ verIndex[i] ].c_str() ) );
+         }
+         // 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("VisuGUI_SetupPlot2dDlg::getCurves : Exception has been caught (real)!!!");
+      }
+    }
+  }
+}
+/*!
+  Slot, called when any <H> button is clicked
+*/
+void VisuGUI_SetupPlot2dDlg::onHBtnToggled( bool on )
+{
+  VisuGUI_ItemContainer* item = ( VisuGUI_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 VisuGUI_SetupPlot2dDlg::onVBtnToggled( bool on )
+{
+  VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender();
+  QPtrList<VisuGUI_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 VisuGUI_SetupPlot2dDlg::enableControls()
+{
+  bool bHSet = false;
+  bool bVSet = false;
+  for ( int i = 0; i < myItems.count(); i++ ) {
+    if ( myItems.at( i )->isHorizontalOn() ) {
+      bHSet = true;
+      break;
+    }
+  }
+#ifndef WNT
+  for ( int i = 0; i < myItems.count(); i++ ) {
+#else
+  for ( i = 0; i < myItems.count(); i++ ) {
+#endif
+    if ( myItems.at( i )->isVerticalOn() )
+      bVSet = true;
+    myItems.at( i )->enableWidgets( bHSet && myItems.at( i )->isVerticalOn() );
+  }
+  myOkBtn->setEnabled( bHSet && bVSet );
+}
+
+// ====================================================================================
+/*!
+  Constructor
+*/
+VisuGUI_ItemContainer::VisuGUI_ItemContainer( QObject* parent, const char* name )
+     : QObject( parent, name ), 
+       myEnabled( true )
+{
+}
+/*!
+  Creates widgets
+*/
+void VisuGUI_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 );
+  myColorBtn->setMinimumWidth( 20 );
+  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 VisuGUI_ItemContainer::enableWidgets( bool enable )
+{
+  myEnabled = enable;
+  updateState();
+}
+/*!
+  Sets horizontal button's state on
+*/
+void VisuGUI_ItemContainer::setHorizontalOn( bool on )
+{
+  myHBtn->setOn( on );
+}
+/*!
+  Gets horizontal button's state
+*/
+bool VisuGUI_ItemContainer::isHorizontalOn() const
+{
+  return myHBtn->isOn();
+}
+/*!
+  Sets vertical button's state on
+*/
+void VisuGUI_ItemContainer::setVerticalOn( bool on )
+{
+  myVBtn->setOn( on );
+}
+/*!
+  Gets vertical button's state
+*/
+bool VisuGUI_ItemContainer::isVerticalOn() const
+{
+  return myVBtn->isOn();
+}
+/*!
+  Sets item AutoAssign flag state
+*/
+void VisuGUI_ItemContainer::setAutoAssign( bool on )
+{
+  myAutoCheck->setChecked( on );
+  updateState();
+}
+/*!
+  Gets item AutoAssign flag state
+*/
+bool VisuGUI_ItemContainer::isAutoAssign() const
+{
+  return myAutoCheck->isChecked();
+}
+/*!
+  Sets item line type and width
+*/
+void VisuGUI_ItemContainer::setLine( const int line, const int width )
+{
+  myLineCombo->setCurrentItem( line );
+}
+/*!
+  Gets item line type
+*/
+int VisuGUI_ItemContainer::getLine() const
+{
+  return myLineCombo->currentItem();
+}
+/*!
+  Gets item line width
+*/
+int VisuGUI_ItemContainer::getLineWidth() const
+{
+  return myLineSpin->value();
+}
+/*!
+  Sets item marker type
+*/
+void VisuGUI_ItemContainer::setMarker( const int marker )
+{
+  myMarkerCombo->setCurrentItem( marker );
+}
+/*!
+  Gets item marker type
+*/
+int VisuGUI_ItemContainer::getMarker() const
+{
+  return myMarkerCombo->currentItem();
+}
+/*!
+  Sets item color
+*/
+void VisuGUI_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 VisuGUI_ItemContainer::getColor() const
+{
+  return myColorBtn->palette().active().button();
+}
+/*!
+  Enables/disables widgets
+*/
+void VisuGUI_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 VisuGUI_ItemContainer::onAutoChanged()
+{
+  updateState();
+  emit( autoClicked() );
+}
+/*!
+  <Color> button slot, invokes color selection dialog box
+*/
+void VisuGUI_ItemContainer::onColorChanged()
+{
+  QColor color = QColorDialog::getColor( getColor() );
+  if ( color.isValid() ) {
+    setColor( color );
+  }
+}
+/*!
+  <H> and <V> buttons slot
+*/
+void VisuGUI_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/VISUGUI/VisuGUI_SetupPlot2dDlg.h b/src/VISUGUI/VisuGUI_SetupPlot2dDlg.h
new file mode 100644 (file)
index 0000000..1ce1e2a
--- /dev/null
@@ -0,0 +1,111 @@
+//  Copyright (C) 2003  CEA/DEN, EDF R&D
+//
+//
+//
+//  File   : VisuGUI_SetupPlot2dDlg.h
+//  Author : Vadim SANDLER
+//  Module : SALOME
+//  $Header$
+
+#ifndef VISUGUI_SetupPlot2dDlg_H
+#define VISUGUI_SetupPlot2dDlg_H
+
+#include "Plot2d_Curve.h"
+
+#include <SALOMEDSClient_SObject.hxx>
+
+#include <qdialog.h>
+#include <qptrlist.h>
+
+//=================================================================================
+// class    : VisuGUI_SetupPlot2dDlg
+// purpose  : Dialog box for setup Plot2d view
+//=================================================================================
+
+class QScrollView;
+class QPushButton;
+class QLabel;
+class QCheckBox;
+class QComboBox;
+class QSpinBox;
+class QToolButton;
+class VisuGUI_ItemContainer;
+
+class VisuGUI_SetupPlot2dDlg : public QDialog
+{ 
+  Q_OBJECT
+
+public:
+  VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, QWidget* parent = 0 );
+  ~VisuGUI_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<VisuGUI_ItemContainer> myItems;
+
+  _PTR(SObject)               myObject;
+};
+
+class VisuGUI_ItemContainer : public QObject
+{
+  Q_OBJECT
+
+public:
+  VisuGUI_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 // VISUGUI_SetupPlot2dDlg_H
+