From: ouv Date: Thu, 30 Sep 2010 14:49:34 +0000 (+0000) Subject: Issue 0020874: [CEA] Graduated axes in GEOM X-Git-Tag: V5_1_5a1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e6f2c3d6970727bebc8a54a7039880c8550248fa;p=modules%2Fgui.git Issue 0020874: [CEA] Graduated axes in GEOM --- diff --git a/configure.ac b/configure.ac index bc7d43df9..2ccf2effd 100644 --- a/configure.ac +++ b/configure.ac @@ -625,6 +625,7 @@ AC_OUTPUT([ \ src/ObjBrowser/Makefile \ src/Prs/Makefile \ src/OBJECT/Makefile \ + src/ViewerTools/Makefile \ src/GLViewer/Makefile \ src/VTKViewer/Makefile \ src/SVTK/Makefile \ diff --git a/doc/salome/gui/images/graduatedaxes2.png b/doc/salome/gui/images/graduatedaxes2.png new file mode 100644 index 000000000..aa9dbf3cc Binary files /dev/null and b/doc/salome/gui/images/graduatedaxes2.png differ diff --git a/doc/salome/gui/input/occ_3d_viewer.doc b/doc/salome/gui/input/occ_3d_viewer.doc index dcadc8d28..5bd68e886 100644 --- a/doc/salome/gui/input/occ_3d_viewer.doc +++ b/doc/salome/gui/input/occ_3d_viewer.doc @@ -126,6 +126,42 @@ viewer. \image html occviewer_axialscale.png \n
Scaling - represents objects deformed (stretched or stuffed) along the axes of coordinates.
+
+ +\image html image109.png +\n
Graduated axes - allows to define parameters of axes +and graduate them (available only with Open CASCADE 6.3 service pack 10)
+ +\image html graduatedaxes2.png + + +
Note! OCC Viewer features a special Polyline Selection mechanism, which allows selecting an arbitraty part of the graphic area using a polygon frame, instead of the usual selection with a rectangular frame. diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index bdfbfae04..ba6c4c54e 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -60,6 +60,7 @@ + diff --git a/src/Makefile.am b/src/Makefile.am index 8b684ec2e..7d4de20d2 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -49,6 +49,7 @@ if ENABLE_VTKVIEWER SUBDIRS_VTKVIEWER = VTKViewer if ENABLE_SALOMEOBJECT SUBDIRS_VTKVIEWER += SVTK + SUBDIRS_VIEWERTOOLS = ViewerTools endif endif @@ -57,6 +58,7 @@ endif ## if ENABLE_OCCVIEWER SUBDIRS_OCCVIEWER = OCCViewer + SUBDIRS_VIEWERTOOLS = ViewerTools if ENABLE_SALOMEOBJECT SUBDIRS_OCCVIEWER += SOCC endif @@ -114,10 +116,10 @@ if ENABLE_PYCONSOLE SUBDIRS_PY_LIGHT = SALOME_SWIG SALOME_PY SALOME_PYQT endif -SUBDIRS = $(SUBDIRS_COMMON) $(SUBDIRS_OBJECT) $(SUBDIRS_GLVIEWER) $(SUBDIRS_VTKVIEWER) $(SUBDIRS_OCCVIEWER) \ - $(SUBDIRS_PLOT2DVIEWER) $(SUBDIRS_SUPERVGRAPHVIEWER) $(SUBDIRS_QXGRAPHVIEWER) $(SUBDIRS_PYCONSOLE) \ - $(SUBDIRS_LIGHT) $(SUBDIRS_CORBA) $(SUBDIRS_PY_LIGHT) +SUBDIRS = $(SUBDIRS_COMMON) $(SUBDIRS_OBJECT) $(SUBDIRS_VIEWERTOOLS) $(SUBDIRS_GLVIEWER) $(SUBDIRS_VTKVIEWER) \ + $(SUBDIRS_OCCVIEWER) $(SUBDIRS_PLOT2DVIEWER) $(SUBDIRS_SUPERVGRAPHVIEWER) $(SUBDIRS_QXGRAPHVIEWER) \ + $(SUBDIRS_PYCONSOLE) $(SUBDIRS_LIGHT) $(SUBDIRS_CORBA) $(SUBDIRS_PY_LIGHT) DIST_SUBDIRS = CASCatch Qtx Style DDS QDS ObjBrowser SUIT SUITApp STD CAF CAM LogWindow Prs Event OpenGLUtils \ - OBJECT GLViewer VTKViewer SVTK OCCViewer SOCC Plot2d SPlot2d SUPERVGraph QxGraph QxScene \ + OBJECT ViewerTools GLViewer VTKViewer SVTK OCCViewer SOCC Plot2d SPlot2d SUPERVGraph QxGraph QxScene \ PyInterp PyConsole LightApp ResExporter TOOLSGUI Session SalomeApp SALOME_SWIG SALOME_PY SALOME_PYQT diff --git a/src/OCCViewer/Makefile.am b/src/OCCViewer/Makefile.am index a9ab7c7c7..4d56e731b 100755 --- a/src/OCCViewer/Makefile.am +++ b/src/OCCViewer/Makefile.am @@ -44,6 +44,8 @@ salomeinclude_HEADERS = \ OCCViewer_AxialScaleDlg.h \ OCCViewer_SetRotationPointDlg.h \ OCCViewer_Trihedron.h \ + OCCViewer_FontWidget.h \ + OCCViewer_CubeAxesDlg.h \ OCCViewer_ToolTip.h dist_libOCCViewer_la_SOURCES = \ @@ -60,6 +62,8 @@ dist_libOCCViewer_la_SOURCES = \ OCCViewer_ClippingDlg.cxx \ OCCViewer_AxialScaleDlg.cxx \ OCCViewer_Trihedron.cxx \ + OCCViewer_FontWidget.cxx \ + OCCViewer_CubeAxesDlg.cxx \ OCCViewer_ToolTip.cxx MOC_FILES = \ @@ -74,8 +78,10 @@ MOC_FILES = \ OCCViewer_SetRotationPointDlg_moc.cxx \ OCCViewer_ClippingDlg_moc.cxx \ OCCViewer_AxialScaleDlg_moc.cxx \ + OCCViewer_FontWidget_moc.cxx \ + OCCViewer_CubeAxesDlg_moc.cxx \ OCCViewer_ToolTip_moc.cxx - + nodist_libOCCViewer_la_SOURCES = $(MOC_FILES) dist_salomeres_DATA = \ @@ -86,6 +92,7 @@ dist_salomeres_DATA = \ resources/occ_view_clipping.png \ resources/occ_view_clipping_pressed.png \ resources/occ_view_scaling.png \ + resources/occ_view_graduated_axes.png \ resources/occ_view_ambient.png \ resources/occ_view_fitall.png \ resources/occ_view_fitarea.png \ @@ -109,7 +116,9 @@ nodist_salomeres_DATA = \ OCCViewer_msg_fr.qm libOCCViewer_la_CPPFLAGS = $(QT_INCLUDES) $(OGL_INCLUDES) $(CAS_CPPFLAGS) \ - -I$(srcdir)/../SUIT -I$(srcdir)/../Qtx -I$(srcdir)/../OpenGLUtils + -I$(srcdir)/../SUIT -I$(srcdir)/../ViewerTools -I$(srcdir)/../Qtx \ + -I$(srcdir)/../OpenGLUtils libOCCViewer_la_LDFLAGS = $(OGL_LIBS) $(QT_MT_LIBS) $(CAS_KERNEL) $(CAS_VIEWER) -libOCCViewer_la_LIBADD = ../Qtx/libqtx.la ../SUIT/libsuit.la ../OpenGLUtils/libOpenGLUtils.la +libOCCViewer_la_LIBADD = ../Qtx/libqtx.la ../SUIT/libsuit.la \ + ../ViewerTools/libViewerTools.la ../OpenGLUtils/libOpenGLUtils.la diff --git a/src/OCCViewer/OCCViewer_CubeAxesDlg.cxx b/src/OCCViewer/OCCViewer_CubeAxesDlg.cxx new file mode 100644 index 000000000..198b0f57a --- /dev/null +++ b/src/OCCViewer/OCCViewer_CubeAxesDlg.cxx @@ -0,0 +1,321 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// + +#include "OCCViewer_CubeAxesDlg.h" + +#include "OCCViewer_FontWidget.h" +#include "OCCViewer_ViewPort3d.h" +#include "OCCViewer_ViewWindow.h" + +#include "QtxAction.h" +#include "QtxIntSpinBox.h" + +#include +#include +#include + +#include + +#ifdef OCC_VERSION_SERVICEPACK +#define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8 | OCC_VERSION_SERVICEPACK) +#else +#define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8) +#endif + +/*! + \class OCCViewer_CubeAxesDlg::AxisWidget + \brief Axis tab widget of the "Graduated axis" dialog box + \internal +*/ + +/*! + Constructor +*/ +OCCViewer_AxisWidget::OCCViewer_AxisWidget (QWidget* theParent) +: ViewerTools_AxisWidgetBase(theParent) +{ +} + +/*! + Destructor +*/ +OCCViewer_AxisWidget::~OCCViewer_AxisWidget() +{ +} + +/*! + Create font widget +*/ +ViewerTools_FontWidgetBase* OCCViewer_AxisWidget::createFontWidget( QWidget* theParent ) +{ + OCCViewer_FontWidget* aFontWidget = new OCCViewer_FontWidget( theParent ); + aFontWidget->Initialize(); + return aFontWidget; +} + +/*! + Set axis data +*/ +void OCCViewer_AxisWidget::SetData( const AxisData& theAxisData ) +{ + myNameGrp->setChecked( theAxisData.DrawName ); + myAxisName->setText( theAxisData.Name ); + myNameFont->SetData( theAxisData.NameColor, 0, false, false, false ); + + myLabelsGrp->setChecked( theAxisData.DrawValues ); + myLabelNumber->setValue( theAxisData.NbValues ); + myLabelOffset->setValue( theAxisData.Offset ); + myLabelsFont->SetData( theAxisData.Color, 0, false, false, false ); + + myTicksGrp->setChecked( theAxisData.DrawTickmarks ); + myTickLength->setValue( theAxisData.TickmarkLength ); +} + +/*! + Get axis data +*/ +void OCCViewer_AxisWidget::GetData( AxisData& theAxisData ) +{ + theAxisData.DrawName = myNameGrp->isChecked(); + theAxisData.Name = myAxisName->text(); + + int aNameFamily; + bool aNameBold, aNameItalic, aNameShadow; + myNameFont->GetData( theAxisData.NameColor, aNameFamily, aNameBold, aNameItalic, aNameShadow ); + + theAxisData.DrawValues = myLabelsGrp->isChecked(); + theAxisData.NbValues = myLabelNumber->value(); + theAxisData.Offset = myLabelOffset->value(); + + int aLabelFamily; + bool aLabelBold, aLabelItalic, aLabelShadow; + myLabelsFont->GetData( theAxisData.Color, aLabelFamily, aLabelBold, aLabelItalic, aLabelShadow ); + + theAxisData.DrawTickmarks = myTicksGrp->isChecked(); + theAxisData.TickmarkLength = myTickLength->value(); +} + +/* + Class : OCCViewer_CubeAxesDlg + Description : Dialog for specifying cube axes properties +*/ + +/*! + Constructor +*/ +OCCViewer_CubeAxesDlg::OCCViewer_CubeAxesDlg(QtxAction* theAction, + OCCViewer_ViewWindow* theParent, + const char* theName): + ViewerTools_CubeAxesDlgBase(theAction, + theParent, + theName), + myMainWindow(theParent) +{ +} + +/*! + Destructor +*/ +OCCViewer_CubeAxesDlg::~OCCViewer_CubeAxesDlg() +{ +} + +/*! + Create axis widget +*/ +ViewerTools_AxisWidgetBase* OCCViewer_CubeAxesDlg::createAxisWidget( QWidget* theParent ) +{ + OCCViewer_AxisWidget* anAxisWidget = new OCCViewer_AxisWidget( theParent ); + anAxisWidget->initialize(); + return anAxisWidget; +} + +/*! + Update dialog fields, connect signals and slots, show dialog +*/ +void OCCViewer_CubeAxesDlg::initialize() +{ + ViewerTools_CubeAxesDlgBase::initialize(); + + for( int i = 0; i < 3; i++ ) + { + if( OCCViewer_AxisWidget* anAxisWidget = dynamic_cast( myAxes[ i ] ) ) + { + OCCViewer_AxisWidget::AxisData anAxisData; + switch( i ) + { + case 0: + anAxisData.Name = "X"; + anAxisData.NameColor = anAxisData.Color = Qt::red; + break; + case 1: + anAxisData.Name = "Y"; + anAxisData.NameColor = anAxisData.Color = Qt::green; + break; + case 2: + anAxisData.Name = "Z"; + anAxisData.NameColor = anAxisData.Color = Qt::blue; + break; + } + anAxisData.DrawName = true; + anAxisData.DrawValues = true; + anAxisData.NbValues = 3; + anAxisData.Offset = 2; + anAxisData.DrawTickmarks = true; + anAxisData.TickmarkLength = 5; + anAxisWidget->SetData( anAxisData ); + } + } +} + +/*! + Update dialog fields, connect signals and slots, show dialog +*/ +void OCCViewer_CubeAxesDlg::Update() +{ + ViewerTools_CubeAxesDlgBase::Update(); +} + +/*! + Verify validity of entry data +*/ +bool OCCViewer_CubeAxesDlg::onApply() +{ + bool isOk = ViewerTools_CubeAxesDlgBase::onApply(); + + try + { + QWidget *aCurrWid = this->focusWidget(); + aCurrWid->clearFocus(); + aCurrWid->setFocus(); + + if( OCCViewer_ViewPort3d* aViewPort = myMainWindow->getViewPort() ) + { + Handle(V3d_View) aView = aViewPort->getView(); + if( !aView.IsNull() ) + ApplyData( aView ); + } + } + catch(...) + { + isOk = false; + } + + return isOk; +} + +/*! + Get graduated trihedron parameters +*/ +void OCCViewer_CubeAxesDlg::GetData( bool& theIsVisible, OCCViewer_AxisWidget::AxisData theAxisData[3] ) +{ + theIsVisible = myIsVisible->isChecked(); + for( int i = 0; i < 3; i++ ) + if( OCCViewer_AxisWidget* anAxisWidget = dynamic_cast( myAxes[ i ] ) ) + anAxisWidget->GetData( theAxisData[i] ); +} + +/*! + Set graduated trihedron parameters +*/ +void OCCViewer_CubeAxesDlg::SetData( bool theIsVisible, OCCViewer_AxisWidget::AxisData theAxisData[3] ) +{ + myIsVisible->setChecked( theIsVisible ); + for( int i = 0; i < 3; i++ ) + if( OCCViewer_AxisWidget* anAxisWidget = dynamic_cast( myAxes[ i ] ) ) + anAxisWidget->SetData( theAxisData[i] ); +} + +/*! + Apply graduated trihedron parameters +*/ +void OCCViewer_CubeAxesDlg::ApplyData( const Handle(V3d_View)& theView ) +{ +#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version + if( theView.IsNull() ) + return; + + if( myIsVisible->isChecked() ) + { + OCCViewer_AxisWidget::AxisData anAxisData[3]; + for( int i = 0; i < 3; i++ ) + if( OCCViewer_AxisWidget* anAxisWidget = dynamic_cast( myAxes[ i ] ) ) + anAxisWidget->GetData( anAxisData[i] ); + + theView->GraduatedTrihedronDisplay( + anAxisData[0].Name.toLatin1().constData(), + anAxisData[1].Name.toLatin1().constData(), + anAxisData[2].Name.toLatin1().constData(), + anAxisData[0].DrawName, + anAxisData[1].DrawName, + anAxisData[2].DrawName, + anAxisData[0].DrawValues, + anAxisData[1].DrawValues, + anAxisData[2].DrawValues, + Standard_True, // draw grid + anAxisData[0].NbValues - 1, + anAxisData[1].NbValues - 1, + anAxisData[2].NbValues - 1, + anAxisData[0].Offset, + anAxisData[1].Offset, + anAxisData[2].Offset, + anAxisData[0].Offset + 20, // tmp + anAxisData[1].Offset + 20, // tmp + anAxisData[2].Offset + 20, // tmp + anAxisData[0].DrawTickmarks, + anAxisData[1].DrawTickmarks, + anAxisData[2].DrawTickmarks, + anAxisData[0].TickmarkLength, + anAxisData[1].TickmarkLength, + anAxisData[2].TickmarkLength, + Quantity_NOC_WHITE, // grid color + Quantity_Color( anAxisData[0].NameColor.redF(), + anAxisData[0].NameColor.greenF(), + anAxisData[0].NameColor.blueF(), + Quantity_TOC_RGB ), + Quantity_Color( anAxisData[1].NameColor.redF(), + anAxisData[1].NameColor.greenF(), + anAxisData[1].NameColor.blueF(), + Quantity_TOC_RGB ), + Quantity_Color( anAxisData[2].NameColor.redF(), + anAxisData[2].NameColor.greenF(), + anAxisData[2].NameColor.blueF(), + Quantity_TOC_RGB ), + Quantity_Color( anAxisData[0].Color.redF(), + anAxisData[0].Color.greenF(), + anAxisData[0].Color.blueF(), + Quantity_TOC_RGB ), + Quantity_Color( anAxisData[1].Color.redF(), + anAxisData[1].Color.greenF(), + anAxisData[1].Color.blueF(), + Quantity_TOC_RGB ), + Quantity_Color( anAxisData[2].Color.redF(), + anAxisData[2].Color.greenF(), + anAxisData[2].Color.blueF(), + Quantity_TOC_RGB ) ); + } + else + theView->GraduatedTrihedronErase(); + + theView->Redraw(); +#endif +} diff --git a/src/OCCViewer/OCCViewer_CubeAxesDlg.h b/src/OCCViewer/OCCViewer_CubeAxesDlg.h new file mode 100644 index 000000000..b570d380c --- /dev/null +++ b/src/OCCViewer/OCCViewer_CubeAxesDlg.h @@ -0,0 +1,99 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 OCCVIEWER_CUBEAXESDLG_H +#define OCCVIEWER_CUBEAXESDLG_H + +#include "OCCViewer.h" + +#include + +#include + +class OCCViewer_ViewWindow; + +/*! + * Class : OCCViewer_AxisWidget + * Description : Axis tab widget of the "Graduated axis" dialog box +*/ +class OCCVIEWER_EXPORT OCCViewer_AxisWidget : public ViewerTools_AxisWidgetBase +{ +public: + struct AxisData + { + bool DrawName; + QString Name; + QColor NameColor; + bool DrawValues; + int NbValues; + int Offset; + QColor Color; + bool DrawTickmarks; + int TickmarkLength; + }; + +public: + OCCViewer_AxisWidget( QWidget* ); + ~OCCViewer_AxisWidget(); + +public: + void SetData( const AxisData& ); + void GetData( AxisData& ); + +protected: + virtual ViewerTools_FontWidgetBase* createFontWidget( QWidget* ); +}; + +/*! + * Class : OCCViewer_CubeAxesDlg + * Description : Dialog for specifynig cube axes properties + */ +class OCCVIEWER_EXPORT OCCViewer_CubeAxesDlg : public ViewerTools_CubeAxesDlgBase +{ + Q_OBJECT + +public: + OCCViewer_CubeAxesDlg(QtxAction* theAction, + OCCViewer_ViewWindow* theParent, + const char* theName); + virtual ~OCCViewer_CubeAxesDlg(); + + virtual void initialize(); + + void GetData( bool& theIsVisible, OCCViewer_AxisWidget::AxisData theAxisData[3] ); + void SetData( bool theIsVisible, OCCViewer_AxisWidget::AxisData theAxisData[3] ); + + void ApplyData( const Handle(V3d_View)& theView ); + + virtual void Update(); + +private slots: + virtual bool onApply(); + +private: + virtual ViewerTools_AxisWidgetBase* createAxisWidget( QWidget* ); + +private: + OCCViewer_ViewWindow* myMainWindow; +}; + +#endif diff --git a/src/OCCViewer/OCCViewer_FontWidget.cxx b/src/OCCViewer/OCCViewer_FontWidget.cxx new file mode 100644 index 000000000..d0a61ae6c --- /dev/null +++ b/src/OCCViewer/OCCViewer_FontWidget.cxx @@ -0,0 +1,99 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// + +#include "OCCViewer_FontWidget.h" + +#include + +//#include + +/*! + * Class : OCCViewer_FontWidget + * Description : Dialog for specifynig font + */ + +/*! + Constructor +*/ +OCCViewer_FontWidget::OCCViewer_FontWidget( QWidget* theParent ) +: ViewerTools_FontWidgetBase( theParent ) +{ +} + +/*! + Destructor +*/ +OCCViewer_FontWidget::~OCCViewer_FontWidget() +{ +} + +void OCCViewer_FontWidget::InitializeFamilies() +{ + //myFamily->insertItem( myFamily->count(), tr( "ARIAL" ) ); + //myFamily->insertItem( myFamily->count(), tr( "COURIER" ) ); + //myFamily->insertItem( myFamily->count(), tr( "TIMES" ) ); +} + +void OCCViewer_FontWidget::SetData( const QColor& theColor, + const int theFamily, + const bool theBold, + const bool theItalic, + const bool theShadow ) +{ + ViewerTools_FontWidgetBase::SetData( theColor, + theFamily, + theBold, + theItalic, + theShadow ); + + /* + if ( theFamily == VTK_ARIAL ) + myFamily->setCurrentIndex( 0 ); + else if ( theFamily == VTK_COURIER ) + myFamily->setCurrentIndex( 1 ); + else + myFamily->setCurrentIndex( 2 ); + */ +} + +void OCCViewer_FontWidget::GetData( QColor& theColor, + int& theFamily, + bool& theBold, + bool& theItalic, + bool& theShadow ) const +{ + ViewerTools_FontWidgetBase::GetData( theColor, + theFamily, + theBold, + theItalic, + theShadow ); + + /* + int anItem = myFamily->currentIndex(); + if ( anItem == 0 ) + theFamily = VTK_ARIAL; + else if ( anItem == 1 ) + theFamily = VTK_COURIER; + else + theFamily = VTK_TIMES; + */ +} diff --git a/src/OCCViewer/OCCViewer_FontWidget.h b/src/OCCViewer/OCCViewer_FontWidget.h new file mode 100644 index 000000000..506d583dd --- /dev/null +++ b/src/OCCViewer/OCCViewer_FontWidget.h @@ -0,0 +1,50 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 OCCVIEWER_FONTWIDGET_H +#define OCCVIEWER_FONTWIDGET_H + +#include "OCCViewer.h" + +#include + +/*! + * Class : OCCViewer_FontWidget + * Description : Dialog for specifynig font + */ +class OCCVIEWER_EXPORT OCCViewer_FontWidget : public ViewerTools_FontWidgetBase +{ + Q_OBJECT + +public: + OCCViewer_FontWidget( QWidget* ); + virtual ~OCCViewer_FontWidget(); + + virtual void SetData( const QColor&, const int, const bool, const bool, const bool ); + + virtual void GetData( QColor&, int&, bool&, bool&, bool& ) const; + +protected: + virtual void InitializeFamilies(); +}; + +#endif diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 925b2dc05..fc0463e79 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -65,6 +65,47 @@ public: QString name; bool isVisible; double size; + // graduated trihedron + bool gtIsVisible; + bool gtDrawNameX; + bool gtDrawNameY; + bool gtDrawNameZ; + QString gtNameX; + QString gtNameY; + QString gtNameZ; + int gtNameColorRX; + int gtNameColorGX; + int gtNameColorBX; + int gtNameColorRY; + int gtNameColorGY; + int gtNameColorBY; + int gtNameColorRZ; + int gtNameColorGZ; + int gtNameColorBZ; + bool gtDrawValuesX; + bool gtDrawValuesY; + bool gtDrawValuesZ; + int gtNbValuesX; + int gtNbValuesY; + int gtNbValuesZ; + int gtOffsetX; + int gtOffsetY; + int gtOffsetZ; + int gtColorRX; + int gtColorGX; + int gtColorBX; + int gtColorRY; + int gtColorGY; + int gtColorBY; + int gtColorRZ; + int gtColorGZ; + int gtColorBZ; + bool gtDrawTickmarksX; + bool gtDrawTickmarksY; + bool gtDrawTickmarksZ; + int gtTickmarkLengthX; + int gtTickmarkLengthY; + int gtTickmarkLengthZ; }; typedef QList viewAspectList; diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index fd0992fba..9ac36b842 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -32,6 +32,7 @@ #include "OCCViewer_ClippingDlg.h" #include "OCCViewer_SetRotationPointDlg.h" #include "OCCViewer_AxialScaleDlg.h" +#include "OCCViewer_CubeAxesDlg.h" #include #include @@ -73,6 +74,14 @@ #include #include +#include + +#ifdef OCC_VERSION_SERVICEPACK +#define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8 | OCC_VERSION_SERVICEPACK) +#else +#define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8) +#endif + static QEvent* l_mbPressEvent = 0; #ifdef WIN32 @@ -250,6 +259,11 @@ void OCCViewer_ViewWindow::initLayout() createActions(); createToolBar(); + + // Graduated axes dialog + QtxAction* anAction = dynamic_cast( toolMgr()->action( GraduatedAxesId ) ); + myCubeAxesDlg = new OCCViewer_CubeAxesDlg( anAction, this, "OCCViewer_CubeAxesDlg" ); + myCubeAxesDlg->initialize(); } /*! @@ -1131,6 +1145,13 @@ void OCCViewer_ViewWindow::createActions() connect(aAction, SIGNAL(triggered()), this, SLOT(onAxialScale())); toolMgr()->registerAction( aAction, AxialScaleId ); + // Graduated axes + aAction = new QtxAction(tr("MNU_GRADUATED_AXES"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_GRADUATED_AXES" ) ), + tr( "MNU_GRADUATED_AXES" ), 0, this); + aAction->setStatusTip(tr("DSC_GRADUATED_AXES")); + connect(aAction, SIGNAL(triggered()), this, SLOT(onGraduatedAxes())); + toolMgr()->registerAction( aAction, GraduatedAxesId ); + // Active only ambient light or not aAction = new QtxAction(tr("MNU_AMBIENT"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_AMBIENT" ) ), tr( "MNU_AMBIENT" ), 0, this); @@ -1195,6 +1216,9 @@ void OCCViewer_ViewWindow::createToolBar() toolMgr()->append( toolMgr()->separator(), tid ); toolMgr()->append( ClippingId, tid ); toolMgr()->append( AxialScaleId, tid ); +#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version + toolMgr()->append( GraduatedAxesId, tid ); +#endif toolMgr()->append( AmbientId, tid ); } @@ -1394,6 +1418,15 @@ void OCCViewer_ViewWindow::onAxialScale() myScalingDlg->show(); } +/*! + Shows Graduated Axes dialog +*/ +void OCCViewer_ViewWindow::onGraduatedAxes() +{ + myCubeAxesDlg->Update(); + myCubeAxesDlg->show(); +} + void OCCViewer_ViewWindow::onAmbientToogle() { Handle(V3d_Viewer) viewer = myViewPort->getViewer(); @@ -1453,6 +1486,54 @@ void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem ) myModel->setTrihedronShown( anItem.isVisible ); myModel->setTrihedronSize( anItem.size ); +#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version + // graduated trihedron + bool anIsVisible = anItem.gtIsVisible; + OCCViewer_AxisWidget::AxisData anAxisData[3]; + anAxisData[0].DrawName = anItem.gtDrawNameX; + anAxisData[1].DrawName = anItem.gtDrawNameZ; + anAxisData[2].DrawName = anItem.gtDrawNameZ; + anAxisData[0].Name = anItem.gtNameX; + anAxisData[1].Name = anItem.gtNameZ; + anAxisData[2].Name = anItem.gtNameZ; + anAxisData[0].NameColor = QColor( anItem.gtNameColorRX, + anItem.gtNameColorGX, + anItem.gtNameColorBX ); + anAxisData[1].NameColor = QColor( anItem.gtNameColorRY, + anItem.gtNameColorGY, + anItem.gtNameColorBY ); + anAxisData[2].NameColor = QColor( anItem.gtNameColorRZ, + anItem.gtNameColorGZ, + anItem.gtNameColorBZ ); + anAxisData[0].DrawValues = anItem.gtDrawValuesX; + anAxisData[1].DrawValues = anItem.gtDrawValuesY; + anAxisData[2].DrawValues = anItem.gtDrawValuesZ; + anAxisData[0].NbValues = anItem.gtNbValuesX; + anAxisData[1].NbValues = anItem.gtNbValuesY; + anAxisData[2].NbValues = anItem.gtNbValuesZ; + anAxisData[0].Offset = anItem.gtOffsetX; + anAxisData[1].Offset = anItem.gtOffsetY; + anAxisData[2].Offset = anItem.gtOffsetZ; + anAxisData[0].Color = QColor( anItem.gtColorRX, + anItem.gtColorGX, + anItem.gtColorBX ); + anAxisData[1].Color = QColor( anItem.gtColorRY, + anItem.gtColorGY, + anItem.gtColorBY ); + anAxisData[2].Color = QColor( anItem.gtColorRZ, + anItem.gtColorGZ, + anItem.gtColorBZ ); + anAxisData[0].DrawTickmarks = anItem.gtDrawTickmarksX; + anAxisData[1].DrawTickmarks = anItem.gtDrawTickmarksY; + anAxisData[2].DrawTickmarks = anItem.gtDrawTickmarksZ; + anAxisData[0].TickmarkLength = anItem.gtTickmarkLengthX; + anAxisData[1].TickmarkLength = anItem.gtTickmarkLengthY; + anAxisData[2].TickmarkLength = anItem.gtTickmarkLengthZ; + + myCubeAxesDlg->SetData( anIsVisible, anAxisData ); + myCubeAxesDlg->ApplyData( aView3d ); +#endif + myRestoreFlag = 0; } @@ -1681,6 +1762,54 @@ viewAspect OCCViewer_ViewWindow::getViewParams() const params.isVisible= isShown; params.size = size; +#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version + // graduated trihedron + bool anIsVisible = false; + OCCViewer_AxisWidget::AxisData anAxisData[3]; + myCubeAxesDlg->GetData( anIsVisible, anAxisData ); + + params.gtIsVisible = anIsVisible; + params.gtDrawNameX = anAxisData[0].DrawName; + params.gtDrawNameY = anAxisData[1].DrawName; + params.gtDrawNameZ = anAxisData[2].DrawName; + params.gtNameX = anAxisData[0].Name; + params.gtNameY = anAxisData[1].Name; + params.gtNameZ = anAxisData[2].Name; + params.gtNameColorRX = anAxisData[0].NameColor.red(); + params.gtNameColorGX = anAxisData[0].NameColor.green(); + params.gtNameColorBX = anAxisData[0].NameColor.blue(); + params.gtNameColorRY = anAxisData[1].NameColor.red(); + params.gtNameColorGY = anAxisData[1].NameColor.green(); + params.gtNameColorBY = anAxisData[1].NameColor.blue(); + params.gtNameColorRZ = anAxisData[2].NameColor.red(); + params.gtNameColorGZ = anAxisData[2].NameColor.green(); + params.gtNameColorBZ = anAxisData[2].NameColor.blue(); + params.gtDrawValuesX = anAxisData[0].DrawValues; + params.gtDrawValuesY = anAxisData[1].DrawValues; + params.gtDrawValuesZ = anAxisData[2].DrawValues; + params.gtNbValuesX = anAxisData[0].NbValues; + params.gtNbValuesY = anAxisData[1].NbValues; + params.gtNbValuesZ = anAxisData[2].NbValues; + params.gtOffsetX = anAxisData[0].Offset; + params.gtOffsetY = anAxisData[1].Offset; + params.gtOffsetZ = anAxisData[2].Offset; + params.gtColorRX = anAxisData[0].Color.red(); + params.gtColorGX = anAxisData[0].Color.green(); + params.gtColorBX = anAxisData[0].Color.blue(); + params.gtColorRY = anAxisData[1].Color.red(); + params.gtColorGY = anAxisData[1].Color.green(); + params.gtColorBY = anAxisData[1].Color.blue(); + params.gtColorRZ = anAxisData[2].Color.red(); + params.gtColorGZ = anAxisData[2].Color.green(); + params.gtColorBZ = anAxisData[2].Color.blue(); + params.gtDrawTickmarksX = anAxisData[0].DrawTickmarks; + params.gtDrawTickmarksY = anAxisData[1].DrawTickmarks; + params.gtDrawTickmarksZ = anAxisData[2].DrawTickmarks; + params.gtTickmarkLengthX = anAxisData[0].TickmarkLength; + params.gtTickmarkLengthY = anAxisData[1].TickmarkLength; + params.gtTickmarkLengthZ = anAxisData[2].TickmarkLength; +#endif + return params; } @@ -1693,11 +1822,71 @@ QString OCCViewer_ViewWindow::getVisualParameters() { viewAspect params = getViewParams(); QString retStr; - retStr.sprintf( "%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e", params.scale, - params.centerX, params.centerY, params.projX, params.projY, params.projZ, params.twist, - params.atX, params.atY, params.atZ, params.eyeX, params.eyeY, params.eyeZ, - params.scaleX, params.scaleY, params.scaleZ ); - retStr += QString().sprintf("*%u*%.2f", params.isVisible, params.size ); + + retStr += QString().sprintf( "scale=%.12e*", params.scale ); + retStr += QString().sprintf( "centerX=%.12e*", params.centerX ); + retStr += QString().sprintf( "centerY=%.12e*", params.centerY ); + retStr += QString().sprintf( "projX=%.12e*", params.projX ); + retStr += QString().sprintf( "projY=%.12e*", params.projY ); + retStr += QString().sprintf( "projZ=%.12e*", params.projZ ); + retStr += QString().sprintf( "twist=%.12e*", params.twist ); + retStr += QString().sprintf( "atX=%.12e*", params.atX ); + retStr += QString().sprintf( "atY=%.12e*", params.atY ); + retStr += QString().sprintf( "atZ=%.12e*", params.atZ ); + retStr += QString().sprintf( "eyeX=%.12e*", params.eyeX ); + retStr += QString().sprintf( "eyeY=%.12e*", params.eyeY ); + retStr += QString().sprintf( "eyeZ=%.12e*", params.eyeZ ); + retStr += QString().sprintf( "scaleX=%.12e*", params.scaleX ); + retStr += QString().sprintf( "scaleY=%.12e*", params.scaleY ); + retStr += QString().sprintf( "scaleZ=%.12e*", params.scaleZ ); + + retStr += QString().sprintf( "isVisible=%.u*", params.isVisible ); + retStr += QString().sprintf( "size=%.2f", params.size ); + +#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version + // graduated trihedron + retStr += QString().sprintf( "*gtIsVisible=%u*", params.gtIsVisible ); + retStr += QString().sprintf( "gtDrawNameX=%u*", params.gtDrawNameX ); + retStr += QString().sprintf( "gtDrawNameY=%u*", params.gtDrawNameY ); + retStr += QString().sprintf( "gtDrawNameZ=%u*", params.gtDrawNameZ ); + retStr += QString().sprintf( "gtNameX=%s*", params.gtNameX.toLatin1().constData() ); + retStr += QString().sprintf( "gtNameY=%s*", params.gtNameY.toLatin1().constData() ); + retStr += QString().sprintf( "gtNameZ=%s*", params.gtNameZ.toLatin1().constData() ); + retStr += QString().sprintf( "gtNameColorRX=%u*", params.gtNameColorRX ); + retStr += QString().sprintf( "gtNameColorGX=%u*", params.gtNameColorGX ); + retStr += QString().sprintf( "gtNameColorBX=%u*", params.gtNameColorBX ); + retStr += QString().sprintf( "gtNameColorRY=%u*", params.gtNameColorRY ); + retStr += QString().sprintf( "gtNameColorGY=%u*", params.gtNameColorGY ); + retStr += QString().sprintf( "gtNameColorBY=%u*", params.gtNameColorBY ); + retStr += QString().sprintf( "gtNameColorRZ=%u*", params.gtNameColorRZ ); + retStr += QString().sprintf( "gtNameColorGZ=%u*", params.gtNameColorGZ ); + retStr += QString().sprintf( "gtNameColorBZ=%u*", params.gtNameColorBZ ); + retStr += QString().sprintf( "gtDrawValuesX=%u*", params.gtDrawValuesX ); + retStr += QString().sprintf( "gtDrawValuesY=%u*", params.gtDrawValuesY ); + retStr += QString().sprintf( "gtDrawValuesZ=%u*", params.gtDrawValuesZ ); + retStr += QString().sprintf( "gtNbValuesX=%u*", params.gtNbValuesX ); + retStr += QString().sprintf( "gtNbValuesY=%u*", params.gtNbValuesY ); + retStr += QString().sprintf( "gtNbValuesZ=%u*", params.gtNbValuesZ ); + retStr += QString().sprintf( "gtOffsetX=%u*", params.gtOffsetX ); + retStr += QString().sprintf( "gtOffsetY=%u*", params.gtOffsetY ); + retStr += QString().sprintf( "gtOffsetZ=%u*", params.gtOffsetZ ); + retStr += QString().sprintf( "gtColorRX=%u*", params.gtColorRX ); + retStr += QString().sprintf( "gtColorGX=%u*", params.gtColorGX ); + retStr += QString().sprintf( "gtColorBX=%u*", params.gtColorBX ); + retStr += QString().sprintf( "gtColorRY=%u*", params.gtColorRY ); + retStr += QString().sprintf( "gtColorGY=%u*", params.gtColorGY ); + retStr += QString().sprintf( "gtColorBY=%u*", params.gtColorBY ); + retStr += QString().sprintf( "gtColorRZ=%u*", params.gtColorRZ ); + retStr += QString().sprintf( "gtColorGZ=%u*", params.gtColorGZ ); + retStr += QString().sprintf( "gtColorBZ=%u*", params.gtColorBZ ); + retStr += QString().sprintf( "gtDrawTickmarksX=%u*", params.gtDrawTickmarksX ); + retStr += QString().sprintf( "gtDrawTickmarksY=%u*", params.gtDrawTickmarksY ); + retStr += QString().sprintf( "gtDrawTickmarksZ=%u*", params.gtDrawTickmarksZ ); + retStr += QString().sprintf( "gtTickmarkLengthX=%u*", params.gtTickmarkLengthX ); + retStr += QString().sprintf( "gtTickmarkLengthY=%u*", params.gtTickmarkLengthY ); + retStr += QString().sprintf( "gtTickmarkLengthZ=%u", params.gtTickmarkLengthZ ); +#endif + return retStr; } @@ -1707,36 +1896,109 @@ QString OCCViewer_ViewWindow::getVisualParameters() */ void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) { + viewAspect params; QStringList paramsLst = parameters.split( '*' ); - if ( paramsLst.size() >= 15 ) { - viewAspect params; - params.scale = paramsLst[0].toDouble(); - params.centerX = paramsLst[1].toDouble(); - params.centerY = paramsLst[2].toDouble(); - params.projX = paramsLst[3].toDouble(); - params.projY = paramsLst[4].toDouble(); - params.projZ = paramsLst[5].toDouble(); - params.twist = paramsLst[6].toDouble(); - params.atX = paramsLst[7].toDouble(); - params.atY = paramsLst[8].toDouble(); - params.atZ = paramsLst[9].toDouble(); - params.eyeX = paramsLst[10].toDouble(); - params.eyeY = paramsLst[11].toDouble(); - params.eyeZ = paramsLst[12].toDouble(); - if ( paramsLst.size() == 18 ) { - params.scaleX = paramsLst[13].toDouble(); - params.scaleY = paramsLst[14].toDouble(); - params.scaleZ = paramsLst[15].toDouble(); - params.isVisible = paramsLst[16].toDouble(); - params.size = paramsLst[17].toDouble(); - } - else { - params.scaleX = 1.; - params.scaleY = 1.; - params.scaleZ = 1.; + if( parameters.contains( '=' ) ) // new format - "scale=1.000e+00*centerX=0.000e+00..." + { + QStringList::const_iterator it = paramsLst.begin(), itEnd = paramsLst.end(); + for( ; it != itEnd; it++ ) { + QString param = *it; + QString paramName = param.section( '=', 0, 0 ); + QString paramStr = param.section( '=', 1, 1 ); + double paramDouble = paramStr.toDouble(); + int paramInt = paramStr.toInt(); + if( paramName == "scale" ) params.scale = paramDouble; + else if( paramName == "centerX" ) params.centerX = paramDouble; + else if( paramName == "centerY" ) params.centerY = paramDouble; + else if( paramName == "projX" ) params.projX = paramDouble; + else if( paramName == "projY" ) params.projY = paramDouble; + else if( paramName == "projZ" ) params.projZ = paramDouble; + else if( paramName == "twist" ) params.twist = paramDouble; + else if( paramName == "atX" ) params.atX = paramDouble; + else if( paramName == "atY" ) params.atY = paramDouble; + else if( paramName == "atZ" ) params.atZ = paramDouble; + else if( paramName == "eyeX" ) params.eyeX = paramDouble; + else if( paramName == "eyeY" ) params.eyeY = paramDouble; + else if( paramName == "eyeZ" ) params.eyeZ = paramDouble; + else if( paramName == "scaleX" ) params.scaleX = paramDouble; + else if( paramName == "scaleY" ) params.scaleY = paramDouble; + else if( paramName == "scaleZ" ) params.scaleZ = paramDouble; + else if( paramName == "isVisible" ) params.isVisible = paramInt; + else if( paramName == "size" ) params.size = paramDouble; + // graduated trihedron + else if( paramName == "gtIsVisible" ) params.gtIsVisible = paramInt; + else if( paramName == "gtDrawNameX" ) params.gtDrawNameX = paramInt; + else if( paramName == "gtDrawNameY" ) params.gtDrawNameY = paramInt; + else if( paramName == "gtDrawNameZ" ) params.gtDrawNameZ = paramInt; + else if( paramName == "gtNameX" ) params.gtNameX = paramStr; + else if( paramName == "gtNameY" ) params.gtNameY = paramStr; + else if( paramName == "gtNameZ" ) params.gtNameZ = paramStr; + else if( paramName == "gtNameColorRX" ) params.gtNameColorRX = paramInt; + else if( paramName == "gtNameColorGX" ) params.gtNameColorGX = paramInt; + else if( paramName == "gtNameColorBX" ) params.gtNameColorBX = paramInt; + else if( paramName == "gtNameColorRY" ) params.gtNameColorRY = paramInt; + else if( paramName == "gtNameColorGY" ) params.gtNameColorGY = paramInt; + else if( paramName == "gtNameColorBY" ) params.gtNameColorBY = paramInt; + else if( paramName == "gtNameColorRZ" ) params.gtNameColorRZ = paramInt; + else if( paramName == "gtNameColorGZ" ) params.gtNameColorGZ = paramInt; + else if( paramName == "gtNameColorBZ" ) params.gtNameColorBZ = paramInt; + else if( paramName == "gtDrawValuesX" ) params.gtDrawValuesX = paramInt; + else if( paramName == "gtDrawValuesY" ) params.gtDrawValuesY = paramInt; + else if( paramName == "gtDrawValuesZ" ) params.gtDrawValuesZ = paramInt; + else if( paramName == "gtNbValuesX" ) params.gtNbValuesX = paramInt; + else if( paramName == "gtNbValuesY" ) params.gtNbValuesY = paramInt; + else if( paramName == "gtNbValuesZ" ) params.gtNbValuesZ = paramInt; + else if( paramName == "gtOffsetX" ) params.gtOffsetX = paramInt; + else if( paramName == "gtOffsetY" ) params.gtOffsetY = paramInt; + else if( paramName == "gtOffsetZ" ) params.gtOffsetZ = paramInt; + else if( paramName == "gtColorRX" ) params.gtColorRX = paramInt; + else if( paramName == "gtColorGX" ) params.gtColorGX = paramInt; + else if( paramName == "gtColorBX" ) params.gtColorBX = paramInt; + else if( paramName == "gtColorRY" ) params.gtColorRY = paramInt; + else if( paramName == "gtColorGY" ) params.gtColorGY = paramInt; + else if( paramName == "gtColorBY" ) params.gtColorBY = paramInt; + else if( paramName == "gtColorRZ" ) params.gtColorRZ = paramInt; + else if( paramName == "gtColorGZ" ) params.gtColorGZ = paramInt; + else if( paramName == "gtColorBZ" ) params.gtColorBZ = paramInt; + else if( paramName == "gtDrawTickmarksX" ) params.gtDrawTickmarksX = paramInt; + else if( paramName == "gtDrawTickmarksY" ) params.gtDrawTickmarksY = paramInt; + else if( paramName == "gtDrawTickmarksZ" ) params.gtDrawTickmarksZ = paramInt; + else if( paramName == "gtTickmarkLengthX" ) params.gtTickmarkLengthX = paramInt; + else if( paramName == "gtTickmarkLengthY" ) params.gtTickmarkLengthY = paramInt; + else if( paramName == "gtTickmarkLengthZ" ) params.gtTickmarkLengthZ = paramInt; + } + } + else // old format - "1.000e+00*0.000e+00..." + { + if ( paramsLst.size() >= 15 ) { + params.scale = paramsLst[0].toDouble(); + params.centerX = paramsLst[1].toDouble(); + params.centerY = paramsLst[2].toDouble(); + params.projX = paramsLst[3].toDouble(); + params.projY = paramsLst[4].toDouble(); + params.projZ = paramsLst[5].toDouble(); + params.twist = paramsLst[6].toDouble(); + params.atX = paramsLst[7].toDouble(); + params.atY = paramsLst[8].toDouble(); + params.atZ = paramsLst[9].toDouble(); + params.eyeX = paramsLst[10].toDouble(); + params.eyeY = paramsLst[11].toDouble(); + params.eyeZ = paramsLst[12].toDouble(); + if ( paramsLst.size() == 18 ) { + params.scaleX = paramsLst[13].toDouble(); + params.scaleY = paramsLst[14].toDouble(); + params.scaleZ = paramsLst[15].toDouble(); + params.isVisible = paramsLst[16].toDouble(); + params.size = paramsLst[17].toDouble(); + } + else { + params.scaleX = 1.; + params.scaleY = 1.; + params.scaleZ = 1.; + } } - performRestoring( params ); } + performRestoring( params ); } /*! diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index 56558b5b7..02300ef18 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -35,6 +35,7 @@ class OCCViewer_ClippingDlg; class OCCViewer_AxialScaleDlg; class OCCViewer_SetRotationPointDlg; class OCCViewer_Viewer; +class OCCViewer_CubeAxesDlg; class viewAspect; class QtxAction; @@ -50,7 +51,7 @@ public: enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, ChangeRotationPointId, RotationId, FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, ClippingId, MemId, RestoreId, - TrihedronShowId, AxialScaleId, AmbientId, SwitchInteractionStyleId }; + TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId, SwitchInteractionStyleId }; enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW, @@ -111,6 +112,7 @@ public slots: void onCloneView(); void onClipping( bool on ); void onAxialScale(); + void onGraduatedAxes(); void onAmbientToogle(); void onMemorizeView(); void onRestoreView(); @@ -179,6 +181,8 @@ protected: OCCViewer_Viewer* myModel; OCCViewer_ViewPort3d* myViewPort; + OCCViewer_CubeAxesDlg* myCubeAxesDlg; + RotationPointType myCurrPointType; RotationPointType myPrevPointType; gp_Pnt mySelectedPoint; diff --git a/src/OCCViewer/resources/OCCViewer_images.ts b/src/OCCViewer/resources/OCCViewer_images.ts index bdd523e49..bcc888b20 100644 --- a/src/OCCViewer/resources/OCCViewer_images.ts +++ b/src/OCCViewer/resources/OCCViewer_images.ts @@ -112,6 +112,10 @@ ICON_OCCVIEWER_SCALING occ_view_scaling.png + + ICON_OCCVIEWER_GRADUATED_AXES + occ_view_graduated_axes.png + ICON_OCCVIEWER_AMBIENT occ_view_ambient.png diff --git a/src/OCCViewer/resources/OCCViewer_msg_en.ts b/src/OCCViewer/resources/OCCViewer_msg_en.ts index 8b19e4c5b..aea134ee6 100644 --- a/src/OCCViewer/resources/OCCViewer_msg_en.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_en.ts @@ -207,6 +207,14 @@ MNU_SCALING Scaling + + DSC_GRADUATED_AXES + Graduated axes + + + MNU_GRADUATED_AXES + Graduated axes + DSC_AMBIENT Toogle keep only ambient light diff --git a/src/OCCViewer/resources/occ_view_graduated_axes.png b/src/OCCViewer/resources/occ_view_graduated_axes.png new file mode 100755 index 000000000..2b44c06fe Binary files /dev/null and b/src/OCCViewer/resources/occ_view_graduated_axes.png differ diff --git a/src/SVTK/Makefile.am b/src/SVTK/Makefile.am index 4ae5a82fa..3842a639f 100755 --- a/src/SVTK/Makefile.am +++ b/src/SVTK/Makefile.am @@ -36,7 +36,6 @@ salomeinclude_HEADERS= \ SALOME_Actor.h \ SVTK_RectPicker.h \ SVTK_DeviceActor.h \ - SVTK_DialogBase.h \ SVTK_FontWidget.h \ SVTK_CubeAxesActor2D.h \ SVTK_Functor.h \ @@ -73,7 +72,6 @@ dist_libSVTK_la_SOURCES= \ SVTK_NonIsometricDlg.cxx \ SVTK_UpdateRateDlg.cxx \ SVTK_CubeAxesDlg.cxx \ - SVTK_DialogBase.cxx \ SVTK_FontWidget.cxx \ SVTK_Trihedron.cxx \ SVTK_View.cxx \ @@ -110,7 +108,6 @@ MOC_FILES= \ SVTK_UpdateRateDlg_moc.cxx \ SVTK_CubeAxesDlg_moc.cxx \ SVTK_FontWidget_moc.cxx \ - SVTK_DialogBase_moc.cxx \ SVTK_ViewModelBase_moc.cxx \ SVTK_ViewManager_moc.cxx \ SVTK_ViewWindow_moc.cxx \ @@ -148,6 +145,7 @@ libSVTK_la_CPPFLAGS = \ $(BOOST_CPPFLAGS) \ -I$(srcdir)/../Qtx \ -I$(srcdir)/../SUIT \ + -I$(srcdir)/../ViewerTools \ -I$(srcdir)/../OBJECT \ -I$(srcdir)/../Prs \ -I$(srcdir)/../VTKViewer \ @@ -160,9 +158,10 @@ libSVTK_la_LDFLAGS = \ $(KERNEL_LDFLAGS) -libSVTK_la_LIBADD = ../Qtx/libqtx.la ../SUIT/libsuit.la ../OBJECT/libSalomeObject.la \ - ../Prs/libSalomePrs.la ../VTKViewer/libVTKViewer.la \ - ../OpenGLUtils/libOpenGLUtils.la -lSALOMELocalTrace +libSVTK_la_LIBADD = ../Qtx/libqtx.la ../SUIT/libsuit.la ../ViewerTools/libViewerTools.la \ + ../OBJECT/libSalomeObject.la ../Prs/libSalomePrs.la \ + ../VTKViewer/libVTKViewer.la ../OpenGLUtils/libOpenGLUtils.la \ + -lSALOMELocalTrace # Executable bin_PROGRAMS = SVTK diff --git a/src/SVTK/SVTK_CubeAxesDlg.cxx b/src/SVTK/SVTK_CubeAxesDlg.cxx index 942e9af62..b979f5508 100644 --- a/src/SVTK/SVTK_CubeAxesDlg.cxx +++ b/src/SVTK/SVTK_CubeAxesDlg.cxx @@ -35,14 +35,9 @@ #include "QtxAction.h" #include "QtxIntSpinBox.h" -#include -#include -#include -#include #include #include #include -#include #include #include @@ -53,176 +48,29 @@ \internal */ -class SVTK_CubeAxesDlg::AxisWidget : public QFrame -{ -public: - AxisWidget( QWidget* ); - ~AxisWidget(); - - void UseName( const bool ); - void SetName( const QString& ); - void SetNameFont( const QColor&, const int, const bool, const bool, const bool ); - bool ReadData( vtkAxisActor2D* ); - bool Apply( vtkAxisActor2D* ); - -private: - // name - QGroupBox* myNameGrp; - QLineEdit* myAxisName; - SVTK_FontWidget* myNameFont; - - // labels - QGroupBox* myLabelsGrp; - QtxIntSpinBox* myLabelNumber; - QtxIntSpinBox* myLabelOffset; - SVTK_FontWidget* myLabelsFont; - - // tick marks - QGroupBox* myTicksGrp; - QtxIntSpinBox* myTickLength; - - friend class SVTK_CubeAxesDlg; -}; - /*! Constructor */ -SVTK_CubeAxesDlg::AxisWidget::AxisWidget (QWidget* theParent) -: QFrame(theParent) +SVTK_AxisWidget::SVTK_AxisWidget (QWidget* theParent) +: ViewerTools_AxisWidgetBase(theParent) { - QList< QLabel* > aLabels; - - // "Name" grp - - myNameGrp = new QGroupBox(SVTK_CubeAxesDlg::tr("AXIS_NAME"), this); - myNameGrp->setCheckable( true ); - - QVBoxLayout* aVBox = new QVBoxLayout; - - QHBoxLayout* aHBox = new QHBoxLayout; - aHBox->setSpacing(5); - QLabel* aLabel = new QLabel(SVTK_CubeAxesDlg::tr("NAME")); - aHBox->addWidget(aLabel); - myAxisName = new QLineEdit; - aHBox->addWidget(myAxisName); - aLabels.append(aLabel); - aVBox->addLayout(aHBox); - - aHBox = new QHBoxLayout; - aHBox->setSpacing(5); - aLabel = new QLabel(SVTK_CubeAxesDlg::tr("FONT")); - aHBox->addWidget(aLabel); - myNameFont = new SVTK_FontWidget(myNameGrp); - aHBox->addWidget(myNameFont); - aLabels.append(aLabel); - aVBox->addLayout(aHBox); - - myNameGrp->setLayout(aVBox); - - // "Labels" grp - - myLabelsGrp = new QGroupBox(SVTK_CubeAxesDlg::tr("LABELS"), this); - myLabelsGrp->setCheckable( true ); - - aVBox = new QVBoxLayout; - - aHBox = new QHBoxLayout; - aHBox->setSpacing(5); - aLabel = new QLabel(SVTK_CubeAxesDlg::tr("NUMBER")); - aHBox->addWidget(aLabel); - myLabelNumber = new QtxIntSpinBox(0,25,1,myLabelsGrp); - aHBox->addWidget(myLabelNumber); - aLabels.append(aLabel); - aVBox->addLayout(aHBox); - - aHBox = new QHBoxLayout; - aHBox->setSpacing(5); - aLabel = new QLabel(SVTK_CubeAxesDlg::tr("OFFSET")); - aHBox->addWidget(aLabel); - myLabelOffset = new QtxIntSpinBox(0,100,1,myLabelsGrp); - aHBox->addWidget(myLabelOffset); - aLabels.append(aLabel); - aVBox->addLayout(aHBox); - - aHBox = new QHBoxLayout; - aHBox->setSpacing(5); - aLabel = new QLabel(SVTK_CubeAxesDlg::tr("FONT")); - aHBox->addWidget(aLabel); - myLabelsFont = new SVTK_FontWidget(myLabelsGrp); - aHBox->addWidget(myLabelsFont); - aLabels.append(aLabel); - aVBox->addLayout(aHBox); - - myLabelsGrp->setLayout(aVBox); - - // "Tick marks" grp - - myTicksGrp = new QGroupBox(SVTK_CubeAxesDlg::tr("TICK_MARKS"), this); - myTicksGrp->setCheckable( true ); - - aVBox = new QVBoxLayout; - - aHBox = new QHBoxLayout; - aHBox->setSpacing(5); - aLabel = new QLabel(SVTK_CubeAxesDlg::tr("LENGTH")); - aHBox->addWidget(aLabel); - myTickLength = new QtxIntSpinBox(0,100,1,myTicksGrp); - aHBox->addWidget(myTickLength); - aLabels.append(aLabel); - aVBox->addLayout(aHBox); - - myTicksGrp->setLayout(aVBox); - - // Layout - - QVBoxLayout* aLay = new QVBoxLayout(this); - aLay->setMargin(5); - aLay->setSpacing(5); - aLay->addWidget(myNameGrp); - aLay->addWidget(myLabelsGrp); - aLay->addWidget(myTicksGrp); - - // init - myNameGrp->setChecked( true ); - myLabelsGrp->setChecked( true ); - myTicksGrp->setChecked( true ); - - // Adjust label widths - QList< QLabel* >::iterator anIter; - int aMaxWidth = 0; - for (anIter = aLabels.begin(); anIter != aLabels.end(); anIter++) - aMaxWidth = qMax(aMaxWidth, (*anIter)->sizeHint().width()); - for (anIter = aLabels.begin(); anIter != aLabels.end(); anIter++) - (*anIter)->setFixedWidth(aMaxWidth); } /*! Destructor */ -SVTK_CubeAxesDlg::AxisWidget::~AxisWidget() +SVTK_AxisWidget::~SVTK_AxisWidget() { } -void SVTK_CubeAxesDlg::AxisWidget::UseName(const bool toUse) +ViewerTools_FontWidgetBase* SVTK_AxisWidget::createFontWidget( QWidget* theParent ) { - myNameGrp->setChecked(toUse); + SVTK_FontWidget* aFontWidget = new SVTK_FontWidget( theParent ); + aFontWidget->Initialize(); + return aFontWidget; } -void SVTK_CubeAxesDlg::AxisWidget::SetName(const QString& theName) -{ - myAxisName->setText(theName); -} - -void SVTK_CubeAxesDlg::AxisWidget::SetNameFont(const QColor& theColor, - const int theFont, - const bool theIsBold, - const bool theIsItalic, - const bool theIsShadow) -{ - myNameFont->SetData(theColor, theFont, theIsBold, theIsItalic, theIsShadow); -} - -bool SVTK_CubeAxesDlg::AxisWidget::ReadData(vtkAxisActor2D* theActor) +bool SVTK_AxisWidget::ReadData(vtkAxisActor2D* theActor) { if (theActor == 0) return false; @@ -293,7 +141,7 @@ bool SVTK_CubeAxesDlg::AxisWidget::ReadData(vtkAxisActor2D* theActor) return true; } -bool SVTK_CubeAxesDlg::AxisWidget::Apply(vtkAxisActor2D* theActor) +bool SVTK_AxisWidget::Apply(vtkAxisActor2D* theActor) { if (theActor == 0) return false; @@ -378,86 +226,28 @@ bool SVTK_CubeAxesDlg::AxisWidget::Apply(vtkAxisActor2D* theActor) SVTK_CubeAxesDlg::SVTK_CubeAxesDlg(QtxAction* theAction, SVTK_ViewWindow* theParent, const char* theName): - SVTK_DialogBase(theAction, - theParent, - theName), + ViewerTools_CubeAxesDlgBase(theAction, + theParent, + theName), myMainWindow(theParent) { - setWindowTitle(tr("CAPTION")); - - QVBoxLayout* aLay = new QVBoxLayout(this); - aLay->setMargin(5); - aLay->setSpacing(5); - aLay->addWidget(createMainFrame(this)); - aLay->addWidget(createButtonFrame(this)); - - connect(theParent, SIGNAL(Show( QShowEvent * )), this, SLOT(onParentShow())); - connect(theParent, SIGNAL(Hide( QHideEvent * )), this, SLOT(onParentHide())); } /*! - Create frame containing dialog's input fields -*/ -QWidget* SVTK_CubeAxesDlg::createMainFrame(QWidget* theParent) -{ - QFrame* aFrame = new QFrame(theParent); - - myTabWg = new QTabWidget(aFrame); - - myAxes[ 0 ] = new AxisWidget(myTabWg); - myAxes[ 1 ] = new AxisWidget(myTabWg); - myAxes[ 2 ] = new AxisWidget(myTabWg); - - myTabWg->addTab(myAxes[ 0 ], tr("X_AXIS")); - myTabWg->addTab(myAxes[ 1 ], tr("Y_AXIS")); - myTabWg->addTab(myAxes[ 2 ], tr("Z_AXIS")); - - myIsVisible = new QCheckBox(tr("IS_VISIBLE"), aFrame); - - QVBoxLayout* aLay = new QVBoxLayout(aFrame); - aLay->setMargin(0); - aLay->setSpacing(5); - aLay->addWidget(myTabWg); - aLay->addWidget(myIsVisible); - - return aFrame; -} - -/*! - Create frame containing buttons + Destructor */ -QWidget* SVTK_CubeAxesDlg::createButtonFrame(QWidget* theParent) +SVTK_CubeAxesDlg::~SVTK_CubeAxesDlg() { - QFrame* aFrame = new QFrame(theParent); - aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken); - - myOkBtn = new QPushButton(tr("BUT_OK"), aFrame); - myApplyBtn = new QPushButton(tr("BUT_APPLY"), aFrame); - myCloseBtn = new QPushButton(tr("BUT_CLOSE"), aFrame); - - QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); - - QHBoxLayout* aLay = new QHBoxLayout(aFrame); - aLay->setMargin(5); - aLay->setSpacing(5); - - aLay->addWidget(myOkBtn); - aLay->addWidget(myApplyBtn); - aLay->addItem(aSpacer); - aLay->addWidget(myCloseBtn); - - connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); - connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply())); - connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); - - return aFrame; } /*! - Destructor + Create axis widget */ -SVTK_CubeAxesDlg::~SVTK_CubeAxesDlg() +ViewerTools_AxisWidgetBase* SVTK_CubeAxesDlg::createAxisWidget( QWidget* theParent ) { + SVTK_AxisWidget* anAxisWidget = new SVTK_AxisWidget( theParent ); + anAxisWidget->initialize(); + return anAxisWidget; } /*! @@ -465,29 +255,23 @@ SVTK_CubeAxesDlg::~SVTK_CubeAxesDlg() */ void SVTK_CubeAxesDlg::Update() { + ViewerTools_CubeAxesDlgBase::Update(); + myActor = myMainWindow->GetCubeAxes(); - myAxes[ 0 ]->ReadData(myActor->GetXAxisActor2D()); - myAxes[ 1 ]->ReadData(myActor->GetYAxisActor2D()); - myAxes[ 2 ]->ReadData(myActor->GetZAxisActor2D()); + ((SVTK_AxisWidget*)myAxes[ 0 ])->ReadData(myActor->GetXAxisActor2D()); + ((SVTK_AxisWidget*)myAxes[ 1 ])->ReadData(myActor->GetYAxisActor2D()); + ((SVTK_AxisWidget*)myAxes[ 2 ])->ReadData(myActor->GetZAxisActor2D()); myIsVisible->setChecked(myActor->GetVisibility() ? true : false); } -/*! - Verify validity of entry data -*/ -bool SVTK_CubeAxesDlg::isValid() const -{ - return true; -} - /*! Verify validity of entry data */ bool SVTK_CubeAxesDlg::onApply() { - bool isOk = true; + bool isOk = ViewerTools_CubeAxesDlgBase::onApply(); try { @@ -495,16 +279,15 @@ bool SVTK_CubeAxesDlg::onApply() aCurrWid->clearFocus(); aCurrWid->setFocus(); - isOk = isOk && myAxes[ 0 ]->Apply(myActor->GetXAxisActor2D()); - isOk = isOk && myAxes[ 1 ]->Apply(myActor->GetYAxisActor2D()); - isOk = isOk && myAxes[ 2 ]->Apply(myActor->GetZAxisActor2D()); - + isOk = isOk && ((SVTK_AxisWidget*)myAxes[ 0 ])->Apply(myActor->GetXAxisActor2D()); + isOk = isOk && ((SVTK_AxisWidget*)myAxes[ 1 ])->Apply(myActor->GetYAxisActor2D()); + isOk = isOk && ((SVTK_AxisWidget*)myAxes[ 2 ])->Apply(myActor->GetZAxisActor2D()); - //myActor->SetXLabel(myAxes[ 0 ]->myAxisName->text()); - //myActor->SetYLabel(myAxes[ 1 ]->myAxisName->text()); - //myActor->SetZLabel(myAxes[ 2 ]->myAxisName->text()); + //myActor->SetXLabel(myAxes[ 0 ]->myAxisName->text()); // to remove? + //myActor->SetYLabel(myAxes[ 1 ]->myAxisName->text()); // to remove? + //myActor->SetZLabel(myAxes[ 2 ]->myAxisName->text()); // to remove? - //myActor->SetNumberOfLabels(myActor->GetXAxisActor2D()->GetNumberOfLabels()); + //myActor->SetNumberOfLabels(myActor->GetXAxisActor2D()->GetNumberOfLabels()); // to remove? if (myIsVisible->isChecked()) myActor->VisibilityOn(); else @@ -520,20 +303,3 @@ bool SVTK_CubeAxesDlg::onApply() return isOk; } - -/*! - SLOT called when "Ok" button pressed. -*/ -void SVTK_CubeAxesDlg::onOk() -{ - if (onApply()) - onClose(); -} - -/*! - SLOT: called when "Close" button pressed. Close dialog -*/ -void SVTK_CubeAxesDlg::onClose() -{ - reject(); -} diff --git a/src/SVTK/SVTK_CubeAxesDlg.h b/src/SVTK/SVTK_CubeAxesDlg.h index 6d615b8c6..57efc3b02 100644 --- a/src/SVTK/SVTK_CubeAxesDlg.h +++ b/src/SVTK/SVTK_CubeAxesDlg.h @@ -27,59 +27,58 @@ #ifndef SVTK_CubeAxesDlg_H #define SVTK_CubeAxesDlg_H -#include "SVTK_DialogBase.h" +#include "SVTK.h" -class QWidget; -class QPushButton; -class QTabWidget; -class QCheckBox; +#include -class QtxAction; +class SVTK_ViewWindow; class SVTK_CubeAxesActor2D; -class SVTK_FontWidget; -class SVTK_AxisWidget; -class SVTK_ViewWindow; +class vtkAxisActor2D; + +/*! + * Class : SVTK_AxisWidget + * Description : Axis tab widget of the "Graduated axis" dialog box +*/ +class SVTK_EXPORT SVTK_AxisWidget : public ViewerTools_AxisWidgetBase +{ +public: + SVTK_AxisWidget( QWidget* ); + ~SVTK_AxisWidget(); + +public: + bool ReadData( vtkAxisActor2D* ); + bool Apply( vtkAxisActor2D* ); + +protected: + virtual ViewerTools_FontWidgetBase* createFontWidget( QWidget* ); +}; /*! * Class : SVTK_CubeAxesDlg * Description : Dialog for specifynig cube axes properties */ -class SVTK_CubeAxesDlg : public SVTK_DialogBase +class SVTK_EXPORT SVTK_CubeAxesDlg : public ViewerTools_CubeAxesDlgBase { Q_OBJECT - class AxisWidget; - public: SVTK_CubeAxesDlg(QtxAction* theAction, SVTK_ViewWindow* theParent, const char* theName); virtual ~SVTK_CubeAxesDlg(); - void Update(); + virtual void Update(); private slots: - void onOk(); - bool onApply(); - void onClose(); + virtual bool onApply(); private: - QWidget* createButtonFrame( QWidget* ); - QWidget* createMainFrame ( QWidget* ); - bool isValid() const; + virtual ViewerTools_AxisWidgetBase* createAxisWidget( QWidget* ); private: - SVTK_ViewWindow *myMainWindow; + SVTK_ViewWindow* myMainWindow; SVTK_CubeAxesActor2D* myActor; - - QTabWidget* myTabWg; - QCheckBox* myIsVisible; - - QPushButton* myOkBtn; - QPushButton* myApplyBtn; - QPushButton* myCloseBtn; - AxisWidget* myAxes[ 3 ]; }; #endif diff --git a/src/SVTK/SVTK_FontWidget.cxx b/src/SVTK/SVTK_FontWidget.cxx index b8e3b28a8..fdbb838ba 100644 --- a/src/SVTK/SVTK_FontWidget.cxx +++ b/src/SVTK/SVTK_FontWidget.cxx @@ -27,11 +27,7 @@ // #include "SVTK_FontWidget.h" -#include #include -#include -#include -#include #include @@ -44,30 +40,8 @@ Constructor */ SVTK_FontWidget::SVTK_FontWidget( QWidget* theParent ) -: QWidget( theParent ) +: ViewerTools_FontWidgetBase( theParent ) { - myColorBtn = new QToolButton( this ); - myColorBtn->setMinimumWidth( 20 ); - - myFamily = new QComboBox( this ); - myFamily->insertItem( myFamily->count(), tr( "ARIAL" ) ); - myFamily->insertItem( myFamily->count(), tr( "COURIER" ) ); - myFamily->insertItem( myFamily->count(), tr( "TIMES" ) ); - - myBold = new QCheckBox( tr( "BOLD" ), this ); - myItalic = new QCheckBox( tr( "ITALIC" ), this ); - myShadow = new QCheckBox( tr( "SHADOW" ), this ); - - QHBoxLayout* aHBLayout = new QHBoxLayout; - aHBLayout->setSpacing( 5 ); - aHBLayout->addWidget(myColorBtn); - aHBLayout->addWidget(myFamily); - aHBLayout->addWidget(myBold); - aHBLayout->addWidget(myItalic); - aHBLayout->addWidget(myShadow); - this->setLayout(aHBLayout); - - connect( myColorBtn, SIGNAL( clicked() ), SLOT( onColor() ) ); } /*! @@ -77,32 +51,24 @@ SVTK_FontWidget::~SVTK_FontWidget() { } -void SVTK_FontWidget::SetColor( const QColor& theColor ) -{ - QPalette palette; - palette.setColor(myColorBtn->backgroundRole(), theColor); - myColorBtn->setPalette(palette); -} - -QColor SVTK_FontWidget::GetColor() const +void SVTK_FontWidget::InitializeFamilies() { - return myColorBtn->palette().color( myColorBtn->backgroundRole() ); -} - -void SVTK_FontWidget::onColor() -{ - QColor aColor = QColorDialog::getColor( GetColor(), this ); - if ( aColor.isValid() ) - SetColor( aColor ); + myFamily->insertItem( myFamily->count(), tr( "ARIAL" ) ); + myFamily->insertItem( myFamily->count(), tr( "COURIER" ) ); + myFamily->insertItem( myFamily->count(), tr( "TIMES" ) ); } void SVTK_FontWidget::SetData( const QColor& theColor, - const int theFamily, - const bool theBold, - const bool theItalic, - const bool theShadow ) + const int theFamily, + const bool theBold, + const bool theItalic, + const bool theShadow ) { - SetColor( theColor ); + ViewerTools_FontWidgetBase::SetData( theColor, + theFamily, + theBold, + theItalic, + theShadow ); if ( theFamily == VTK_ARIAL ) myFamily->setCurrentIndex( 0 ); @@ -110,10 +76,6 @@ void SVTK_FontWidget::SetData( const QColor& theColor, myFamily->setCurrentIndex( 1 ); else myFamily->setCurrentIndex( 2 ); - - myBold->setChecked( theBold ); - myItalic->setChecked( theItalic ); - myShadow->setChecked( theShadow ); } void SVTK_FontWidget::GetData( QColor& theColor, @@ -122,17 +84,17 @@ void SVTK_FontWidget::GetData( QColor& theColor, bool& theItalic, bool& theShadow ) const { - theColor = GetColor(); + ViewerTools_FontWidgetBase::GetData( theColor, + theFamily, + theBold, + theItalic, + theShadow ); - int anItem =myFamily->currentIndex(); + int anItem = myFamily->currentIndex(); if ( anItem == 0 ) theFamily = VTK_ARIAL; else if ( anItem == 1 ) theFamily = VTK_COURIER; else theFamily = VTK_TIMES; - - theBold = myBold->isChecked(); - theItalic = myItalic->isChecked(); - theShadow = myShadow->isChecked(); } diff --git a/src/SVTK/SVTK_FontWidget.h b/src/SVTK/SVTK_FontWidget.h index 6150dfe5f..dde1e4be7 100644 --- a/src/SVTK/SVTK_FontWidget.h +++ b/src/SVTK/SVTK_FontWidget.h @@ -29,19 +29,13 @@ #include "SVTK.h" -#include - -class QToolButton; -class QComboBox; -class QCheckBox; -class QColor; - +#include /*! * Class : SVTK_FontWidget * Description : Dialog for specifynig font */ -class SVTK_EXPORT SVTK_FontWidget : public QWidget +class SVTK_EXPORT SVTK_FontWidget : public ViewerTools_FontWidgetBase { Q_OBJECT @@ -49,22 +43,12 @@ public: SVTK_FontWidget( QWidget* ); virtual ~SVTK_FontWidget(); - void SetColor( const QColor& ); - QColor GetColor() const; - - void SetData( const QColor&, const int, const bool, const bool, const bool ); - - void GetData( QColor&, int&, bool&, bool&, bool& ) const; + virtual void SetData( const QColor&, const int, const bool, const bool, const bool ); -private slots: - void onColor(); + virtual void GetData( QColor&, int&, bool&, bool&, bool& ) const; -private: - QToolButton* myColorBtn; - QComboBox* myFamily; - QCheckBox* myBold; - QCheckBox* myItalic; - QCheckBox* myShadow; +protected: + virtual void InitializeFamilies(); }; #endif diff --git a/src/SVTK/SVTK_NonIsometricDlg.cxx b/src/SVTK/SVTK_NonIsometricDlg.cxx index a1c5c6da0..ac35cdc10 100644 --- a/src/SVTK/SVTK_NonIsometricDlg.cxx +++ b/src/SVTK/SVTK_NonIsometricDlg.cxx @@ -47,9 +47,9 @@ SVTK_NonIsometricDlg ::SVTK_NonIsometricDlg(QtxAction* theAction, SVTK_ViewWindow* theParent, const char* theName): - SVTK_DialogBase(theAction, - theParent, - theName), + ViewerTools_DialogBase(theAction, + theParent, + theName), m_MainWindow(theParent) { setWindowTitle(tr("DLG_TITLE")); diff --git a/src/SVTK/SVTK_NonIsometricDlg.h b/src/SVTK/SVTK_NonIsometricDlg.h index 1e2573d1d..dced659d9 100644 --- a/src/SVTK/SVTK_NonIsometricDlg.h +++ b/src/SVTK/SVTK_NonIsometricDlg.h @@ -29,7 +29,7 @@ #ifndef SVTK_NONISOMETRICDLG_H #define SVTK_NONISOMETRICDLG_H -#include "SVTK_DialogBase.h" +#include class SVTK_ViewWindow; @@ -39,7 +39,7 @@ class QtxAction; class QPushButton; -class SVTK_NonIsometricDlg : public SVTK_DialogBase +class SVTK_NonIsometricDlg : public ViewerTools_DialogBase { Q_OBJECT; diff --git a/src/SVTK/SVTK_SetRotationPointDlg.cxx b/src/SVTK/SVTK_SetRotationPointDlg.cxx index 28ac37ec7..eec869920 100755 --- a/src/SVTK/SVTK_SetRotationPointDlg.cxx +++ b/src/SVTK/SVTK_SetRotationPointDlg.cxx @@ -55,9 +55,9 @@ SVTK_SetRotationPointDlg ::SVTK_SetRotationPointDlg(QtxAction* theAction, SVTK_ViewWindow* theParent, const char* theName): - SVTK_DialogBase(theAction, - theParent, - theName), + ViewerTools_DialogBase(theAction, + theParent, + theName), myMainWindow(theParent), myPriority(0.0), myEventCallbackCommand(vtkCallbackCommand::New()), diff --git a/src/SVTK/SVTK_SetRotationPointDlg.h b/src/SVTK/SVTK_SetRotationPointDlg.h index e87335e3f..ed807b66c 100755 --- a/src/SVTK/SVTK_SetRotationPointDlg.h +++ b/src/SVTK/SVTK_SetRotationPointDlg.h @@ -31,7 +31,7 @@ #include "SVTK.h" -#include "SVTK_DialogBase.h" +#include #include @@ -48,7 +48,7 @@ class QCheckBox; class vtkCallbackCommand; class vtkObject; -class SVTK_EXPORT SVTK_SetRotationPointDlg : public SVTK_DialogBase +class SVTK_EXPORT SVTK_SetRotationPointDlg : public ViewerTools_DialogBase { Q_OBJECT; diff --git a/src/SVTK/SVTK_UpdateRateDlg.cxx b/src/SVTK/SVTK_UpdateRateDlg.cxx index 373471ffe..d73408be7 100644 --- a/src/SVTK/SVTK_UpdateRateDlg.cxx +++ b/src/SVTK/SVTK_UpdateRateDlg.cxx @@ -169,9 +169,9 @@ SVTK_UpdateRateDlg ::SVTK_UpdateRateDlg(QtxAction* theAction, SVTK_ViewWindow* theParent, const char* theName): - SVTK_DialogBase(theAction, - theParent, - theName), + ViewerTools_DialogBase(theAction, + theParent, + theName), myPriority(0.0), myEventCallbackCommand(vtkCallbackCommand::New()), myRWInteractor(theParent->GetInteractor()), diff --git a/src/SVTK/SVTK_UpdateRateDlg.h b/src/SVTK/SVTK_UpdateRateDlg.h index 045c2d35a..61ec0a622 100644 --- a/src/SVTK/SVTK_UpdateRateDlg.h +++ b/src/SVTK/SVTK_UpdateRateDlg.h @@ -29,7 +29,7 @@ #ifndef SVTK_UPDATERATEDLG_H #define SVTK_UPDATERATEDLG_H -#include "SVTK_DialogBase.h" +#include #include @@ -46,7 +46,7 @@ class vtkCallbackCommand; class vtkObject; -class SVTK_UpdateRateDlg : public SVTK_DialogBase +class SVTK_UpdateRateDlg : public ViewerTools_DialogBase { Q_OBJECT; diff --git a/src/SVTK/SVTK_ViewParameterDlg.cxx b/src/SVTK/SVTK_ViewParameterDlg.cxx index 600250b4d..b4400f558 100755 --- a/src/SVTK/SVTK_ViewParameterDlg.cxx +++ b/src/SVTK/SVTK_ViewParameterDlg.cxx @@ -56,7 +56,7 @@ using namespace std; SVTK_ViewParameterDlg::SVTK_ViewParameterDlg(QtxAction* theAction, SVTK_ViewWindow* theParent, const char* theName): - SVTK_DialogBase(theAction, theParent, theName), + ViewerTools_DialogBase(theAction, theParent, theName), myMainWindow(theParent), myPriority(0.0), myEventCallbackCommand(vtkCallbackCommand::New()), diff --git a/src/SVTK/SVTK_ViewParameterDlg.h b/src/SVTK/SVTK_ViewParameterDlg.h index b98770063..acef99e54 100755 --- a/src/SVTK/SVTK_ViewParameterDlg.h +++ b/src/SVTK/SVTK_ViewParameterDlg.h @@ -28,7 +28,7 @@ #include "SVTK.h" -#include "SVTK_DialogBase.h" +#include #include #include @@ -47,7 +47,7 @@ class QButtonGroup; class vtkCallbackCommand; class vtkObject; -class SVTK_EXPORT SVTK_ViewParameterDlg : public SVTK_DialogBase +class SVTK_EXPORT SVTK_ViewParameterDlg : public ViewerTools_DialogBase { Q_OBJECT; diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index a8fa48f19..440bf08ce 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -165,6 +165,7 @@ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel) myUpdateRateDlg = new SVTK_UpdateRateDlg( getAction( UpdateRate ), this, "SVTK_UpdateRateDlg" ); myNonIsometricDlg = new SVTK_NonIsometricDlg( getAction( NonIsometric ), this, "SVTK_NonIsometricDlg" ); myCubeAxesDlg = new SVTK_CubeAxesDlg( getAction( GraduatedAxes ), this, "SVTK_CubeAxesDlg" ); + myCubeAxesDlg->initialize(); mySetRotationPointDlg = new SVTK_SetRotationPointDlg ( getAction( ChangeRotationPointId ), this, "SVTK_SetRotationPointDlg" ); myViewParameterDlg = new SVTK_ViewParameterDlg diff --git a/src/SVTK/resources/SVTK_msg_en.ts b/src/SVTK/resources/SVTK_msg_en.ts index 3663ce51e..8593ed6fa 100644 --- a/src/SVTK/resources/SVTK_msg_en.ts +++ b/src/SVTK/resources/SVTK_msg_en.ts @@ -188,67 +188,8 @@ Interaction Style Switch - - SVTK_CubeAxesDlg - - X_AXIS - X axis - - - Y_AXIS - Y axis - - - Z_AXIS - Z axis - - - CAPTION - Graduated axes - - - IS_VISIBLE - Is visible - - - FONT - Font - - - NAME - Name - - - TICK_MARKS - Tick marks - - - LABELS - Labels - - - LENGTH - Length - - - NUMBER - Number - - - OFFSET - Offset - - - AXIS_NAME - Axis name - - SVTK_FontWidget - - BOLD - Bold - ARIAL Arial @@ -257,14 +198,6 @@ TIMES Times - - ITALIC - Italic - - - SHADOW - Shadow - COURIER Courier diff --git a/src/SalomeApp/resources/SalomeApp.xml b/src/SalomeApp/resources/SalomeApp.xml index 542811fc7..0a037a064 100644 --- a/src/SalomeApp/resources/SalomeApp.xml +++ b/src/SalomeApp/resources/SalomeApp.xml @@ -69,6 +69,7 @@ + diff --git a/src/ViewerTools/Makefile.am b/src/ViewerTools/Makefile.am new file mode 100755 index 000000000..eefbd3a19 --- /dev/null +++ b/src/ViewerTools/Makefile.am @@ -0,0 +1,55 @@ +# Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# 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 +# + +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +lib_LTLIBRARIES = libViewerTools.la + +salomeinclude_HEADERS= \ + ViewerTools.h \ + ViewerTools_CubeAxesDlgBase.h \ + ViewerTools_DialogBase.h \ + ViewerTools_FontWidgetBase.h + +dist_libViewerTools_la_SOURCES= \ + ViewerTools_CubeAxesDlgBase.cxx \ + ViewerTools_DialogBase.cxx \ + ViewerTools_FontWidgetBase.cxx + +MOC_FILES= \ + ViewerTools_CubeAxesDlgBase_moc.cxx \ + ViewerTools_DialogBase_moc.cxx \ + ViewerTools_FontWidgetBase_moc.cxx + +nodist_libViewerTools_la_SOURCES= $(MOC_FILES) + +nodist_salomeres_DATA = \ + ViewerTools_msg_en.qm + +libViewerTools_la_CPPFLAGS = \ + $(QT_INCLUDES) \ + -I$(srcdir)/../Qtx + +libViewerTools_la_LDFLAGS = \ + $(QT_MT_LIBS) + +libViewerTools_la_LIBADD = ../Qtx/libqtx.la diff --git a/src/ViewerTools/ViewerTools.h b/src/ViewerTools/ViewerTools.h new file mode 100644 index 000000000..f79e2c23d --- /dev/null +++ b/src/ViewerTools/ViewerTools.h @@ -0,0 +1,41 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 VIEWERTOOLS_H +#define VIEWERTOOLS_H + +#ifdef WIN32 +# if defined VIEWERTOOLS_EXPORTS +# define VIEWERTOOLS_EXPORT __declspec(dllexport) +# else +# define VIEWERTOOLS_EXPORT __declspec(dllimport) +# endif +#else +# define VIEWERTOOLS_EXPORT +#endif + +#if defined WIN32 +#pragma warning ( disable: 4251 ) +#pragma warning ( disable: 4786 ) +#endif + +#endif diff --git a/src/ViewerTools/ViewerTools_CubeAxesDlgBase.cxx b/src/ViewerTools/ViewerTools_CubeAxesDlgBase.cxx new file mode 100644 index 000000000..f3f1e0e08 --- /dev/null +++ b/src/ViewerTools/ViewerTools_CubeAxesDlgBase.cxx @@ -0,0 +1,322 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// + +#include "ViewerTools_CubeAxesDlgBase.h" + +#include "ViewerTools_FontWidgetBase.h" + +#include "QtxAction.h" +#include "QtxIntSpinBox.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/*! + * Class : ViewerTools_AxisWidgetBase + * Description : Axis tab widget of the "Graduated axis" dialog box +*/ + +/*! + Constructor +*/ +ViewerTools_AxisWidgetBase::ViewerTools_AxisWidgetBase (QWidget* theParent) +: QFrame(theParent) +{ +} + +/*! + Destructor +*/ +ViewerTools_AxisWidgetBase::~ViewerTools_AxisWidgetBase() +{ +} + +/*! + Initialize controls +*/ +void ViewerTools_AxisWidgetBase::initialize() +{ + QList< QLabel* > aLabels; + + // "Name" grp + + myNameGrp = new QGroupBox(ViewerTools_CubeAxesDlgBase::tr("AXIS_NAME"), this); + myNameGrp->setCheckable( true ); + + QVBoxLayout* aVBox = new QVBoxLayout; + + QHBoxLayout* aHBox = new QHBoxLayout; + aHBox->setSpacing(5); + QLabel* aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("NAME")); + aHBox->addWidget(aLabel); + myAxisName = new QLineEdit; + aHBox->addWidget(myAxisName); + aLabels.append(aLabel); + aVBox->addLayout(aHBox); + + aHBox = new QHBoxLayout; + aHBox->setSpacing(5); + aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("FONT")); + aHBox->addWidget(aLabel); + myNameFont = createFontWidget(myNameGrp); + aHBox->addWidget(myNameFont); + aLabels.append(aLabel); + aVBox->addLayout(aHBox); + + myNameGrp->setLayout(aVBox); + + // "Labels" grp + + myLabelsGrp = new QGroupBox(ViewerTools_CubeAxesDlgBase::tr("LABELS"), this); + myLabelsGrp->setCheckable( true ); + + aVBox = new QVBoxLayout; + + aHBox = new QHBoxLayout; + aHBox->setSpacing(5); + aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("NUMBER")); + aHBox->addWidget(aLabel); + myLabelNumber = new QtxIntSpinBox(2,25,1,myLabelsGrp); + aHBox->addWidget(myLabelNumber); + aLabels.append(aLabel); + aVBox->addLayout(aHBox); + + aHBox = new QHBoxLayout; + aHBox->setSpacing(5); + aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("OFFSET")); + aHBox->addWidget(aLabel); + myLabelOffset = new QtxIntSpinBox(0,100,1,myLabelsGrp); + aHBox->addWidget(myLabelOffset); + aLabels.append(aLabel); + aVBox->addLayout(aHBox); + + aHBox = new QHBoxLayout; + aHBox->setSpacing(5); + aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("FONT")); + aHBox->addWidget(aLabel); + myLabelsFont = createFontWidget(myLabelsGrp); + aHBox->addWidget(myLabelsFont); + aLabels.append(aLabel); + aVBox->addLayout(aHBox); + + myLabelsGrp->setLayout(aVBox); + + // "Tick marks" grp + + myTicksGrp = new QGroupBox(ViewerTools_CubeAxesDlgBase::tr("TICK_MARKS"), this); + myTicksGrp->setCheckable( true ); + + aVBox = new QVBoxLayout; + + aHBox = new QHBoxLayout; + aHBox->setSpacing(5); + aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("LENGTH")); + aHBox->addWidget(aLabel); + myTickLength = new QtxIntSpinBox(0,100,1,myTicksGrp); + aHBox->addWidget(myTickLength); + aLabels.append(aLabel); + aVBox->addLayout(aHBox); + + myTicksGrp->setLayout(aVBox); + + // Layout + + QVBoxLayout* aLay = new QVBoxLayout(this); + aLay->setMargin(5); + aLay->setSpacing(5); + aLay->addWidget(myNameGrp); + aLay->addWidget(myLabelsGrp); + aLay->addWidget(myTicksGrp); + + // init + myNameGrp->setChecked( true ); + myLabelsGrp->setChecked( true ); + myTicksGrp->setChecked( true ); + + // Adjust label widths + QList< QLabel* >::iterator anIter; + int aMaxWidth = 0; + for (anIter = aLabels.begin(); anIter != aLabels.end(); anIter++) + aMaxWidth = qMax(aMaxWidth, (*anIter)->sizeHint().width()); + for (anIter = aLabels.begin(); anIter != aLabels.end(); anIter++) + (*anIter)->setFixedWidth(aMaxWidth); +} + +void ViewerTools_AxisWidgetBase::UseName(const bool toUse) +{ + myNameGrp->setChecked(toUse); +} + +void ViewerTools_AxisWidgetBase::SetName(const QString& theName) +{ + myAxisName->setText(theName); +} + +void ViewerTools_AxisWidgetBase::SetNameFont(const QColor& theColor, + const int theFont, + const bool theIsBold, + const bool theIsItalic, + const bool theIsShadow) +{ + myNameFont->SetData(theColor, theFont, theIsBold, theIsItalic, theIsShadow); +} + +/* + Class : ViewerTools_CubeAxesDlgBase + Description : Dialog for specifying cube axes properties +*/ + +/*! + Constructor +*/ +ViewerTools_CubeAxesDlgBase::ViewerTools_CubeAxesDlgBase(QtxAction* theAction, + QWidget* theParent, + const char* theName): + ViewerTools_DialogBase(theAction, + theParent, + theName) +{ + setWindowTitle(tr("CAPTION")); +} + +/*! + Initialize controls +*/ +void ViewerTools_CubeAxesDlgBase::initialize() +{ + QVBoxLayout* aLay = new QVBoxLayout(this); + aLay->setMargin(5); + aLay->setSpacing(5); + aLay->addWidget(createMainFrame(this)); + aLay->addWidget(createButtonFrame(this)); +} + +/*! + Create frame containing dialog's input fields +*/ +QWidget* ViewerTools_CubeAxesDlgBase::createMainFrame(QWidget* theParent) +{ + QFrame* aFrame = new QFrame(theParent); + + myTabWg = new QTabWidget(aFrame); + + myAxes[ 0 ] = createAxisWidget(myTabWg); + myAxes[ 1 ] = createAxisWidget(myTabWg); + myAxes[ 2 ] = createAxisWidget(myTabWg); + + myTabWg->addTab(myAxes[ 0 ], tr("X_AXIS")); + myTabWg->addTab(myAxes[ 1 ], tr("Y_AXIS")); + myTabWg->addTab(myAxes[ 2 ], tr("Z_AXIS")); + + myIsVisible = new QCheckBox(tr("IS_VISIBLE"), aFrame); + + QVBoxLayout* aLay = new QVBoxLayout(aFrame); + aLay->setMargin(0); + aLay->setSpacing(5); + aLay->addWidget(myTabWg); + aLay->addWidget(myIsVisible); + + return aFrame; +} + +/*! + Create frame containing buttons +*/ +QWidget* ViewerTools_CubeAxesDlgBase::createButtonFrame(QWidget* theParent) +{ + QFrame* aFrame = new QFrame(theParent); + aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken); + + myOkBtn = new QPushButton(tr("BUT_OK"), aFrame); + myApplyBtn = new QPushButton(tr("BUT_APPLY"), aFrame); + myCloseBtn = new QPushButton(tr("BUT_CLOSE"), aFrame); + + QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); + + QHBoxLayout* aLay = new QHBoxLayout(aFrame); + aLay->setMargin(5); + aLay->setSpacing(5); + + aLay->addWidget(myOkBtn); + aLay->addWidget(myApplyBtn); + aLay->addItem(aSpacer); + aLay->addWidget(myCloseBtn); + + connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); + connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply())); + connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); + + return aFrame; +} + +/*! + Destructor +*/ +ViewerTools_CubeAxesDlgBase::~ViewerTools_CubeAxesDlgBase() +{ +} + +/*! + Update dialog fields, connect signals and slots, show dialog +*/ +void ViewerTools_CubeAxesDlgBase::Update() +{ +} + +/*! + Verify validity of entry data +*/ +bool ViewerTools_CubeAxesDlgBase::isValid() const +{ + return true; +} + +/*! + Verify validity of entry data +*/ +bool ViewerTools_CubeAxesDlgBase::onApply() +{ + return true; +} + +/*! + SLOT called when "Ok" button pressed. +*/ +void ViewerTools_CubeAxesDlgBase::onOk() +{ + if (onApply()) + onClose(); +} + +/*! + SLOT: called when "Close" button pressed. Close dialog +*/ +void ViewerTools_CubeAxesDlgBase::onClose() +{ + reject(); +} diff --git a/src/ViewerTools/ViewerTools_CubeAxesDlgBase.h b/src/ViewerTools/ViewerTools_CubeAxesDlgBase.h new file mode 100644 index 000000000..d7e7b8539 --- /dev/null +++ b/src/ViewerTools/ViewerTools_CubeAxesDlgBase.h @@ -0,0 +1,119 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 VIEWERTOOLS_CUBEAXESDLGBASE_H +#define VIEWERTOOLS_CUBEAXESDLGBASE_H + +#include "ViewerTools_DialogBase.h" + +#include + +class QWidget; +class QPushButton; +class QTabWidget; +class QCheckBox; +class QGroupBox; +class QLineEdit; + +class QtxAction; +class QtxIntSpinBox; + +class ViewerTools_FontWidgetBase; + +/*! + * Class : ViewerTools_AxisWidgetBase + * Description : Axis tab widget of the "Graduated axis" dialog box +*/ +class VIEWERTOOLS_EXPORT ViewerTools_AxisWidgetBase : public QFrame +{ +public: + ViewerTools_AxisWidgetBase( QWidget* ); + ~ViewerTools_AxisWidgetBase(); + + void UseName( const bool ); + void SetName( const QString& ); + void SetNameFont( const QColor&, const int, const bool, const bool, const bool ); + +public: + virtual void initialize(); + +protected: + virtual ViewerTools_FontWidgetBase* createFontWidget( QWidget* ) = 0; + +protected: + // name + QGroupBox* myNameGrp; + QLineEdit* myAxisName; + ViewerTools_FontWidgetBase* myNameFont; + + // labels + QGroupBox* myLabelsGrp; + QtxIntSpinBox* myLabelNumber; + QtxIntSpinBox* myLabelOffset; + ViewerTools_FontWidgetBase* myLabelsFont; + + // tick marks + QGroupBox* myTicksGrp; + QtxIntSpinBox* myTickLength; +}; + +/*! + * Class : ViewerTools_CubeAxesDlgBase + * Description : Dialog for specifying cube axes properties + */ +class VIEWERTOOLS_EXPORT ViewerTools_CubeAxesDlgBase : public ViewerTools_DialogBase +{ + Q_OBJECT + +public: + ViewerTools_CubeAxesDlgBase(QtxAction* theAction, + QWidget* theParent, + const char* theName); + virtual ~ViewerTools_CubeAxesDlgBase(); + + virtual void initialize(); + + virtual void Update(); + +protected slots: + virtual void onOk(); + virtual bool onApply(); + virtual void onClose(); + +protected: + virtual QWidget* createButtonFrame( QWidget* ); + virtual QWidget* createMainFrame ( QWidget* ); + virtual bool isValid() const; + + virtual ViewerTools_AxisWidgetBase* createAxisWidget( QWidget* ) = 0; + +protected: + QTabWidget* myTabWg; + QCheckBox* myIsVisible; + + QPushButton* myOkBtn; + QPushButton* myApplyBtn; + QPushButton* myCloseBtn; + ViewerTools_AxisWidgetBase* myAxes[ 3 ]; +}; + +#endif diff --git a/src/ViewerTools/ViewerTools_DialogBase.cxx b/src/ViewerTools/ViewerTools_DialogBase.cxx new file mode 100644 index 000000000..2fc0e407b --- /dev/null +++ b/src/ViewerTools/ViewerTools_DialogBase.cxx @@ -0,0 +1,79 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// + +#include "ViewerTools_DialogBase.h" + +#include "QtxAction.h" + +/*! + Constructor +*/ +ViewerTools_DialogBase +::ViewerTools_DialogBase(QtxAction* theAction, + QWidget* theParent, + const char* theName, + bool theModal, + Qt::WindowFlags theWFalgs): + QDialog(theParent, + theWFalgs | Qt::WindowTitleHint | Qt::WindowSystemMenuHint), + myAction(theAction) +{ + setObjectName(theName); + setModal(theModal); + + connect(theParent, SIGNAL(Show( QShowEvent * )), this, SLOT(onParentShow())); + connect(theParent, SIGNAL(Hide( QHideEvent * )), this, SLOT(onParentHide())); +} + +/* + * Destroys the object and frees any allocated resources + */ +ViewerTools_DialogBase +::~ViewerTools_DialogBase() +{ + // no need to delete child widgets, Qt does it all for us +} + +void +ViewerTools_DialogBase +::onParentShow() +{ + if(myAction->isChecked()) + show(); + else + hide(); +} + +void +ViewerTools_DialogBase +::onParentHide() +{ + hide(); +} + +void +ViewerTools_DialogBase +::done( int r ) +{ + myAction->setChecked( false ); + QDialog::done( r ); +} diff --git a/src/ViewerTools/ViewerTools_DialogBase.h b/src/ViewerTools/ViewerTools_DialogBase.h new file mode 100644 index 000000000..e9fcd56c3 --- /dev/null +++ b/src/ViewerTools/ViewerTools_DialogBase.h @@ -0,0 +1,54 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 VIEWERTOOLS_DIALOGBASE_H +#define VIEWERTOOLS_DIALOGBASE_H + +#include "ViewerTools.h" + +#include + +class QtxAction; + +class VIEWERTOOLS_EXPORT ViewerTools_DialogBase : public QDialog +{ + Q_OBJECT; + +public: + ViewerTools_DialogBase(QtxAction* theAction, + QWidget* theParent, + const char* theName = "", + bool theModal = FALSE, + Qt::WindowFlags theWFalgs = 0); + + ~ViewerTools_DialogBase(); + +protected slots: + void onParentShow(); + void onParentHide(); + virtual void done( int ); + +protected: + QtxAction* myAction; +}; + +#endif // VIEWERTOOLS_DIALOGBASE_H diff --git a/src/ViewerTools/ViewerTools_FontWidgetBase.cxx b/src/ViewerTools/ViewerTools_FontWidgetBase.cxx new file mode 100644 index 000000000..2558546f2 --- /dev/null +++ b/src/ViewerTools/ViewerTools_FontWidgetBase.cxx @@ -0,0 +1,128 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// + +#include "ViewerTools_FontWidgetBase.h" + +#include +#include +#include +#include +#include + +/*! + * Class : ViewerTools_FontWidgetBase + * Description : Dialog for specifynig font + */ + +/*! + Constructor +*/ +ViewerTools_FontWidgetBase::ViewerTools_FontWidgetBase( QWidget* theParent ) +: QWidget( theParent ) +{ +} + +/*! + Destructor +*/ +ViewerTools_FontWidgetBase::~ViewerTools_FontWidgetBase() +{ +} + +void ViewerTools_FontWidgetBase::Initialize() +{ + myColorBtn = new QToolButton( this ); + myColorBtn->setMinimumWidth( 20 ); + + myFamily = new QComboBox( this ); + InitializeFamilies(); + + myBold = new QCheckBox( tr( "BOLD" ), this ); + myItalic = new QCheckBox( tr( "ITALIC" ), this ); + myShadow = new QCheckBox( tr( "SHADOW" ), this ); + + QHBoxLayout* aHBLayout = new QHBoxLayout; + aHBLayout->setMargin( 0 ); + aHBLayout->setSpacing( 5 ); + aHBLayout->addWidget(myColorBtn); + aHBLayout->addWidget(myFamily); + aHBLayout->addWidget(myBold); + aHBLayout->addWidget(myItalic); + aHBLayout->addWidget(myShadow); + aHBLayout->addStretch(); + this->setLayout(aHBLayout); + + connect( myColorBtn, SIGNAL( clicked() ), SLOT( onColor() ) ); + + if( myFamily->count() == 0 ) + { + myFamily->hide(); + myBold->hide(); + myItalic->hide(); + myShadow->hide(); + } +} + +void ViewerTools_FontWidgetBase::SetColor( const QColor& theColor ) +{ + QPalette palette; + palette.setColor(myColorBtn->backgroundRole(), theColor); + myColorBtn->setPalette(palette); +} + +QColor ViewerTools_FontWidgetBase::GetColor() const +{ + return myColorBtn->palette().color( myColorBtn->backgroundRole() ); +} + +void ViewerTools_FontWidgetBase::onColor() +{ + QColor aColor = QColorDialog::getColor( GetColor(), this ); + if ( aColor.isValid() ) + SetColor( aColor ); +} + +void ViewerTools_FontWidgetBase::SetData( const QColor& theColor, + const int theFamily, + const bool theBold, + const bool theItalic, + const bool theShadow ) +{ + SetColor( theColor ); + + myBold->setChecked( theBold ); + myItalic->setChecked( theItalic ); + myShadow->setChecked( theShadow ); +} + +void ViewerTools_FontWidgetBase::GetData( QColor& theColor, + int& theFamily, + bool& theBold, + bool& theItalic, + bool& theShadow ) const +{ + theColor = GetColor(); + + theBold = myBold->isChecked(); + theItalic = myItalic->isChecked(); + theShadow = myShadow->isChecked(); +} diff --git a/src/ViewerTools/ViewerTools_FontWidgetBase.h b/src/ViewerTools/ViewerTools_FontWidgetBase.h new file mode 100644 index 000000000..9ade57abc --- /dev/null +++ b/src/ViewerTools/ViewerTools_FontWidgetBase.h @@ -0,0 +1,71 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 VIEWERTOOLS_FONTWIDGETBASE_H +#define VIEWERTOOLS_FONTWIDGETBASE_H + +#include "ViewerTools.h" + +#include + +class QToolButton; +class QComboBox; +class QCheckBox; +class QColor; + +/*! + * Class : ViewerTools_FontWidgetBase + * Description : Dialog for specifying font + */ +class VIEWERTOOLS_EXPORT ViewerTools_FontWidgetBase : public QWidget +{ + Q_OBJECT + +public: + ViewerTools_FontWidgetBase( QWidget* ); + virtual ~ViewerTools_FontWidgetBase(); + + void SetColor( const QColor& ); + QColor GetColor() const; + + virtual void SetData( const QColor&, const int, const bool, const bool, const bool ); + + virtual void GetData( QColor&, int&, bool&, bool&, bool& ) const; + +public: + virtual void Initialize(); + +protected: + virtual void InitializeFamilies() = 0; + +protected slots: + void onColor(); + +protected: + QToolButton* myColorBtn; + QComboBox* myFamily; + QCheckBox* myBold; + QCheckBox* myItalic; + QCheckBox* myShadow; +}; + +#endif diff --git a/src/ViewerTools/resources/ViewerTools_msg_en.ts b/src/ViewerTools/resources/ViewerTools_msg_en.ts new file mode 100644 index 000000000..fe8c8598d --- /dev/null +++ b/src/ViewerTools/resources/ViewerTools_msg_en.ts @@ -0,0 +1,95 @@ + + + + ViewerTools_CubeAxesDlgBase + + X_AXIS + X axis + + + Y_AXIS + Y axis + + + Z_AXIS + Z axis + + + CAPTION + Graduated axes + + + IS_VISIBLE + Is visible + + + FONT + Font + + + NAME + Name + + + TICK_MARKS + Tick marks + + + LABELS + Labels + + + LENGTH + Length + + + NUMBER + Number + + + OFFSET + Offset + + + AXIS_NAME + Axis name + + + + ViewerTools_FontWidgetBase + + BOLD + Bold + + + ITALIC + Italic + + + SHADOW + Shadow + + +