From: apo Date: Mon, 3 Oct 2005 06:23:36 +0000 (+0000) Subject: To add CubeAxes control to SVTK_MainView X-Git-Tag: BR-D5-38-2003_D2005-12-10~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=71dd3f078736a459cf2915546cf146078aae98ef;p=modules%2Fgui.git To add CubeAxes control to SVTK_MainView --- diff --git a/src/SVTK/Makefile.in b/src/SVTK/Makefile.in index bf8c8e599..42fd65c20 100755 --- a/src/SVTK/Makefile.in +++ b/src/SVTK/Makefile.in @@ -1,7 +1,7 @@ # File : Makefile.in # Author : Alexander Solovyov(OCN) # Module : SVTK -# $Header: /dn06/SALOME_CVS/GUI_SRC/src/SVTK/Makefile.in,v 1.1 +# $Header: top_srcdir=@top_srcdir@ top_builddir=../.. @@ -17,8 +17,8 @@ EXPORT_HEADERS= \ SVTK_Prs.h \ SVTK_Actor.h \ SALOME_Actor.h \ + SVTK_FontWidget.h \ SVTK_CubeAxesActor2D.h \ - SVTK_NonIsometricDlg.h \ SVTK_Functor.h \ SVTK_MainWindow.h \ SVTK_View.h \ @@ -45,6 +45,8 @@ LIB_SRC= \ SALOME_Actor.cxx \ SVTK_CubeAxesActor2D.cxx \ SVTK_NonIsometricDlg.cxx \ + SVTK_CubeAxesDlg.cxx \ + SVTK_FontWidget.cxx \ SVTK_Trihedron.cxx \ SVTK_MainWindow.cxx \ SVTK_View.cxx \ @@ -62,6 +64,8 @@ LIB_MOC = \ SVTK_GenericRenderWindowInteractor.h \ SVTK_RenderWindowInteractor.h \ SVTK_NonIsometricDlg.h \ + SVTK_CubeAxesDlg.h \ + SVTK_FontWidget.h \ SVTK_ViewModelBase.h \ SVTK_ViewManager.h \ SVTK_ViewWindow.h \ diff --git a/src/SVTK/SVTK.cxx b/src/SVTK/SVTK.cxx index 20b3ae94c..a8f334e13 100644 --- a/src/SVTK/SVTK.cxx +++ b/src/SVTK/SVTK.cxx @@ -36,6 +36,8 @@ #include "SVTK_MainWindow.h" #include "SVTK_MainWindow.h" #include "SVTK_NonIsometricDlg.h" +#include "SVTK_CubeAxesDlg.h" +#include "SVTK_FontWidget.h" #include "SVTK_ViewModel.h" #include "SVTK_ViewWindow.h" #include "SVTK_Renderer.h" diff --git a/src/SVTK/SVTK_CubeAxesDlg.cxx b/src/SVTK/SVTK_CubeAxesDlg.cxx new file mode 100644 index 000000000..72552c6ba --- /dev/null +++ b/src/SVTK/SVTK_CubeAxesDlg.cxx @@ -0,0 +1,566 @@ +// VISU VISUGUI : GUI for SMESH component +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SVTK_CubeAxesDlg.cxx +// Author : Sergey LITONIN +// Module : VISU + +#include "SVTK_CubeAxesDlg.h" + +#include "SVTK_MainWindow.h" +#include "SVTK_FontWidget.h" + +#include "SVTK_CubeAxesActor2D.h" + +#include "QtxAction.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/*! + * Class : AxisWg + * Description : Tab of dialog + */ + +//======================================================================= +// name : SVTK_AxisWidget::AxisWg +// Purpose : Constructor +//======================================================================= +SVTK_AxisWidget::SVTK_AxisWidget (QWidget* theParent) +: QFrame(theParent) +{ + QValueList< QLabel* > aLabels; + + // "Name" grp + + myNameGrp = new QGroupBox(3, Qt::Vertical, tr("AXIS_NAME"), this); + myIsNameVisible = new QCheckBox(tr("IS_VISIBLE"), myNameGrp); + + QHBox* aHBox = new QHBox(myNameGrp); + aHBox->setSpacing(5); + QLabel* aLabel = new QLabel(tr("NAME"), aHBox); + myAxisName = new QLineEdit(aHBox); + aLabels.append(aLabel); + + aHBox = new QHBox(myNameGrp); + aHBox->setSpacing(5); + aLabel = new QLabel(tr("FONT"), aHBox); + myNameFont = new SVTK_FontWidget(aHBox); + aLabels.append(aLabel); + + + // "Labels" grp + + myLabelsGrp = new QGroupBox(4, Qt::Vertical, tr("LABELS"), this); + myIsLabelsVisible = new QCheckBox(tr("IS_VISIBLE"), myLabelsGrp); + + aHBox = new QHBox(myLabelsGrp); + aHBox->setSpacing(5); + aLabel = new QLabel(tr("NUMBER"), aHBox); + myLabelNumber = new QLineEdit(aHBox); + myLabelNumber->setValidator(new QIntValidator(0, 25, this)); + myLabelNumber->installEventFilter(this); + aLabels.append(aLabel); + + aHBox = new QHBox(myLabelsGrp); + aHBox->setSpacing(5); + aLabel = new QLabel(tr("OFFSET"), aHBox); + myLabelOffset = new QLineEdit(aHBox); + aLabels.append(aLabel); + + aHBox = new QHBox(myLabelsGrp); + aHBox->setSpacing(5); + aLabel = new QLabel(tr("FONT"), aHBox); + myLabelsFont = new SVTK_FontWidget(aHBox); + aLabels.append(aLabel); + + // "Tick marks" grp + + myTicksGrp = new QGroupBox(2, Qt::Vertical, tr("TICK_MARKS"), this); + myIsTicksVisible = new QCheckBox(tr("IS_VISIBLE"), myTicksGrp); + + aHBox = new QHBox(myTicksGrp); + aHBox->setSpacing(5); + aLabel = new QLabel(tr("LENGTH"), aHBox); + myTickLength = new QLineEdit(aHBox); + aLabels.append(aLabel); + + // Layout + + QVBoxLayout* aLay = new QVBoxLayout(this, 0, 5); + aLay->addWidget(myNameGrp); + aLay->addWidget(myLabelsGrp); + aLay->addWidget(myTicksGrp); + + // init + myIsNameVisible->setChecked(true); + myIsLabelsVisible->setChecked(true); + myIsTicksVisible->setChecked(true); + updateControlState(); + + // Adjust label widths + QValueList< 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); + + // connect signals and slots + connect(myIsNameVisible, SIGNAL(stateChanged(int)), SLOT(onNameChecked())); + connect(myIsLabelsVisible, SIGNAL(stateChanged(int)), SLOT(onLabelsChecked())); + connect(myIsTicksVisible, SIGNAL(stateChanged(int)), SLOT(onTicksChecked())); +} + +SVTK_AxisWidget::~SVTK_AxisWidget() +{ +} + +void SVTK_AxisWidget::updateControlState() +{ + onNameChecked(); + onLabelsChecked(); + onTicksChecked(); +} + +bool SVTK_AxisWidget::eventFilter(QObject* o, QEvent* e) +{ + if (e->type() == QEvent::FocusOut) { + bool isOK = false; + int k = myLabelNumber->text().toInt(&isOK); + if (isOK && k > 25) myLabelNumber->setText("25"); + } + return false; +} + +//======================================================================= +// name : SVTK_AxisWidget::onNameChecked +// Purpose : +//======================================================================= +void SVTK_AxisWidget::setEnabled(QGroupBox* theGrp, const bool theState) +{ + QObjectList aChildren(*theGrp->children()); + QObject* anObj; + for(anObj = aChildren.first(); anObj !=0; anObj = aChildren.next()) + if (anObj !=0 && anObj->inherits("QHBox")) + ((QHBox*)anObj)->setEnabled(theState); +} + +//======================================================================= +// Labels : SVTK_AxisWidget::onLabelsChecked +// Purpose : +//======================================================================= +void SVTK_AxisWidget::onLabelsChecked() +{ + setEnabled(myLabelsGrp, myIsLabelsVisible->isChecked()); +} + +//======================================================================= +// Labels : SVTK_AxisWidget::onTicksChecked +// Purpose : +//======================================================================= +void SVTK_AxisWidget::onTicksChecked() +{ + setEnabled(myTicksGrp, myIsTicksVisible->isChecked()); +} + +//======================================================================= +// name : SVTK_AxisWidget::onNameChecked +// Purpose : +//======================================================================= +void SVTK_AxisWidget::onNameChecked() +{ + setEnabled(myNameGrp, myIsNameVisible->isChecked()); +} + +//======================================================================= +// name : SVTK_AxisWidget::UseName +// Purpose : +//======================================================================= +void SVTK_AxisWidget::UseName(const bool toUse) +{ + myIsNameVisible->setChecked(toUse); +} + +//======================================================================= +// name : SVTK_AxisWidget::SetName +// Purpose : +//================================================== ===================== +void SVTK_AxisWidget::SetName(const QString& theName) +{ + myAxisName->setText(theName); +} + +//======================================================================= +// name : SVTK_AxisWidget::SetNameFont +// Purpose : +//======================================================================= +void SVTK_AxisWidget::SetNameFont(const QColor& theColor, + const int theFont, + const bool theIsBold, + const bool theIsItalic, + const bool theIsShadow) +{ + myNameFont->SetData(theColor, theFont, theIsBold, theIsItalic, theIsShadow); +} + +//======================================================================= +// name : SVTK_AxisWidget::SetNameFont +// Purpose : +//======================================================================= +bool SVTK_AxisWidget::ReadData(vtkAxisActor2D* theActor) +{ + if (theActor == 0) + return false; + + // Name + + bool useName = theActor->GetTitleVisibility(); + QString aTitle(theActor->GetTitle()); + + QColor aTitleColor(255, 255, 255); + int aTitleFontFamily = VTK_ARIAL; + bool isTitleBold = false; + bool isTitleItalic = false; + bool isTitleShadow = false; + + vtkTextProperty* aTitleProp = theActor->GetTitleTextProperty(); + if (aTitleProp !=0) + { + float c[ 3 ]; + aTitleProp->GetColor(c); + aTitleColor.setRgb((int)(c[ 0 ] * 255), (int)(c[ 1 ] * 255), (int)(c[ 2 ] * 255)); + aTitleFontFamily = aTitleProp->GetFontFamily(); + isTitleBold = aTitleProp->GetBold() ? true : false; + isTitleItalic = aTitleProp->GetItalic() ? true : false; + isTitleShadow = aTitleProp->GetShadow() ? true : false; + } + + myIsNameVisible->setChecked(useName); + myAxisName->setText(aTitle); + myNameFont->SetData(aTitleColor, aTitleFontFamily, isTitleBold, isTitleItalic, isTitleShadow); + + // Labels + + bool useLabels = theActor->GetLabelVisibility(); + int nbLabels = theActor->GetNumberOfLabels(); + int anOffset = theActor->GetTickOffset(); + + QColor aLabelsColor(255, 255, 255); + int aLabelsFontFamily = VTK_ARIAL; + bool isLabelsBold = false; + bool isLabelsItalic = false; + bool isLabelsShadow = false; + + vtkTextProperty* aLabelsProp = theActor->GetLabelTextProperty(); + if (aLabelsProp !=0) + { + float c[ 3 ]; + aLabelsProp->GetColor(c); + aLabelsColor.setRgb((int)(c[ 0 ] * 255), (int)(c[ 1 ] * 255), (int)(c[ 2 ] * 255)); + aLabelsFontFamily = aLabelsProp->GetFontFamily(); + isLabelsBold = aLabelsProp->GetBold() ? true : false; + isLabelsItalic = aLabelsProp->GetItalic() ? true : false; + isLabelsShadow = aLabelsProp->GetShadow() ? true : false; + } + + myIsLabelsVisible->setChecked(useLabels); + myLabelNumber->setText(QString("%1").arg(nbLabels)); + myLabelOffset->setText(QString("%1").arg(anOffset)); + myLabelsFont->SetData(aLabelsColor, aLabelsFontFamily, isLabelsBold, isLabelsItalic, isLabelsShadow); + + // Tick marks + bool useTickMarks = theActor->GetTickVisibility(); + int aTickLength = theActor->GetTickLength(); + + myIsTicksVisible->setChecked(useTickMarks); + myTickLength->setText(QString("%1").arg(aTickLength)); + + return true; +} + +//======================================================================= +// name : SVTK_CubeAxesDlg::Apply +// Purpose : +//======================================================================= +bool SVTK_AxisWidget::Apply(vtkAxisActor2D* theActor) +{ + if (theActor == 0) + return false; + + // Name + + theActor->SetTitleVisibility(myIsNameVisible->isChecked() ? 1 : 0); + theActor->SetTitle(myAxisName->text().latin1()); + + QColor aTitleColor(255, 255, 255); + int aTitleFontFamily = VTK_ARIAL; + bool isTitleBold = false; + bool isTitleItalic = false; + bool isTitleShadow = false; + + myNameFont->GetData(aTitleColor, aTitleFontFamily, isTitleBold, isTitleItalic, isTitleShadow); + vtkTextProperty* aTitleProp = theActor->GetTitleTextProperty(); + if (aTitleProp) + { + aTitleProp->SetColor(aTitleColor.red() / 255., + aTitleColor.green() / 255., + aTitleColor.blue() / 255.); + aTitleProp->SetFontFamily(aTitleFontFamily); + + aTitleProp->SetBold(isTitleBold ? 1 : 0); + aTitleProp->SetItalic(isTitleItalic ? 1 : 0); + aTitleProp->SetShadow(isTitleShadow ? 1 : 0); + + theActor->SetTitleTextProperty(aTitleProp); + } + + // Labels + + theActor->SetLabelVisibility(myIsLabelsVisible->isChecked() ? 1 : 0); + + bool isOk = false; + int nbLabels = myLabelNumber->text().toInt(&isOk); + if (isOk) + theActor->SetNumberOfLabels(nbLabels); + + int anOffset = myLabelOffset->text().toInt(&isOk); + if (isOk) + theActor->SetTickOffset(anOffset); + + QColor aLabelsColor(255, 255, 255); + int aLabelsFontFamily = VTK_ARIAL; + bool isLabelsBold = false; + bool isLabelsItalic = false; + bool isLabelsShadow = false; + + myLabelsFont->GetData(aLabelsColor, aLabelsFontFamily, isLabelsBold, isLabelsItalic, isLabelsShadow); + vtkTextProperty* aLabelsProp = theActor->GetLabelTextProperty(); + if (aLabelsProp) + { + aLabelsProp->SetColor(aLabelsColor.red() / 255., + aLabelsColor.green() / 255., + aLabelsColor.blue() / 255.); + aLabelsProp->SetFontFamily(aLabelsFontFamily); + + aLabelsProp->SetBold(isLabelsBold ? 1 : 0); + aLabelsProp->SetItalic(isLabelsItalic ? 1 : 0); + aLabelsProp->SetShadow(isLabelsShadow ? 1 : 0); + + aLabelsProp->Modified(); + theActor->SetLabelTextProperty(aLabelsProp); + } + + + // Tick marks + theActor->SetTickVisibility(myIsTicksVisible->isChecked()); + int aTickLength = myTickLength->text().toInt(&isOk); + if (isOk) + theActor->SetTickLength(aTickLength); + + return true; +} + +/* + Class : SVTK_CubeAxesDlg + Description : Dialog for specifynig cube axes properties +*/ + +//======================================================================= +// name : SVTK_CubeAxesDlg::SVTK_CubeAxesDlg +// Purpose : Constructor +//======================================================================= +SVTK_CubeAxesDlg::SVTK_CubeAxesDlg(SVTK_MainWindow* theParent, + const char* theName, + QtxAction* theAction): + QDialog(theParent, + theName, + false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + myMainWindow(theParent), + myAction(theAction) +{ + setCaption(tr("CAPTION")); + + QVBoxLayout* aLay = new QVBoxLayout(this, 5, 5); + aLay->addWidget(createMainFrame(this)); + aLay->addWidget(createButtonFrame(this)); +} + +//======================================================================= +// name : SVTK_CubeAxesDlg::createMainFrame +// Purpose : 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 SVTK_AxisWidget(myTabWg); + myAxes[ 1 ] = new SVTK_AxisWidget(myTabWg); + myAxes[ 2 ] = new SVTK_AxisWidget(myTabWg); + + myTabWg->addTab(myAxes[ 0 ], tr("X_AXIS")); + myTabWg->addTab(myAxes[ 1 ], tr("Y_AXIS")); + myTabWg->addTab(myAxes[ 2 ], tr("Z_AXIS")); + + myTabWg->setMargin(5); + + myIsVisible = new QCheckBox(tr("IS_VISIBLE"), aFrame); + + QVBoxLayout* aLay = new QVBoxLayout(aFrame, 0, 5); + aLay->addWidget(myTabWg); + aLay->addWidget(myIsVisible); + + return aFrame; +} + +//======================================================================= +// name : SVTK_CubeAxesDlg::createButtonFrame +// Purpose : Create frame containing buttons +//======================================================================= +QWidget* SVTK_CubeAxesDlg::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, 5, 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; +} + +//======================================================================= +// name : SVTK_CubeAxesDlg::~SVTK_CubeAxesDlg +// Purpose : Destructor +//======================================================================= +SVTK_CubeAxesDlg::~SVTK_CubeAxesDlg() +{ +} + +//======================================================================= +// name : SVTK_CubeAxesDlg::Update +// Purpose : Update dialog fields, connect signals and slots, show dialog +//======================================================================= +void SVTK_CubeAxesDlg::Update() +{ + myActor = myMainWindow->GetCubeAxes(); + + myAxes[ 0 ]->ReadData(myActor->GetXAxisActor2D()); + myAxes[ 1 ]->ReadData(myActor->GetYAxisActor2D()); + myAxes[ 2 ]->ReadData(myActor->GetZAxisActor2D()); + + myIsVisible->setChecked(myActor->GetVisibility() ? true : false); +} + +//======================================================================= +// name : SVTK_CubeAxesDlg::isValid +// Purpose : Verify validity of entry data +//======================================================================= +bool SVTK_CubeAxesDlg::isValid() const +{ + return true; +} + +//======================================================================= +// name : SVTK_CubeAxesDlg::onApply +// Purpose : Verify validity of entry data +//======================================================================= +bool SVTK_CubeAxesDlg::onApply() +{ + bool isOk = true; + + try + { + isOk = isOk && myAxes[ 0 ]->Apply(myActor->GetXAxisActor2D()); + isOk = isOk && myAxes[ 1 ]->Apply(myActor->GetYAxisActor2D()); + isOk = isOk && myAxes[ 2 ]->Apply(myActor->GetZAxisActor2D()); + + + //myActor->SetXLabel(myAxes[ 0 ]->myAxisName->text()); + //myActor->SetYLabel(myAxes[ 1 ]->myAxisName->text()); + //myActor->SetZLabel(myAxes[ 2 ]->myAxisName->text()); + + //myActor->SetNumberOfLabels(myActor->GetXAxisActor2D()->GetNumberOfLabels()); + if (myIsVisible->isChecked()) + myActor->VisibilityOn(); + else + myActor->VisibilityOff(); + + if (isOk) + myMainWindow->Repaint(); + } + catch(...) + { + isOk = false; + } + + return isOk; +} + +//======================================================================= +// name : SVTK_CubeAxesDlg::onOk +// Purpose : SLOT called when "Ok" button pressed. +//======================================================================= +void SVTK_CubeAxesDlg::onOk() +{ + if (onApply()) + onClose(); +} + +//======================================================================= +// name : SVTK_CubeAxesDlg::onClose +// Purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void SVTK_CubeAxesDlg::onClose() +{ + reject(); + + myAction->setOn( false ); +} diff --git a/src/SVTK/SVTK_CubeAxesDlg.h b/src/SVTK/SVTK_CubeAxesDlg.h new file mode 100644 index 000000000..dc089f603 --- /dev/null +++ b/src/SVTK/SVTK_CubeAxesDlg.h @@ -0,0 +1,142 @@ +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SVTK_CubeAxesDlg.h +// Author : Sergey LITONIN +// Module : VISU + + +#ifndef SVTK_CubeAxesDlg_H +#define SVTK_CubeAxesDlg_H + +#include +#include + +class QWidget; +class QFrame; +class QPushButton; +class QTabWidget; +class QCheckBox; +class QLineEdit; +class QGroupBox; + +class QtxAction; + +class vtkAxisActor2D; +class SVTK_CubeAxesActor2D; + +class SVTK_FontWidget; +class SVTK_AxisWidget; +class SVTK_MainWindow; + +/*! + * Class : SVTK_CubeAxesDlg + * Description : Dialog for specifynig cube axes properties + */ +class SVTK_CubeAxesDlg : public QDialog +{ + Q_OBJECT + +public: + SVTK_CubeAxesDlg(SVTK_MainWindow* theParent, + const char* theName, + QtxAction* theAction); + virtual ~SVTK_CubeAxesDlg(); + + void Update(); + +private slots: + void onOk(); + bool onApply(); + void onClose(); + +private: + QWidget* createButtonFrame( QWidget* ); + QWidget* createMainFrame ( QWidget* ); + bool isValid() const; + +private: + SVTK_MainWindow *myMainWindow; + SVTK_CubeAxesActor2D* myActor; + QtxAction* myAction; + + QTabWidget* myTabWg; + QCheckBox* myIsVisible; + + QPushButton* myOkBtn; + QPushButton* myApplyBtn; + QPushButton* myCloseBtn; + SVTK_AxisWidget* myAxes[ 3 ]; +}; + +/*! + * Class : SVTK_AxisWidget + * Description : Tab of dialog + */ +class SVTK_AxisWidget : public QFrame +{ + Q_OBJECT + +public: + SVTK_AxisWidget( QWidget* ); + ~SVTK_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* ); + +protected: + bool eventFilter(QObject*, QEvent*); + +private slots: + void onNameChecked(); + void onLabelsChecked(); + void onTicksChecked(); + +private: + void updateControlState(); + void setEnabled( QGroupBox*, const bool ); + +private: + // name + QGroupBox* myNameGrp; + QCheckBox* myIsNameVisible; + QLineEdit* myAxisName; + SVTK_FontWidget* myNameFont; + + // labels + QGroupBox* myLabelsGrp; + QCheckBox* myIsLabelsVisible; + QLineEdit* myLabelNumber; + QLineEdit* myLabelOffset; + SVTK_FontWidget* myLabelsFont; + + // tick marks + QGroupBox* myTicksGrp; + QCheckBox* myIsTicksVisible; + QLineEdit* myTickLength; + + friend class SVTK_CubeAxesDlg; +}; + +#endif diff --git a/src/SVTK/SVTK_FontWidget.cxx b/src/SVTK/SVTK_FontWidget.cxx new file mode 100644 index 000000000..edaa9a6c0 --- /dev/null +++ b/src/SVTK/SVTK_FontWidget.cxx @@ -0,0 +1,149 @@ +// VISU VISUGUI : GUI for SMESH component +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : +// Author : Sergey LITONIN +// Module : + +#include "SVTK_FontWidget.h" + +#include +#include +#include +#include + +#include + +/*! + * Class : SVTK_FontWidget + * Description : Dialog for specifynig font + */ + +//======================================================================= +// name : SVTK_FontWidget +// Purpose : Constructor +//======================================================================= +SVTK_FontWidget::SVTK_FontWidget( QWidget* theParent ) +: QHBox( theParent ) +{ + setSpacing( 5 ); + myColorBtn = new QToolButton( this ); + myColorBtn->setMinimumWidth( 20 ); + + myFamily = new QComboBox( this ); + myFamily->insertItem( tr( "ARIAL" ) ); + myFamily->insertItem( tr( "COURIER" ) ); + myFamily->insertItem( tr( "TIMES" ) ); + + myBold = new QCheckBox( tr( "BOLD" ), this ); + myItalic = new QCheckBox( tr( "ITALIC" ), this ); + myShadow = new QCheckBox( tr( "SHADOW" ), this ); + + connect( myColorBtn, SIGNAL( clicked() ), SLOT( onColor() ) ); +} + +//======================================================================= +// name : ~SVTK_FontWidget +// Purpose : Destructor +//======================================================================= +SVTK_FontWidget::~SVTK_FontWidget() +{ +} + +//======================================================================= +// name : SetColor +// Purpose : +//======================================================================= +void SVTK_FontWidget::SetColor( const QColor& theColor ) +{ + myColorBtn->setPaletteBackgroundColor( theColor ); +} + +//======================================================================= +// name : GetColor +// Purpose : +//======================================================================= +QColor SVTK_FontWidget::GetColor() const +{ + return myColorBtn->paletteBackgroundColor(); +} + +//======================================================================= +// name : onColor +// Purpose : +//======================================================================= +void SVTK_FontWidget::onColor() +{ + QColor aColor = QColorDialog::getColor( GetColor(), this ); + if ( aColor.isValid() ) + SetColor( aColor ); +} + +//======================================================================= +// name : SetData +// Purpose : +//======================================================================= +void SVTK_FontWidget::SetData( const QColor& theColor, + const int theFamily, + const bool theBold, + const bool theItalic, + const bool theShadow ) +{ + SetColor( theColor ); + + if ( theFamily == VTK_ARIAL ) + myFamily->setCurrentItem( 0 ); + else if ( theFamily == VTK_COURIER ) + myFamily->setCurrentItem( 1 ); + else + myFamily->setCurrentItem( 2 ); + + myBold->setChecked( theBold ); + myItalic->setChecked( theItalic ); + myShadow->setChecked( theShadow ); +} + +//======================================================================= +// name : GetData +// Purpose : +//======================================================================= +void SVTK_FontWidget::GetData( QColor& theColor, + int& theFamily, + bool& theBold, + bool& theItalic, + bool& theShadow ) const +{ + theColor = GetColor(); + + int anItem =myFamily->currentItem(); + 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 new file mode 100644 index 000000000..c06e1e459 --- /dev/null +++ b/src/SVTK/SVTK_FontWidget.h @@ -0,0 +1,68 @@ +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : +// Author : Sergey LITONIN +// Module : + + +#ifndef SVTK_FontWidget_H +#define SVTK_FontWidget_H + +#include + +class QToolButton; +class QComboBox; +class QCheckBox; +class QColor; + + +/*! + * Class : SVTK_FontWidget + * Description : Dialog for specifynig font + */ +class SVTK_FontWidget : public QHBox +{ + Q_OBJECT + +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; + +private slots: + void onColor(); + +private: + QToolButton* myColorBtn; + QComboBox* myFamily; + QCheckBox* myBold; + QCheckBox* myItalic; + QCheckBox* myShadow; +}; + +#endif diff --git a/src/SVTK/SVTK_MainWindow.cxx b/src/SVTK/SVTK_MainWindow.cxx index e0a7fa3a4..22cf09b2f 100644 --- a/src/SVTK/SVTK_MainWindow.cxx +++ b/src/SVTK/SVTK_MainWindow.cxx @@ -39,6 +39,7 @@ #include "SUIT_Tools.h" #include "SUIT_ResourceMgr.h" #include "SVTK_NonIsometricDlg.h" +#include "SVTK_CubeAxesDlg.h" #include "SVTK_MainWindow.h" #include "SVTK_Event.h" @@ -482,6 +483,17 @@ SVTK_MainWindow myActionsMap[ NonIsometric ] = anAction; myNonIsometricDlg = new SVTK_NonIsometricDlg(this,"SVTK_NonIsometricDlg",anAction); + + // onGraduatedAxes: Manage graduated axes params + anAction = new QtxAction(tr("MNU_SVTK_GRADUATED_AXES"), + theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_GRADUATED_AXES" ) ), + tr( "MNU_SVTK_GRADUATED_AXES" ), 0, this); + anAction->setStatusTip(tr("DSC_SVTK_GRADUATED_AXES")); + anAction->setToggleAction(true); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onGraduatedAxes(bool))); + myActionsMap[ GraduatedAxes ] = anAction; + + myCubeAxesDlg = new SVTK_CubeAxesDlg(this,"SVTK_CubeAxesDlg",anAction); } //---------------------------------------------------------------------------- @@ -514,6 +526,7 @@ SVTK_MainWindow myActionsMap[ResetId]->addTo(myToolBar); myActionsMap[NonIsometric]->addTo(myToolBar); + myActionsMap[GraduatedAxes]->addTo(myToolBar); } //---------------------------------------------------------------------------- @@ -652,6 +665,17 @@ SVTK_MainWindow myNonIsometricDlg->hide(); } +void +SVTK_MainWindow +::onGraduatedAxes(bool theIsActivate) +{ + if(theIsActivate){ + myCubeAxesDlg->Update(); + myCubeAxesDlg->show(); + }else + myCubeAxesDlg->hide(); +} + //---------------------------------------------------------------------------- void SVTK_MainWindow diff --git a/src/SVTK/SVTK_MainWindow.h b/src/SVTK/SVTK_MainWindow.h index f9e524491..7d8d9738d 100644 --- a/src/SVTK/SVTK_MainWindow.h +++ b/src/SVTK/SVTK_MainWindow.h @@ -25,6 +25,7 @@ class SUIT_ResourceMgr; class SVTK_RenderWindowInteractor; class SVTK_NonIsometricDlg; class SVTK_CubeAxesActor2D; +class SVTK_CubeAxesDlg; class VTKViewer_Trihedron; class VTKViewer_Transform; @@ -167,6 +168,7 @@ public: void onViewCubeAxes(); void onNonIsometric(bool theIsActivate); + void onGraduatedAxes(bool theIsActivate); void onAdjustTrihedron(); void onAdjustCubeAxes(); @@ -188,10 +190,12 @@ public: enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId, FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, - ViewTrihedronId, NonIsometric}; + ViewTrihedronId, NonIsometric, GraduatedAxes}; typedef QMap TActionsMap; SVTK_NonIsometricDlg* myNonIsometricDlg; + SVTK_CubeAxesDlg* myCubeAxesDlg; + vtkSmartPointer myEventDispatcher; TActionsMap myActionsMap; QToolBar* myToolBar;