]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
GUITHARE 0002109: External 20696 2D 3D surfaces.
authorouv <ouv@opencascade.com>
Tue, 25 Mar 2014 07:57:46 +0000 (11:57 +0400)
committerouv <ouv@opencascade.com>
Tue, 25 Mar 2014 07:57:46 +0000 (11:57 +0400)
1) 4.29.2 Remove surfaces
2) 4.29.3 Fit range/zoom (partially)
3) 4.29.6 Legends

adm_local/win32/SVTK.vcproj
src/SVTK/Plot3d_FitDataDlg.cxx [new file with mode: 0644]
src/SVTK/Plot3d_FitDataDlg.h [new file with mode: 0644]
src/SVTK/Plot3d_SetupSurfacesDlg.cxx
src/SVTK/SVTK_FitDataDlg.cxx [new file with mode: 0644]
src/SVTK/SVTK_FitDataDlg.h [new file with mode: 0644]
src/SVTK/SVTK_ViewModel.cxx
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/SVTK_ViewWindow.h
src/SVTK/resources/SVTK_msg_en.ts

index 2591e62a22de4268cdf5e8e97c53970fbc2857dd..4f231d2894c86051ee228308969700fef3f2bd98 100644 (file)
                                        />
                                </FileConfiguration>
                        </File>
+                       <File
+                               RelativePath="..\..\src\SVTK\Plot3d_FitDataDlg.h"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generate moc_$(InputName).cxx..."
+                                               CommandLine="type $(InputPath) &gt; $(GUI_SRC_DIR)\$(ConfigurationName)\include\$(InputFileName)&#x0D;&#x0A;$(QTDIR)\bin\moc.exe $(InputPath) -o ..\..\moc\moc_$(InputName).cxx&#x0D;&#x0A;"
+                                               Outputs="$(GUI_SRC_DIR)\$(ConfigurationName)\include\$(InputFileName);..\..\moc\moc_$(InputName).cxx"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generate moc_$(InputName).cxx..."
+                                               CommandLine="type $(InputPath) &gt; $(GUI_SRC_DIR)\$(ConfigurationName)\include\$(InputFileName)&#x0D;&#x0A;$(QTDIR)\bin\moc.exe $(InputPath) -o ..\..\moc\moc_$(InputName).cxx&#x0D;&#x0A;"
+                                               Outputs="$(GUI_SRC_DIR)\$(ConfigurationName)\include\$(InputFileName);..\..\moc\moc_$(InputName).cxx"
+                                       />
+                               </FileConfiguration>
+                       </File>
                        <File
                                RelativePath="..\..\src\SVTK\Plot3d_SetupSurfacesDlg.h"
                                >
                                RelativePath="..\..\src\SVTK\Plot3d_Actor.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath="..\..\src\SVTK\Plot3d_FitDataDlg.cxx"
+                               >
+                       </File>
                        <File
                                RelativePath="..\..\src\SVTK\Plot3d_SetupSurfacesDlg.cxx"
                                >
                        Name="Meta Object Files"
                        Filter="moc_*.cxx"
                        >
+                       <File
+                               RelativePath="..\..\moc\moc_Plot3d_FitDataDlg.cxx"
+                               >
+                       </File>
                        <File
                                RelativePath="..\..\moc\moc_Plot3d_SetupSurfacesDlg.cxx"
                                >
