From 0369b35ca7690d33fa3e553c7f7df44f39fc44c8 Mon Sep 17 00:00:00 2001 From: sln Date: Tue, 24 May 2005 11:34:36 +0000 Subject: [PATCH] PostPro 2005: T1.5: Graduated ruled. New dialog for editing properties of graduated axes (CubeAxes) added. --- src/VISUGUI/VISU_msg_en.po | 71 ++++ src/VISUGUI/VisuGUI.cxx | 11 +- src/VISUGUI/VisuGUI_CubeAxesDlg.cxx | 580 ++++++++++++++++++++++++++++ src/VISUGUI/VisuGUI_CubeAxesDlg.h | 162 ++++++++ src/VISUGUI/VisuGUI_FontWg.cxx | 158 ++++++++ src/VISUGUI/VisuGUI_FontWg.h | 96 +++++ 6 files changed, 1077 insertions(+), 1 deletion(-) create mode 100755 src/VISUGUI/VisuGUI_CubeAxesDlg.cxx create mode 100755 src/VISUGUI/VisuGUI_CubeAxesDlg.h create mode 100755 src/VISUGUI/VisuGUI_FontWg.cxx create mode 100755 src/VISUGUI/VisuGUI_FontWg.h diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index f8f3edb4..0cc34b82 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -407,3 +407,74 @@ msgstr "Translate Presentation" msgid "BTN_RESET" msgstr "Reset" + +# -------------------------------------- + +msgid "VisuGUI_CubeAxesDlg::CAPTION" +msgstr "Graduated axes" + +msgid "VisuGUI_AxisWg::AXIS_NAME" +msgstr "Axis name" + +msgid "VisuGUI_AxisWg::IS_VISIBLE" +msgstr "Is visible" + +msgid "VisuGUI_CubeAxesDlg::X_AXIS" +msgstr "X axis" + +msgid "VisuGUI_CubeAxesDlg::Y_AXIS" +msgstr "Y axis" + +msgid "VisuGUI_CubeAxesDlg::Z_AXIS" +msgstr "Z axis" + +msgid "VisuGUI_AxisWg::NAME" +msgstr "Name" + +msgid "VisuGUI_AxisWg::FONT" +msgstr "Font" + +msgid "VisuGUI_AxisWg::LABELS" +msgstr "Labels" + +msgid "VisuGUI_AxisWg::NUMBER" +msgstr "Number" + +msgid "VisuGUI_AxisWg::OFFSET" +msgstr "Offset" + +msgid "VisuGUI_AxisWg::TICK_MARKS" +msgstr "Tick marks" + +msgid "VisuGUI_AxisWg::LENGTH" +msgstr "Length" + +# -------------------------------------- + +msgid "VisuGUI_FontWg::ARIAL" +msgstr "Arial" + +msgid "VisuGUI_FontWg::COURIER" +msgstr "Courier" + +msgid "VisuGUI_FontWg::TIMES" +msgstr "Times" + +msgid "VisuGUI_FontWg::BOLD" +msgstr "Bold" + +msgid "VisuGUI_FontWg::ITALIC" +msgstr "Italic" + +msgid "VisuGUI_FontWg::SHADOW" +msgstr "Shadow" + +msgid "VisuGUI_CubeAxesDlg::IS_VISIBLE" +msgstr "Is visible" + + + + + + + diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 94d639fc..61922f31 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -63,6 +63,7 @@ #include "VisuGUI_TimeAnimation.h" #include "VisuGUI_ClippingDlg.h" #include "VisuGUI_Plot3DDlg.h" +#include "VisuGUI_CubeAxesDlg.h" #include "VisuGUI_Selection.h" #include "VisuGUI_NonIsometricDlg.h" @@ -569,6 +570,14 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) break; } + case 431 : + { + //Show dialog that allows to select scale function and corresponding scale factor + VisuGUI_CubeAxesDlg* aDlg = new VisuGUI_CubeAxesDlg( QAD_Application::getDesktop() ); + aDlg->show(); + break; + } + /* ============================ */ /* POP-UP OBJECTS BROWSER */ /* ============================ */ @@ -587,7 +596,7 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) case 803 : // Display only case 903 : // Display only visuGUI->DisplayOnlyPrs(); - break; + break; aDlg case 901 : // Display visuGUI->DisplayPrs(); diff --git a/src/VISUGUI/VisuGUI_CubeAxesDlg.cxx b/src/VISUGUI/VisuGUI_CubeAxesDlg.cxx new file mode 100755 index 00000000..e2f78432 --- /dev/null +++ b/src/VISUGUI/VisuGUI_CubeAxesDlg.cxx @@ -0,0 +1,580 @@ +// 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 : VisuGUI_CubeAxesDlg.cxx +// Author : Sergey LITONIN +// Module : VISU + +#include "VisuGUI_CubeAxesDlg.h" +#include "VisuGUI_FontWg.h" +#include "VisuGUI.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +/* + Class : AxisWg + Description : Tab of dialog +*/ + +//======================================================================= +// name : VisuGUI_AxisWg::AxisWg +// Purpose : Constructor +//======================================================================= +VisuGUI_AxisWg::VisuGUI_AxisWg( 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 VisuGUI_FontWg( 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 ); + 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 VisuGUI_FontWg( 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() ) ); +} + +VisuGUI_AxisWg::~VisuGUI_AxisWg() +{ +} + +void VisuGUI_AxisWg::updateControlState() +{ + onNameChecked(); + onLabelsChecked(); + onTicksChecked(); +} + +//======================================================================= +// name : VisuGUI_AxisWg::onNameChecked +// Purpose : +//======================================================================= +void VisuGUI_AxisWg::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 : VisuGUI_AxisWg::onLabelsChecked +// Purpose : +//======================================================================= +void VisuGUI_AxisWg::onLabelsChecked() +{ + setEnabled( myLabelsGrp, myIsLabelsVisible->isChecked() ); +} + +//======================================================================= +// Labels : VisuGUI_AxisWg::onTicksChecked +// Purpose : +//======================================================================= +void VisuGUI_AxisWg::onTicksChecked() +{ + setEnabled( myTicksGrp, myIsTicksVisible->isChecked() ); +} + +//======================================================================= +// name : VisuGUI_AxisWg::onNameChecked +// Purpose : +//======================================================================= +void VisuGUI_AxisWg::onNameChecked() +{ + setEnabled( myNameGrp, myIsNameVisible->isChecked() ); +} + +//======================================================================= +// name : VisuGUI_AxisWg::UseName +// Purpose : +//======================================================================= +void VisuGUI_AxisWg::UseName( const bool toUse ) +{ + myIsNameVisible->setChecked( toUse ); +} + +//======================================================================= +// name : VisuGUI_AxisWg::SetName +// Purpose : +//================================================== ===================== +void VisuGUI_AxisWg::SetName( const QString& theName ) +{ + myAxisName->setText( theName ); +} + +//======================================================================= +// name : VisuGUI_AxisWg::SetNameFont +// Purpose : +//======================================================================= +void VisuGUI_AxisWg::SetNameFont( const QColor& theColor, + const int theFont, + const bool theIsBold, + const bool theIsItalic, + const bool theIsShadow ) +{ + myNameFont->SetData( theColor, theFont, theIsBold, theIsItalic, theIsShadow ); +} + +//======================================================================= +// name : VisuGUI_AxisWg::SetNameFont +// Purpose : +//======================================================================= +bool VisuGUI_AxisWg::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[ 0 ] * 255 ), (int)( c[ 0 ] * 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 : VisuGUI_CubeAxesDlg::Apply +// Purpose : +//======================================================================= +bool VisuGUI_AxisWg::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 ); + + theActor->SetLabelTextProperty( aLabelsProp ); + } + + + // Tick marks + theActor->SetTickVisibility( myIsTicksVisible->isChecked() ); + int aTickLength = myTickLength->text().toInt( &isOk ); + if ( isOk ) + theActor->SetTickLength( aTickLength ); + + return true; +} + +/* + Class : VisuGUI_CubeAxesDlg + Description : Dialog for specifynig cube axes properties +*/ + +//======================================================================= +// name : VisuGUI_CubeAxesDlg::VisuGUI_CubeAxesDlg +// Purpose : Constructor +//======================================================================= +VisuGUI_CubeAxesDlg::VisuGUI_CubeAxesDlg( QWidget* theParent ) +: QDialog( theParent, "VisuGUI_CubeAxesDlg", false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +{ + setCaption( tr( "CAPTION" ) ); + + QVBoxLayout* aLay = new QVBoxLayout( this, 5, 5 ); + aLay->addWidget( createMainFrame( this ) ); + aLay->addWidget( createButtonFrame( this ) ); + + Init(); + + if ( VisuGUI::GetDesktop()->getMainFrame() ) + connect( VisuGUI::GetDesktop()->getMainFrame(), SIGNAL( windowActivated( QWidget* ) ), + SLOT( onWindowActivated( QWidget* ) ) ); +} + +//======================================================================= +// name : VisuGUI_CubeAxesDlg::createMainFrame +// Purpose : Create frame containing dialog's input fields +//======================================================================= +QWidget* VisuGUI_CubeAxesDlg::createMainFrame( QWidget* theParent ) +{ + QFrame* aFrame = new QFrame( theParent ); + + myTabWg = new QTabWidget( aFrame ); + + myAxes[ 0 ] = new VisuGUI_AxisWg( myTabWg ); + myAxes[ 1 ] = new VisuGUI_AxisWg( myTabWg ); + myAxes[ 2 ] = new VisuGUI_AxisWg( 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 : VisuGUI_CubeAxesDlg::createButtonFrame +// Purpose : Create frame containing buttons +//======================================================================= +QWidget* VisuGUI_CubeAxesDlg::createButtonFrame( QWidget* theParent ) +{ + QFrame* aFrame = new QFrame( theParent ); + aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + + myOkBtn = new QPushButton( tr( "VISU_BUT_OK" ), aFrame ); + myApplyBtn = new QPushButton( tr( "VISU_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 : VisuGUI_CubeAxesDlg::~VisuGUI_CubeAxesDlg +// Purpose : Destructor +//======================================================================= +VisuGUI_CubeAxesDlg::~VisuGUI_CubeAxesDlg() +{ +} + +//======================================================================= +// name : VisuGUI_CubeAxesDlg::Init +// Purpose : Init dialog fields, connect signals and slots, show dialog +//======================================================================= +bool VisuGUI_CubeAxesDlg::Init() +{ + VTKViewer_ViewFrame* aFrame = VisuGUI::GetVtkViewFrame(); + if ( aFrame == 0 || !aFrame->isCubeAxesDisplayed() ) + return false; + + SALOME_CubeAxesActor2D* anActor = aFrame->GetCubeAxes(); + if ( anActor == 0 ) + return false; + + myAxes[ 0 ]->ReadData( anActor->GetXAxisActor2D() ); + myAxes[ 1 ]->ReadData( anActor->GetYAxisActor2D() ); + myAxes[ 2 ]->ReadData( anActor->GetZAxisActor2D() ); + + myIsVisible->setChecked( anActor->GetVisibility() ? true : false ); + + return true; + +} + +//======================================================================= +// name : VisuGUI_CubeAxesDlg::isValid +// Purpose : Verify validity of entry data +//======================================================================= +bool VisuGUI_CubeAxesDlg::isValid() const +{ + return true; +} + +//======================================================================= +// name : VisuGUI_CubeAxesDlg::onApply +// Purpose : Verify validity of entry data +//======================================================================= +bool VisuGUI_CubeAxesDlg::onApply() +{ + bool isOk = true; + + try + { + VTKViewer_ViewFrame* aFrame = VisuGUI::GetVtkViewFrame(); + if ( aFrame == 0 ) + return false; + + SALOME_CubeAxesActor2D* anActor = aFrame->GetCubeAxes(); + if ( anActor == 0 ) + return false; + + isOk = isOk && myAxes[ 0 ]->Apply( anActor->GetXAxisActor2D() ); + isOk = isOk && myAxes[ 1 ]->Apply( anActor->GetYAxisActor2D() ); + isOk = isOk && myAxes[ 2 ]->Apply( anActor->GetZAxisActor2D() ); + + //anActor->SetXLabel( myAxes[ 0 ]->myAxisName->text() ); + //anActor->SetYLabel( myAxes[ 1 ]->myAxisName->text() ); + //anActor->SetZLabel( myAxes[ 2 ]->myAxisName->text() ); + + //anActor->SetNumberOfLabels( anActor->GetXAxisActor2D()->GetNumberOfLabels() ); + if ( myIsVisible->isChecked() ) + anActor->VisibilityOn(); + else + anActor->VisibilityOff(); + + if ( isOk ) + aFrame->Repaint(); + } + catch( ... ) + { + isOk = false; + } + + return isOk; +} + + + +//======================================================================= +// name : VisuGUI_CubeAxesDlg::onOk +// Purpose : SLOT called when "Ok" button pressed. +//======================================================================= +void VisuGUI_CubeAxesDlg::onOk() +{ + if ( onApply() ) + onClose(); +} + +//======================================================================= +// name : VisuGUI_CubeAxesDlg::onClose +// Purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void VisuGUI_CubeAxesDlg::onClose() +{ + reject(); +} + +//======================================================================= +// name : VisuGUI_CubeAxesDlg::onClose +// Purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void VisuGUI_CubeAxesDlg::onWindowActivated( QWidget* ) +{ + VTKViewer_ViewFrame* aFrame = VisuGUI::GetVtkViewFrame(); + if ( aFrame != 0 ) + Init(); + else + onClose(); +} + diff --git a/src/VISUGUI/VisuGUI_CubeAxesDlg.h b/src/VISUGUI/VisuGUI_CubeAxesDlg.h new file mode 100755 index 00000000..73e9ec6a --- /dev/null +++ b/src/VISUGUI/VisuGUI_CubeAxesDlg.h @@ -0,0 +1,162 @@ +// 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 : VisuGUI_CubeAxesDlg.h +// Author : Sergey LITONIN +// Module : VISU + + +#ifndef VisuGUI_CubeAxesDlg_H +#define VisuGUI_CubeAxesDlg_H + +#include +#include + +class QWidget; +class QFrame; +class QPushButton; +class QTabWidget; +class QCheckBox; +class QLineEdit; +class VisuGUI_FontWg; +class QGroupBox; +class VisuGUI_AxisWg; +class vtkAxisActor2D; + +/* + Class : VisuGUI_CubeAxesDlg + Description : Dialog for specifynig cube axes properties +*/ + +class VisuGUI_CubeAxesDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_CubeAxesDlg( QWidget* ); + virtual ~VisuGUI_CubeAxesDlg(); + + bool Init(); + + +private slots: + + void onOk(); + bool onApply(); + void onClose(); + + void onWindowActivated( QWidget* ); + +private: + + QWidget* createButtonFrame( QWidget* ); + QWidget* createMainFrame ( QWidget* ); + bool isValid() const; + +private: + + QTabWidget* myTabWg; + QCheckBox* myIsVisible; + + QPushButton* myOkBtn; + QPushButton* myApplyBtn; + QPushButton* myCloseBtn; + VisuGUI_AxisWg* myAxes[ 3 ]; + +}; + +/* + Class : VisuGUI_AxisWg + Description : Tab of dialog +*/ + +class VisuGUI_AxisWg : public QFrame +{ + Q_OBJECT + +public: + + VisuGUI_AxisWg( QWidget* ); + ~VisuGUI_AxisWg(); + + 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 slots: + + void onNameChecked(); + void onLabelsChecked(); + void onTicksChecked(); + +private: + + void updateControlState(); + void setEnabled( QGroupBox*, const bool ); + +private: + + // name + QGroupBox* myNameGrp; + QCheckBox* myIsNameVisible; + QLineEdit* myAxisName; + VisuGUI_FontWg* myNameFont; + + // labels + QGroupBox* myLabelsGrp; + QCheckBox* myIsLabelsVisible; + QLineEdit* myLabelNumber; + QLineEdit* myLabelOffset; + VisuGUI_FontWg* myLabelsFont; + + // tick marks + QGroupBox* myTicksGrp; + QCheckBox* myIsTicksVisible; + QLineEdit* myTickLength; + + friend class VisuGUI_CubeAxesDlg; +}; + +#endif + + + + + + + + + + + + + + + + + diff --git a/src/VISUGUI/VisuGUI_FontWg.cxx b/src/VISUGUI/VisuGUI_FontWg.cxx new file mode 100755 index 00000000..a37a7e4f --- /dev/null +++ b/src/VISUGUI/VisuGUI_FontWg.cxx @@ -0,0 +1,158 @@ +// 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 : VisuGUI_CubeAxesDlg.cxx +// Author : Sergey LITONIN +// Module : VISU + +#include "VisuGUI_FontWg.h" + +#include +#include +#include +#include + +#include + +/* + Class : VisuGUI_FontWg + Description : Dialog for specifynig font +*/ + +//======================================================================= +// name : VisuGUI_FontWg +// Purpose : Constructor +//======================================================================= +VisuGUI_FontWg::VisuGUI_FontWg( QWidget* theParent ) +: QHBox( theParent ) +{ + setSpacing( 5 ); + myColorBtn = new QToolButton( this ); + + 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() ) ); + +} +VisuGUI_FontWg::~VisuGUI_FontWg() +{ +} + +//======================================================================= +// name : SetColor +// Purpose : +//======================================================================= +void VisuGUI_FontWg::SetColor( const QColor& theColor ) +{ + myColorBtn->setPaletteBackgroundColor( theColor ); +} + +//======================================================================= +// name : GetColor +// Purpose : +//======================================================================= +QColor VisuGUI_FontWg::GetColor() const +{ + return myColorBtn->paletteBackgroundColor(); +} + +//======================================================================= +// name : onColor +// Purpose : +//======================================================================= +void VisuGUI_FontWg::onColor() +{ + QColor aColor = QColorDialog::getColor( GetColor(), this ); + if ( aColor.isValid() ) + SetColor( aColor ); +} + +//======================================================================= +// name : SetData +// Purpose : +//======================================================================= +void VisuGUI_FontWg::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 VisuGUI_FontWg::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/VISUGUI/VisuGUI_FontWg.h b/src/VISUGUI/VisuGUI_FontWg.h new file mode 100755 index 00000000..b6f91d8d --- /dev/null +++ b/src/VISUGUI/VisuGUI_FontWg.h @@ -0,0 +1,96 @@ +// 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 : VisuGUI_FontWg.h +// Author : Sergey LITONIN +// Module : VISU + + +#ifndef VisuGUI_FontWg_H +#define VisuGUI_FontWg_H + +#include + +class QToolButton; +class QComboBox; +class QCheckBox; +class QColor; + + +/* + Class : VisuGUI_FontWg + Description : Dialog for specifynig font +*/ + +class VisuGUI_FontWg : public QHBox +{ + Q_OBJECT + +public: + VisuGUI_FontWg( QWidget* ); + virtual ~VisuGUI_FontWg(); + + 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 + + + + + + + + + + + + + + + + + -- 2.39.2