Salome HOME
Dialog SetupCurveDlg has been added
authorvsv <vsv@opencascade.com>
Thu, 23 Jun 2005 12:41:50 +0000 (12:41 +0000)
committervsv <vsv@opencascade.com>
Thu, 23 Jun 2005 12:41:50 +0000 (12:41 +0000)
src/Plot2d/Makefile.in
src/Plot2d/Plot2d_SetupCurveDlg.cxx [new file with mode: 0644]
src/Plot2d/Plot2d_SetupCurveDlg.h [new file with mode: 0644]

index 6bd082a69d7de837085a05ccffcb975424c246c5..65ccacd41dd13ebe9db33c9dd7fea4efc56c168c 100755 (executable)
@@ -20,7 +20,8 @@ EXPORT_HEADERS= Plot2d.h \
                Plot2d_ViewFrame.h \
                Plot2d_ViewManager.h \
                Plot2d_ViewModel.h \
-               Plot2d_ViewWindow.h
+               Plot2d_ViewWindow.h \
+               Plot2d_SetupCurveDlg.h
 
 # .po files to transform in .qm
 PO_FILES = Plot2d_images.po \
@@ -35,7 +36,8 @@ LIB_SRC= Plot2d_Curve.cxx \
         Plot2d_ViewFrame.cxx \
         Plot2d_ViewManager.cxx \
         Plot2d_ViewModel.cxx \
-        Plot2d_ViewWindow.cxx          
+        Plot2d_ViewWindow.cxx \
+        Plot2d_SetupCurveDlg.cxx
 
 LIB_MOC = \
        Plot2d_FitDataDlg.h \
@@ -43,7 +45,8 @@ LIB_MOC = \
        Plot2d_ViewFrame.h \
        Plot2d_ViewManager.h \
        Plot2d_ViewModel.h \
-       Plot2d_ViewWindow.h 
+       Plot2d_ViewWindow.h \
+       Plot2d_SetupCurveDlg.h
 
 RESOURCES_FILES = \
 plot2d_clone.png \