diff --git a/src/SVTK/Plot3d_FitDataDlg.cxx b/src/SVTK/Plot3d_FitDataDlg.cxx
new file mode 100644 (file)
index 0000000..44db9e4
--- /dev/null
@@ -0,0 +1,286 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File   : Plot3d_FitDataDlg.cxx
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
+
+#include "Plot3d_FitDataDlg.h"
+
+#include <QLabel>
+#include <QLayout>
+#include <QValidator>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QGroupBox>
+#include <QLineEdit>
+
+#define SPACING_SIZE      6
+#define MARGIN_SIZE       11
+#define MIN_EDIT_SIZE     100
+
+/*!
+  Constructor 
+*/
+Plot3d_FitDataDlg::Plot3d_FitDataDlg( QWidget* parent, bool secondAxisY )
+     : QDialog( parent ? parent : 0,
+         Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
+       myY2MinEdit( 0 ), myY2MaxEdit( 0 ), mySecondAxisY( secondAxisY )
+{
+  setObjectName( "Plot3d_FitDataDlg" );
+  setModal( true );
+  setWindowTitle( tr( "FIT_DATA_TLT" ) );
+  setSizeGripEnabled( TRUE );
+  QGridLayout* topLayout = new QGridLayout( this ); 
+  topLayout->setSpacing( SPACING_SIZE );
+  topLayout->setMargin( MARGIN_SIZE );
+
+  // 'Range' group
+  myRangeGrp = new QGroupBox( this );
+  QGridLayout* aGridLayout = new QGridLayout( myRangeGrp );
+  myRangeGrp->setLayout( aGridLayout );
+  aGridLayout->setAlignment( Qt::AlignTop );
+  aGridLayout->setMargin( MARGIN_SIZE );
+  aGridLayout->setSpacing( SPACING_SIZE );
+
+  myModeAllRB  = new QRadioButton( tr( "FIT_ALL" ),        myRangeGrp );
+  myModeHorRB  = new QRadioButton( tr( "FIT_HORIZONTAL" ), myRangeGrp );
+  myModeVerRB  = new QRadioButton( tr( "FIT_VERTICAL" ),   myRangeGrp );
+
+  QDoubleValidator* aValidator = new QDoubleValidator( this );
+  myXMinEdit = new QLineEdit( myRangeGrp );
+  myXMinEdit->setValidator( aValidator );
+  myXMinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myXMinEdit->setMinimumSize( MIN_EDIT_SIZE, 0 );
+  myXMinEdit->setText( "0.0" );
+
+  myYMinEdit = new QLineEdit( myRangeGrp );
+  myYMinEdit->setValidator( aValidator );
+  myYMinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myYMinEdit->setMinimumSize( MIN_EDIT_SIZE, 0 );
+  myYMinEdit->setText( "0.0" );
+
+  myXMaxEdit = new QLineEdit( myRangeGrp );
+  myXMaxEdit->setValidator( aValidator );
+  myXMaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myXMaxEdit->setMinimumSize( MIN_EDIT_SIZE, 0 );
+  myXMaxEdit->setText( "0.0" );
+
+  myYMaxEdit = new QLineEdit( myRangeGrp );
+  myYMaxEdit->setValidator( aValidator );
+  myYMaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myYMaxEdit->setMinimumSize( MIN_EDIT_SIZE, 0 );
+  myYMaxEdit->setText( "0.0" );
+
+  if (mySecondAxisY) {
+    myY2MinEdit = new QLineEdit( myRangeGrp );
+    myY2MinEdit->setValidator( aValidator );
+    myY2MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+    myY2MinEdit->setMinimumSize( MIN_EDIT_SIZE, 0 );
+    myY2MinEdit->setText( "0.0" );
+
+    myY2MaxEdit = new QLineEdit( myRangeGrp );
+    myY2MaxEdit->setValidator( aValidator );
+    myY2MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+    myY2MaxEdit->setMinimumSize( MIN_EDIT_SIZE, 0 );
+    myY2MaxEdit->setText( "0.0" );
+  }
+
+  QFrame* aHLine = new QFrame( myRangeGrp );
+  aHLine->setFrameStyle( QFrame::HLine | QFrame::Sunken );
+
+  QHBoxLayout* aModeLayout = new QHBoxLayout;
+  aModeLayout->setMargin( 0 );
+  aModeLayout->setSpacing( SPACING_SIZE );
+  aModeLayout->addWidget( myModeAllRB );
+  aModeLayout->addWidget( myModeHorRB );
+  aModeLayout->addWidget( myModeVerRB );
+
+  QLabel* horLab = new QLabel( tr( "HORIZONTAL_AXIS" ), myRangeGrp );
+  QLabel* verLab = new QLabel( tr( "VERTICAL_AXIS" ), myRangeGrp );
+  if (mySecondAxisY)
+    verLab->setText( tr( "VERTICAL_LEFT_AXIS" ) );
+
+  QFont font = horLab->font(); font.setBold( true );
+  horLab->setFont( font ); verLab->setFont( font );
+
+  aGridLayout->addLayout( aModeLayout,    0, 0, 1, 5 );
+  aGridLayout->addWidget( aHLine,         1, 0, 1, 5 );
+  aGridLayout->addWidget( horLab,         2,    0 );
+  aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), 
+                                          2,    1 );
+  aGridLayout->addWidget( myXMinEdit,     2,    2 );
+  aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), 
+                                          2,    3 );
+  aGridLayout->addWidget( myXMaxEdit,     2,    4 );
+  aGridLayout->addWidget( verLab,         3,    0 );
+  aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), 
+                                          3,    1 );
+  aGridLayout->addWidget( myYMinEdit,     3,    2 );
+  aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), 
+                                          3,    3 );
+  aGridLayout->addWidget( myYMaxEdit,     3,    4 );
+
+  if (mySecondAxisY) {
+    QLabel* ver2Lab = new QLabel(tr( "VERTICAL_RIGHT_AXIS" ), myRangeGrp );
+    ver2Lab->setFont( font );
+    aGridLayout->addWidget( ver2Lab,        4,    0 );
+    aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), 
+                                            4,    1 );
+    aGridLayout->addWidget( myY2MinEdit,    4,    2 );
+    aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), 
+                                            4,    3 );
+    aGridLayout->addWidget( myY2MaxEdit,    4,    4 );
+  }
+
+  // OK/Cancel buttons
+  myOkBtn = new QPushButton( tr( "BUT_OK" ), this );
+  myOkBtn->setObjectName( "buttonOk" );
+  myOkBtn->setAutoDefault( TRUE );
+  myOkBtn->setDefault( TRUE );
+  myCancelBtn = new QPushButton(  tr( "BUT_CANCEL" ), this );
+  myCancelBtn->setObjectName( "buttonCancel" );
+  myCancelBtn->setAutoDefault( TRUE );
+
+  topLayout->addWidget( myRangeGrp, 0, 0, 1, 3 );
+  topLayout->addWidget( myOkBtn, 1, 0 );
+  topLayout->setColumnStretch( 1, 5 );
+  topLayout->addWidget( myCancelBtn, 1, 2 );
+
+  // connect signals
+  connect( myOkBtn,      SIGNAL( clicked() ),      this, SLOT( accept() ) );
+  connect( myCancelBtn,  SIGNAL( clicked() ),      this, SLOT( reject() ) );
+  connect( myRangeGrp,   SIGNAL( clicked( int ) ), this, SLOT( onModeChanged( int ) ) );
+
+  // initial state
+  myModeAllRB->setChecked( true );
+  onModeChanged( 0 );
+}
+
+/*!
+  Sets range
+*/
+void Plot3d_FitDataDlg::setRange( const double xMin, 
+                                  const double xMax,
+                                  const double yMin,
+                                  const double yMax,
+                                  const double y2Min,
+                                  const double y2Max) 
+{
+  myXMinEdit->setText( QString::number( xMin ) );
+  myXMaxEdit->setText( QString::number( xMax ) );
+  myYMinEdit->setText( QString::number( yMin ) );
+  myYMaxEdit->setText( QString::number( yMax ) );
+  if (mySecondAxisY) {
+    myY2MinEdit->setText( QString::number( y2Min ) );
+    myY2MaxEdit->setText( QString::number( y2Max ) );
+  }
+}
+
+/*!
+  Gets range, returns mode (see getMode())
+*/
+int Plot3d_FitDataDlg::getRange( double& xMin, 
+                                 double& xMax,
+                                 double& yMin,
+                                 double& yMax,
+                                 double& y2Min,
+                                 double& y2Max) 
+{
+  xMin = myXMinEdit->text().toDouble();
+  xMax = myXMaxEdit->text().toDouble();
+  yMin = myYMinEdit->text().toDouble();
+  yMax = myYMaxEdit->text().toDouble();
+  if (mySecondAxisY) {
+    y2Min = myY2MinEdit->text().toDouble();
+    y2Max = myY2MaxEdit->text().toDouble();
+  }
+  else {
+    y2Min = 0;
+    y2Max = 0;
+  }
+  int myMode = 0;
+  if ( myModeAllRB->isChecked() )
+    myMode = 0;
+  if ( myModeHorRB->isChecked() )
+    myMode = 1;
+  if ( myModeVerRB->isChecked() )
+    myMode = 2;
+  return myMode;
+}
+
+/*!
+  Gets mode : 0 - Fit all; 1 - Fit horizontal, 2 - Fit vertical
+*/
+int Plot3d_FitDataDlg::getMode() 
+{
+  int myMode = 0;
+  if ( myModeAllRB->isChecked() )
+    myMode = 0;
+  if ( myModeHorRB->isChecked() )
+    myMode = 1;
+  if ( myModeVerRB->isChecked() )
+    myMode = 2;
+  return myMode;
+}
+
+/*!
+  Called when range mode changed
+*/
+void Plot3d_FitDataDlg::onModeChanged(int mode) 
+{
+  bool badFocus;
+  switch( mode ) {
+  case 0: // fit all mode
+    myXMinEdit->setEnabled(true);
+    myXMaxEdit->setEnabled(true);
+    myYMinEdit->setEnabled(true);
+    myYMaxEdit->setEnabled(true);
+    if (mySecondAxisY) {
+      myY2MinEdit->setEnabled(true);
+      myY2MaxEdit->setEnabled(true);
+    }
+    break;
+  case 1: // fit horizontal mode
+    badFocus = myYMinEdit->hasFocus() || myYMaxEdit->hasFocus();
+    myXMinEdit->setEnabled(true);
+    myXMaxEdit->setEnabled(true);
+    myYMinEdit->setEnabled(false);
+    myYMaxEdit->setEnabled(false);
+    if (mySecondAxisY) {
+      myY2MinEdit->setEnabled(false);
+      myY2MaxEdit->setEnabled(false);
+    }
+    if (badFocus)
+      myXMinEdit->setFocus();
+    break;
+  case 2: // fit vertical mode
+    badFocus = myXMinEdit->hasFocus() || myXMaxEdit->hasFocus();
+    myXMinEdit->setEnabled(false);
+    myXMaxEdit->setEnabled(false);
+    myYMinEdit->setEnabled(true);
+    myYMaxEdit->setEnabled(true);
+    if (mySecondAxisY) {
+      myY2MinEdit->setEnabled(true);
+      myY2MaxEdit->setEnabled(true);
+    }
+    if (badFocus)
+      myYMinEdit->setFocus();
+    break;
+  }
+}
diff --git a/src/SVTK/Plot3d_FitDataDlg.h b/src/SVTK/Plot3d_FitDataDlg.h
new file mode 100644 (file)
index 0000000..5b5916a
--- /dev/null
@@ -0,0 +1,76 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef PLOT3D_FITDATADLG_H
+#define PLOT3D_FITDATADLG_H
+
+#include "SVTK.h"
+
+#include <QDialog>
+
+class QGroupBox;
+class QRadioButton;
+class QLineEdit;
+class QPushButton;
+
+class SVTK_EXPORT Plot3d_FitDataDlg : public QDialog
+{
+  Q_OBJECT
+
+public:
+// constuctor
+  Plot3d_FitDataDlg( QWidget* parent, bool secondAxisY );
+
+// sets range
+  void setRange(const double xMin, 
+                const double xMax,
+                const double yMin,
+                const double yMax,
+                const double y2Min = 0,
+                const double y2Max = 0);
+// gets range, returns mode (see getMode())
+  int getRange(double& xMin, 
+               double& xMax,
+               double& yMin,
+               double& yMax,
+               double& y2Min,
+               double& y2Max);
+// gets mode : 0 - Fit all; 1 - Fit horizontal, 2 - Fit vertical
+  int getMode();
+
+protected slots:
+// called when range mode changed
+  void onModeChanged(int);
+
+private:
+  QGroupBox*              myRangeGrp;
+  QRadioButton*           myModeAllRB;
+  QRadioButton*           myModeHorRB;
+  QRadioButton*           myModeVerRB;
+  QLineEdit*              myXMinEdit;
+  QLineEdit*              myYMinEdit;
+  QLineEdit*              myY2MinEdit;
+  QLineEdit*              myXMaxEdit;
+  QLineEdit*              myYMaxEdit;
+  QLineEdit*              myY2MaxEdit;
+  QPushButton*            myOkBtn;
+  QPushButton*            myCancelBtn;
+  bool                    mySecondAxisY;
+};
+
+#endif
index a1c1e49afea1e0d09a2ef93c2cbfae1cac4e4345..4fb7d4c621f24bf860d9f8e26379876e96f16cfc 100644 (file)
@@ -95,7 +95,7 @@ Plot3d_SetupSurfacesDlg::Plot3d_SetupSurfacesDlg( QWidget* theParent )
   connect( myTable, SIGNAL( valueChanged( int, int ) ), SLOT( onValueChanged( int, int ) ) );
 
   setButtonPosition( Right, Cancel );
-  setMinimumWidth( 500 );
+  setMinimumWidth( 300 );
   setMinimumHeight( 250 );
 }
 
diff --git a/src/SVTK/SVTK_FitDataDlg.cxx b/src/SVTK/SVTK_FitDataDlg.cxx
new file mode 100644 (file)
index 0000000..5f5cf18
--- /dev/null
@@ -0,0 +1,287 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File   : Plot2d_FitDataDlg.cxx
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
+
+#include "Plot2d_FitDataDlg.h"
+#include <QLabel>
+#include <QLayout>
+#include <QValidator>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QGroupBox>
+#include <QLineEdit>
+
+#define SPACING_SIZE      6
+#define MARGIN_SIZE       11
+#define MIN_EDIT_SIZE     100
+
+/*!
+  Constructor 
+*/
+Plot2d_FitDataDlg::Plot2d_FitDataDlg( QWidget* parent, bool secondAxisY )
+     : QDialog( parent ? parent : 0,
+         Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
+       myY2MinEdit( 0 ), myY2MaxEdit( 0 ), mySecondAxisY( secondAxisY )
+
+{
+  setObjectName( "Plot2d_FitDataDlg" );
+  setModal( true );
+  setWindowTitle( tr( "FIT_DATA_TLT" ) );
+  setSizeGripEnabled( TRUE );
+  QGridLayout* topLayout = new QGridLayout( this ); 
+  topLayout->setSpacing( SPACING_SIZE );
+  topLayout->setMargin( MARGIN_SIZE );
+
+  // 'Range' group
+  myRangeGrp = new QGroupBox( this );
+  QGridLayout* aGridLayout = new QGridLayout( myRangeGrp );
+  myRangeGrp->setLayout( aGridLayout );
+  aGridLayout->setAlignment( Qt::AlignTop );
+  aGridLayout->setMargin( MARGIN_SIZE );
+  aGridLayout->setSpacing( SPACING_SIZE );
+
+  myModeAllRB  = new QRadioButton( tr( "FIT_ALL" ),        myRangeGrp );
+  myModeHorRB  = new QRadioButton( tr( "FIT_HORIZONTAL" ), myRangeGrp );
+  myModeVerRB  = new QRadioButton( tr( "FIT_VERTICAL" ),   myRangeGrp );
+
+  QDoubleValidator* aValidator = new QDoubleValidator( this );
+  myXMinEdit = new QLineEdit( myRangeGrp );
+  myXMinEdit->setValidator( aValidator );
+  myXMinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myXMinEdit->setMinimumSize( MIN_EDIT_SIZE, 0 );
+  myXMinEdit->setText( "0.0" );
+
+  myYMinEdit = new QLineEdit( myRangeGrp );
+  myYMinEdit->setValidator( aValidator );
+  myYMinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myYMinEdit->setMinimumSize( MIN_EDIT_SIZE, 0 );
+  myYMinEdit->setText( "0.0" );
+
+  myXMaxEdit = new QLineEdit( myRangeGrp );
+  myXMaxEdit->setValidator( aValidator );
+  myXMaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myXMaxEdit->setMinimumSize( MIN_EDIT_SIZE, 0 );
+  myXMaxEdit->setText( "0.0" );
+
+  myYMaxEdit = new QLineEdit( myRangeGrp );
+  myYMaxEdit->setValidator( aValidator );
+  myYMaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  myYMaxEdit->setMinimumSize( MIN_EDIT_SIZE, 0 );
+  myYMaxEdit->setText( "0.0" );
+
+  if (mySecondAxisY) {
+    myY2MinEdit = new QLineEdit( myRangeGrp );
+    myY2MinEdit->setValidator( aValidator );
+    myY2MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+    myY2MinEdit->setMinimumSize( MIN_EDIT_SIZE, 0 );
+    myY2MinEdit->setText( "0.0" );
+
+    myY2MaxEdit = new QLineEdit( myRangeGrp );
+    myY2MaxEdit->setValidator( aValidator );
+    myY2MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+    myY2MaxEdit->setMinimumSize( MIN_EDIT_SIZE, 0 );
+    myY2MaxEdit->setText( "0.0" );
+  }
+
+  QFrame* aHLine = new QFrame( myRangeGrp );
+  aHLine->setFrameStyle( QFrame::HLine | QFrame::Sunken );
+
+  QHBoxLayout* aModeLayout = new QHBoxLayout;
+  aModeLayout->setMargin( 0 );
+  aModeLayout->setSpacing( SPACING_SIZE );
+  aModeLayout->addWidget( myModeAllRB );
+  aModeLayout->addWidget( myModeHorRB );
+  aModeLayout->addWidget( myModeVerRB );
+
+  QLabel* horLab = new QLabel( tr( "HORIZONTAL_AXIS" ), myRangeGrp );
+  QLabel* verLab = new QLabel( tr( "VERTICAL_AXIS" ), myRangeGrp );
+  if (mySecondAxisY)
+    verLab->setText( tr( "VERTICAL_LEFT_AXIS" ) );
+
+  QFont font = horLab->font(); font.setBold( true );
+  horLab->setFont( font ); verLab->setFont( font );
+
+  aGridLayout->addLayout( aModeLayout,    0, 0, 1, 5 );
+  aGridLayout->addWidget( aHLine,         1, 0, 1, 5 );
+  aGridLayout->addWidget( horLab,         2,    0 );
+  aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), 
+                                          2,    1 );
+  aGridLayout->addWidget( myXMinEdit,     2,    2 );
+  aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), 
+                                          2,    3 );
+  aGridLayout->addWidget( myXMaxEdit,     2,    4 );
+  aGridLayout->addWidget( verLab,         3,    0 );
+  aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), 
+                                          3,    1 );
+  aGridLayout->addWidget( myYMinEdit,     3,    2 );
+  aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), 
+                                          3,    3 );
+  aGridLayout->addWidget( myYMaxEdit,     3,    4 );
+
+  if (mySecondAxisY) {
+    QLabel* ver2Lab = new QLabel(tr( "VERTICAL_RIGHT_AXIS" ), myRangeGrp );
+    ver2Lab->setFont( font );
+    aGridLayout->addWidget( ver2Lab,        4,    0 );
+    aGridLayout->addWidget( new QLabel( tr( "MIN_VALUE_LAB" ), myRangeGrp ), 
+                                            4,    1 );
+    aGridLayout->addWidget( myY2MinEdit,    4,    2 );
+    aGridLayout->addWidget( new QLabel( tr( "MAX_VALUE_LAB" ), myRangeGrp ), 
+                                            4,    3 );
+    aGridLayout->addWidget( myY2MaxEdit,    4,    4 );
+  }
+
+  // OK/Cancel buttons
+  myOkBtn = new QPushButton( tr( "BUT_OK" ), this );
+  myOkBtn->setObjectName( "buttonOk" );
+  myOkBtn->setAutoDefault( TRUE );
+  myOkBtn->setDefault( TRUE );
+  myCancelBtn = new QPushButton(  tr( "BUT_CANCEL" ), this );
+  myCancelBtn->setObjectName( "buttonCancel" );
+  myCancelBtn->setAutoDefault( TRUE );
+
+  topLayout->addWidget( myRangeGrp, 0, 0, 1, 3 );
+  topLayout->addWidget( myOkBtn, 1, 0 );
+  topLayout->setColumnStretch( 1, 5 );
+  topLayout->addWidget( myCancelBtn, 1, 2 );
+
+  // connect signals
+  connect( myOkBtn,      SIGNAL( clicked() ),      this, SLOT( accept() ) );
+  connect( myCancelBtn,  SIGNAL( clicked() ),      this, SLOT( reject() ) );
+  connect( myRangeGrp,   SIGNAL( clicked( int ) ), this, SLOT( onModeChanged( int ) ) );
+
+  // initial state
+  myModeAllRB->setChecked( true );
+  onModeChanged( 0 );
+}
+
+/*!
+  Sets range
+*/
+void Plot2d_FitDataDlg::setRange( const double xMin, 
+                                  const double xMax,
+                                  const double yMin,
+                                  const double yMax,
+                                  const double y2Min,
+                                  const double y2Max) 
+{
+  myXMinEdit->setText( QString::number( xMin ) );
+  myXMaxEdit->setText( QString::number( xMax ) );
+  myYMinEdit->setText( QString::number( yMin ) );
+  myYMaxEdit->setText( QString::number( yMax ) );
+  if (mySecondAxisY) {
+    myY2MinEdit->setText( QString::number( y2Min ) );
+    myY2MaxEdit->setText( QString::number( y2Max ) );
+  }
+}
+
+/*!
+  Gets range, returns mode (see getMode())
+*/
+int Plot2d_FitDataDlg::getRange( double& xMin, 
+                                 double& xMax,
+                                 double& yMin,
+                                 double& yMax,
+                                 double& y2Min,
+                                 double& y2Max) 
+{
+  xMin = myXMinEdit->text().toDouble();
+  xMax = myXMaxEdit->text().toDouble();
+  yMin = myYMinEdit->text().toDouble();
+  yMax = myYMaxEdit->text().toDouble();
+  if (mySecondAxisY) {
+    y2Min = myY2MinEdit->text().toDouble();
+    y2Max = myY2MaxEdit->text().toDouble();
+  }
+  else {
+    y2Min = 0;
+    y2Max = 0;
+  }
+  int myMode = 0;
+  if ( myModeAllRB->isChecked() )
+    myMode = 0;
+  if ( myModeHorRB->isChecked() )
+    myMode = 1;
+  if ( myModeVerRB->isChecked() )
+    myMode = 2;
+  return myMode;
+}
+
+/*!
+  Gets mode : 0 - Fit all; 1 - Fit horizontal, 2 - Fit vertical
+*/
+int Plot2d_FitDataDlg::getMode() 
+{
+  int myMode = 0;
+  if ( myModeAllRB->isChecked() )
+    myMode = 0;
+  if ( myModeHorRB->isChecked() )
+    myMode = 1;
+  if ( myModeVerRB->isChecked() )
+    myMode = 2;
+  return myMode;
+}
+
+/*!
+  Called when range mode changed
+*/
+void Plot2d_FitDataDlg::onModeChanged(int mode) 
+{
+  bool badFocus;
+  switch( mode ) {
+  case 0: // fit all mode
+    myXMinEdit->setEnabled(true);
+    myXMaxEdit->setEnabled(true);
+    myYMinEdit->setEnabled(true);
+    myYMaxEdit->setEnabled(true);
+    if (mySecondAxisY) {
+      myY2MinEdit->setEnabled(true);
+      myY2MaxEdit->setEnabled(true);
+    }
+    break;
+  case 1: // fit horizontal mode
+    badFocus = myYMinEdit->hasFocus() || myYMaxEdit->hasFocus();
+    myXMinEdit->setEnabled(true);
+    myXMaxEdit->setEnabled(true);
+    myYMinEdit->setEnabled(false);
+    myYMaxEdit->setEnabled(false);
+    if (mySecondAxisY) {
+      myY2MinEdit->setEnabled(false);
+      myY2MaxEdit->setEnabled(false);
+    }
+    if (badFocus)
+      myXMinEdit->setFocus();
+    break;
+  case 2: // fit vertical mode
+    badFocus = myXMinEdit->hasFocus() || myXMaxEdit->hasFocus();
+    myXMinEdit->setEnabled(false);
+    myXMaxEdit->setEnabled(false);
+    myYMinEdit->setEnabled(true);
+    myYMaxEdit->setEnabled(true);
+    if (mySecondAxisY) {
+      myY2MinEdit->setEnabled(true);
+      myY2MaxEdit->setEnabled(true);
+    }
+    if (badFocus)
+      myYMinEdit->setFocus();
+    break;
+  }
+}
+
diff --git a/src/SVTK/SVTK_FitDataDlg.h b/src/SVTK/SVTK_FitDataDlg.h
new file mode 100644 (file)
index 0000000..096a8ba
--- /dev/null
@@ -0,0 +1,75 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef PLOT2D_FITDATADLG_H
+#define PLOT2D_FITDATADLG_H
+
+#include "Plot2d.h"
+#include <QDialog>
+
+class QGroupBox;
+class QRadioButton;
+class QLineEdit;
+class QPushButton;
+
+class PLOT2D_EXPORT Plot2d_FitDataDlg : public QDialog
+{
+  Q_OBJECT
+
+public:
+// constuctor
+  Plot2d_FitDataDlg( QWidget* parent, bool secondAxisY );
+
+// sets range
+  void setRange(const double xMin, 
+                const double xMax,
+                const double yMin,
+                const double yMax,
+                const double y2Min = 0,
+                const double y2Max = 0);
+// gets range, returns mode (see getMode())
+  int getRange(double& xMin, 
+               double& xMax,
+               double& yMin,
+               double& yMax,
+               double& y2Min,
+               double& y2Max);
+// gets mode : 0 - Fit all; 1 - Fit horizontal, 2 - Fit vertical
+  int getMode();
+
+protected slots:
+// called when range mode changed
+  void onModeChanged(int);
+
+private:
+  QGroupBox*              myRangeGrp;
+  QRadioButton*           myModeAllRB;
+  QRadioButton*           myModeHorRB;
+  QRadioButton*           myModeVerRB;
+  QLineEdit*              myXMinEdit;
+  QLineEdit*              myYMinEdit;
+  QLineEdit*              myY2MinEdit;
+  QLineEdit*              myXMaxEdit;
+  QLineEdit*              myYMaxEdit;
+  QLineEdit*              myY2MaxEdit;
+  QPushButton*            myOkBtn;
+  QPushButton*            myCancelBtn;
+  bool                    mySecondAxisY;
+};
+
+#endif
index bbaf40ded90f99b82c15b1259bd69b7ffb2445ba..c84b84bc7ded6c47b5a00250a803551a0835175a 100644 (file)
@@ -324,6 +324,13 @@ void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager)
 */
 void SVTK_Viewer::contextMenuPopup( QMenu* thePopup )
 {
+  SVTK_ViewWindow* aView = (SVTK_ViewWindow*)myViewManager->getActiveView();
+  if( aView )
+    aView->contextMenuPopup( thePopup );
+
+  if( !thePopup->isEmpty() )
+    thePopup->addSeparator();
+
   thePopup->addAction( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
   thePopup->addAction( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) );
 
index ad94c7c189ba1607aaec6b248932d675dabe8dce..5df7b7edc49b02c57ef639ad0ba6ba87bd7cdd33 100755 (executable)
 #include "SVTK_ViewParameterDlg.h"
 
 #include "Plot3d_Actor.h"
+#include "Plot3d_FitDataDlg.h"
 #include "Plot3d_SetupSurfacesDlg.h"
 
 #include "SALOME_Actor.h"
 
+#include <QMenu>
 #include <QToolBar>
 #include <QEvent>
 #include <QXmlStreamWriter>
@@ -44,6 +46,7 @@
 #include <vtkAxisActor2D.h>
 #include <vtkGL2PSExporter.h>
 #include <vtkInteractorStyle.h>
+#include <vtkScalarBarActor.h>
 
 #include "QtxAction.h"
 
@@ -233,6 +236,15 @@ void SVTK_ViewWindow::Initialize(SVTK_View* theView,
 SVTK_ViewWindow::~SVTK_ViewWindow()
 {}
 
+/*!
+  Fill the context menu
+  \param thePopup context menu
+*/
+void SVTK_ViewWindow::contextMenuPopup( QMenu* thePopup )
+{
+  if( myMode2D )
+    thePopup->addAction( tr( "TOT_SVTK_FITDATA" ), this, SLOT( onFitData() ) );
+}
 
 /*!
   \return corresponding view
@@ -2259,7 +2271,8 @@ void SVTK_ViewWindow::onSurfacesSettings()
     if( Plot3d_Actor* aSurface = dynamic_cast<Plot3d_Actor*>( anActor ) )
     {
       aSurfaces << aSurface;
-      aNameList << aSurface->getName();
+      if( vtkScalarBarActor* aScalarBar = aSurface->GetScalarBarActor().GetPointer() )
+        aNameList << aScalarBar->GetTitle();
     }
   }
 
@@ -2285,6 +2298,7 @@ void SVTK_ViewWindow::onSurfacesSettings()
       Plot3d_Actor* aSurface = aSurfaces[ anIndex ];
       aSurfaces.removeAt( anIndex );
       aSurface->RemoveFromRender( aRenderer );
+      aSurface->Delete();
     }
   }
 
@@ -2301,7 +2315,8 @@ void SVTK_ViewWindow::onSurfacesSettings()
   {
     Plot3d_Actor* aSurface = anIndexToSurface[ i ];
     QString aText = aTexts[ i ];
-    aSurface->setName( aText.toLatin1().constData() );
+    if( vtkScalarBarActor* aScalarBar = aSurface->GetScalarBarActor().GetPointer() )
+      aScalarBar->SetTitle( aText.toLatin1().constData() );
   }
 
   vtkFloatingPointType aGlobalBounds[6] = { VTK_DOUBLE_MAX, VTK_DOUBLE_MIN,
@@ -2339,3 +2354,11 @@ void SVTK_ViewWindow::onSurfacesSettings()
   SetScale( aScale );
   onFitAll();
 }
+
+/*!
+  Fit 2D surfaces to the specified data range
+*/
+void SVTK_ViewWindow::onFitData()
+{
+  // to do
+}
index 3df84190c19ba85040cc7c88cb2ae1bb21f5b030..14b3e6cea5b338f52b0a8c4da625ac927127b001 100755 (executable)
@@ -97,6 +97,9 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
   //! To initialize #SVTK_ViewWindow instance
   virtual void Initialize(SVTK_ViewModelBase* theModel);
 
+  //! Fill the context menu
+  void contextMenuPopup( QMenu* thePopup );
+
   //! Get #SVTK_View
   SVTK_View* getView();
 
@@ -312,6 +315,8 @@ public slots:
 
   void onSurfacesSettings();
 
+  void onFitData();
+
   void onStartRecording();
   void onPlayRecording();
   void onPauseRecording();
index a31323cdebc61920b94112a53df06f8f3282a139..987cb7c0ffd9644157e97d5dab8d4f092cb3ce9c 100644 (file)
         <translation>Tool jpeg2yuv, necessary for AVI recording, is not available.
 Please, refer to the documentation.</translation>
     </message>
+    <message>
+        <source>TOT_SVTK_FITDATA</source>
+        <translation>Fit range</translation>
+    </message>
 </context>
 <context>
     <name>SVTK_NonIsometricDlg</name>
@@ -625,6 +629,45 @@ Please, refer to the documentation.</translation>
         <translation>Change background...</translation>
     </message>
 </context>
+<context>
+    <name>Plot3d_FitDataDlg</name>
+    <message>
+        <source>FIT_HORIZONTAL</source>
+        <translation>Fit horizontally</translation>
+    </message>
+    <message>
+        <source>MIN_VALUE_LAB</source>
+        <translation>Min:</translation>
+    </message>
+    <message>
+        <source>VERTICAL_AXIS</source>
+        <translation>Vertical axis</translation>
+    </message>
+    <message>
+        <source>MAX_VALUE_LAB</source>
+        <translation>Max:</translation>
+    </message>
+    <message>
+        <source>HORIZONTAL_AXIS</source>
+        <translation>Horizontal axis</translation>
+    </message>
+    <message>
+        <source>VERTICAL_LEFT_AXIS</source>
+        <translation>Vertical left axis</translation>
+    </message>
+    <message>
+        <source>FIT_ALL</source>
+        <translation>Fit both</translation>
+    </message>
+    <message>
+        <source>VERTICAL_RIGHT_AXIS</source>
+        <translation>Vertical right axis</translation>
+    </message>
+    <message>
+        <source>FIT_VERTICAL</source>
+        <translation>Fit vertically</translation>
+    </message>
+</context>
 <context>
     <name>Plot3d_SetupSurfacesDlg</name>
     <message>