diff --git a/src/Plot2d/Plot2d_SetupCurveDlg.cxx b/src/Plot2d/Plot2d_SetupCurveDlg.cxx
new file mode 100644 (file)
index 0000000..c0f0d5a
--- /dev/null
@@ -0,0 +1,200 @@
+//  SALOME Plot2d : implementation of desktop and GUI kernel
+//
+//  Copyright (C) 2003  CEA/DEN, EDF R&D
+//
+//
+//
+//  File   : Plot2d_SetupCurveDlg.cxx
+//  Author : Vadim SANDLER
+//  Module : SALOME
+//  $Header$
+
+#include "Plot2d_SetupCurveDlg.h"
+#include "SUIT_Tools.h"
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qcombobox.h>
+#include <qspinbox.h>
+#include <qtoolbutton.h>
+#include <qgroupbox.h>
+#include <qcolordialog.h>
+using namespace std;
+
+#define MARGIN_SIZE      11
+#define SPACING_SIZE     6
+#define MIN_COMBO_WIDTH  100
+#define MIN_SPIN_WIDTH   50
+#define MAX_LINE_WIDTH   100
+
+/*!
+  Constructor
+*/
+Plot2d_SetupCurveDlg::Plot2d_SetupCurveDlg( QWidget* parent )
+     : QDialog( parent, "Plot2d_SetupCurveDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+{
+  setCaption( tr("TLT_SETUP_CURVE") );
+  setSizeGripEnabled( TRUE );
+  QGridLayout* topLayout = new QGridLayout( this ); 
+  topLayout->setSpacing( SPACING_SIZE );
+  topLayout->setMargin( MARGIN_SIZE );
+
+  QGroupBox* TopGroup = new QGroupBox( this );
+  TopGroup->setColumnLayout( 0, Qt::Vertical );
+  TopGroup->layout()->setSpacing( 0 ); TopGroup->layout()->setMargin( 0 );
+  QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
+  TopGroupLayout->setAlignment( Qt::AlignTop );
+  TopGroupLayout->setSpacing( SPACING_SIZE ); TopGroupLayout->setMargin( MARGIN_SIZE );
+
+  QLabel* aLineTypeLab = new QLabel( tr( "CURVE_LINE_TYPE_LAB" ), TopGroup );
+  myLineCombo = new QComboBox( false, TopGroup );
+  myLineCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myLineCombo->setMinimumWidth( MIN_COMBO_WIDTH );
+  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
+
+  QLabel* aLineWidthLab = new QLabel( tr( "CURVE_LINE_WIDTH_LAB" ), TopGroup );
+  myLineSpin = new QSpinBox( 0, MAX_LINE_WIDTH, 1, TopGroup );
+  myLineSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myLineSpin->setMinimumWidth( MIN_SPIN_WIDTH );
+  myLineSpin->setValue( 0 );        // default width is 0
+
+  QLabel* aMarkerLab = new QLabel( tr( "CURVE_MARKER_TYPE_LAB" ), TopGroup );
+  myMarkerCombo = new QComboBox( false, TopGroup );
+  myMarkerCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myMarkerCombo->setMinimumWidth( MIN_COMBO_WIDTH );
+  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
+
+  QLabel* aColorLab = new QLabel( tr( "CURVE_COLOR_LAB" ), TopGroup );
+  myColorBtn = new QToolButton( TopGroup );
+  myColorBtn->setMinimumWidth(25);
+
+  TopGroupLayout->addWidget( aLineTypeLab, 0, 0 );
+  TopGroupLayout->addMultiCellWidget( myLineCombo, 0, 0, 1, 2 );
+  TopGroupLayout->addWidget( aLineWidthLab, 1, 0 );
+  TopGroupLayout->addMultiCellWidget( myLineSpin, 1, 1, 1, 2 );
+  TopGroupLayout->addWidget( aMarkerLab, 2, 0 );
+  TopGroupLayout->addMultiCellWidget( myMarkerCombo, 2, 2, 1, 2 );
+  TopGroupLayout->addWidget( aColorLab, 3, 0 );
+  TopGroupLayout->addWidget( myColorBtn, 3, 1 );
+  TopGroupLayout->setColStretch( 2, 5 );
+
+  QGroupBox* GroupButtons = new QGroupBox( this );
+  GroupButtons->setColumnLayout( 0, Qt::Vertical );
+  GroupButtons->layout()->setSpacing( 0 ); GroupButtons->layout()->setMargin( 0 );
+  QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() );
+  GroupButtonsLayout->setAlignment( Qt::AlignTop );
+  GroupButtonsLayout->setSpacing( SPACING_SIZE ); GroupButtonsLayout->setMargin( MARGIN_SIZE );
+
+  myOkBtn = new QPushButton( tr( "BUT_OK" ), GroupButtons );
+  myOkBtn->setAutoDefault( true ); myOkBtn->setDefault( true );
+  myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ) , GroupButtons );
+  myCancelBtn->setAutoDefault( true );
+
+  GroupButtonsLayout->addWidget( myOkBtn );
+  GroupButtonsLayout->addStretch();
+  GroupButtonsLayout->addWidget( myCancelBtn );
+
+  connect( myColorBtn,  SIGNAL( clicked() ), this, SLOT( onColorChanged() ) );
+  connect( myOkBtn,     SIGNAL( clicked() ), this, SLOT( accept() ) );
+  connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
+  setColor( QColor( 0, 0, 0 ) );
+
+  topLayout->addWidget( TopGroup,     0, 0 );
+  topLayout->addWidget( GroupButtons, 1, 0 );
+
+  SUIT_Tools::centerWidget( this, parent );
+}
+/*!
+  Destructor
+*/
+Plot2d_SetupCurveDlg::~Plot2d_SetupCurveDlg()
+{
+}
+/*!
+  Sets line style and width
+*/
+void Plot2d_SetupCurveDlg::setLine( const int line, const int width )
+{
+  myLineCombo->setCurrentItem( line );
+  myLineSpin->setValue( width );
+}
+/*!
+  Gets line style
+*/
+int Plot2d_SetupCurveDlg::getLine() const
+{
+  return myLineCombo->currentItem();
+}
+/*!
+  Gets line width
+*/
+int Plot2d_SetupCurveDlg::getLineWidth() const
+{
+  return myLineSpin->value();
+}
+/*!
+  Sets marker style
+*/
+void Plot2d_SetupCurveDlg::setMarker( const int marker )
+{
+  myMarkerCombo->setCurrentItem( marker );
+}
+/*!
+  Gets marker style
+*/
+int Plot2d_SetupCurveDlg::getMarker() const 
+{
+  return myMarkerCombo->currentItem();
+}
+/*!
+  Sets color
+*/
+void Plot2d_SetupCurveDlg::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 color
+*/
+QColor Plot2d_SetupCurveDlg::getColor() const 
+{
+  return myColorBtn->palette().active().button();
+}
+/*!
+  <Color> button slot, invokes color selection dialog box
+*/
+void Plot2d_SetupCurveDlg::onColorChanged()
+{
+  QColor color = QColorDialog::getColor( getColor() );
+  if ( color.isValid() ) {
+    setColor( color );
+  }
+}
+
+
+
+
+
diff --git a/src/Plot2d/Plot2d_SetupCurveDlg.h b/src/Plot2d/Plot2d_SetupCurveDlg.h
new file mode 100644 (file)
index 0000000..c9bea3a
--- /dev/null
@@ -0,0 +1,57 @@
+//  SALOME Plot2d : implementation of desktop and GUI kernel
+//
+//  Copyright (C) 2003  CEA/DEN, EDF R&D
+//
+//
+//
+//  File   : Plot2d_SetupCurveDlg.h
+//  Author : Vadim SANDLER
+//  Module : SALOME
+//  $Header$
+
+#ifndef Plot2d_SetupCurveDlg_H
+#define Plot2d_SetupCurveDlg_H
+
+#include <qdialog.h>
+
+//=================================================================================
+// class    : Plot2d_SetupCurveDlg
+// purpose  : Dialog box for setup Plot2d curve
+//=================================================================================
+
+class QPushButton;
+class QComboBox;
+class QSpinBox;
+class QToolButton;
+
+class Plot2d_SetupCurveDlg : public QDialog
+{ 
+  Q_OBJECT
+
+public:
+  Plot2d_SetupCurveDlg( QWidget* parent = 0 );
+  ~Plot2d_SetupCurveDlg();
+
+public:
+  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 slots:
+  void   onColorChanged();
+
+private:
+  QPushButton* myOkBtn;
+  QPushButton* myCancelBtn;
+  QComboBox*   myLineCombo;
+  QSpinBox*    myLineSpin;
+  QComboBox*   myMarkerCombo;
+  QToolButton* myColorBtn;
+};
+
+#endif // Plot2d_SetupCurveDlg_H
+