Back to index

salome-gui  6.5.0
ViewerTools_CubeAxesDlgBase.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include "ViewerTools_CubeAxesDlgBase.h"
00024 
00025 #include "ViewerTools_FontWidgetBase.h"
00026 
00027 #include "QtxAction.h"
00028 #include "QtxIntSpinBox.h"
00029 
00030 #include <QHBoxLayout>
00031 #include <QVBoxLayout>
00032 #include <QPushButton>
00033 #include <QTabWidget>
00034 #include <QCheckBox>
00035 #include <QGroupBox>
00036 #include <QLineEdit>
00037 #include <QLabel>
00038 
00047 ViewerTools_AxisWidgetBase::ViewerTools_AxisWidgetBase (QWidget* theParent)
00048 : QFrame(theParent)
00049 {
00050 }
00051 
00055 ViewerTools_AxisWidgetBase::~ViewerTools_AxisWidgetBase()
00056 {
00057 }
00058 
00062 void ViewerTools_AxisWidgetBase::initialize()
00063 {
00064   QList< QLabel* > aLabels;
00065 
00066   // "Name" grp
00067 
00068   myNameGrp = new QGroupBox(ViewerTools_CubeAxesDlgBase::tr("AXIS_NAME"), this);
00069   myNameGrp->setCheckable( true );
00070 
00071   QVBoxLayout* aVBox = new QVBoxLayout;
00072   
00073   QHBoxLayout* aHBox = new QHBoxLayout;
00074   aHBox->setSpacing(5);
00075   QLabel* aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("NAME"));
00076   aHBox->addWidget(aLabel);
00077   myAxisName = new QLineEdit;
00078   aHBox->addWidget(myAxisName);
00079   aLabels.append(aLabel);
00080   aVBox->addLayout(aHBox);
00081 
00082   aHBox = new QHBoxLayout;
00083   aHBox->setSpacing(5);
00084   aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("FONT"));
00085   aHBox->addWidget(aLabel);
00086   myNameFont = createFontWidget(myNameGrp);
00087   aHBox->addWidget(myNameFont);
00088   aLabels.append(aLabel);
00089   aVBox->addLayout(aHBox);
00090 
00091   myNameGrp->setLayout(aVBox);
00092 
00093   // "Labels" grp
00094 
00095   myLabelsGrp = new QGroupBox(ViewerTools_CubeAxesDlgBase::tr("LABELS"), this);
00096   myLabelsGrp->setCheckable( true );
00097 
00098   aVBox = new QVBoxLayout;
00099 
00100   aHBox = new QHBoxLayout;
00101   aHBox->setSpacing(5);
00102   aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("NUMBER"));
00103   aHBox->addWidget(aLabel);
00104   myLabelNumber = new QtxIntSpinBox(2,25,1,myLabelsGrp);
00105   aHBox->addWidget(myLabelNumber);
00106   aLabels.append(aLabel);
00107   aVBox->addLayout(aHBox);
00108 
00109   aHBox = new QHBoxLayout;
00110   aHBox->setSpacing(5);
00111   aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("OFFSET"));
00112   aHBox->addWidget(aLabel);
00113   myLabelOffset = new QtxIntSpinBox(0,100,1,myLabelsGrp);
00114   aHBox->addWidget(myLabelOffset);
00115   aLabels.append(aLabel);
00116   aVBox->addLayout(aHBox);
00117 
00118   aHBox = new QHBoxLayout;
00119   aHBox->setSpacing(5);
00120   aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("FONT"));
00121   aHBox->addWidget(aLabel);
00122   myLabelsFont = createFontWidget(myLabelsGrp);
00123   aHBox->addWidget(myLabelsFont);
00124   aLabels.append(aLabel);
00125   aVBox->addLayout(aHBox);
00126 
00127   myLabelsGrp->setLayout(aVBox);
00128 
00129   // "Tick marks" grp
00130 
00131   myTicksGrp = new QGroupBox(ViewerTools_CubeAxesDlgBase::tr("TICK_MARKS"), this);
00132   myTicksGrp->setCheckable( true );
00133 
00134   aVBox = new QVBoxLayout;
00135 
00136   aHBox = new QHBoxLayout;
00137   aHBox->setSpacing(5);
00138   aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("LENGTH"));
00139   aHBox->addWidget(aLabel);
00140   myTickLength = new QtxIntSpinBox(0,100,1,myTicksGrp);
00141   aHBox->addWidget(myTickLength);
00142   aLabels.append(aLabel);
00143   aVBox->addLayout(aHBox);
00144 
00145   myTicksGrp->setLayout(aVBox);
00146 
00147   // Layout
00148 
00149   QVBoxLayout* aLay = new QVBoxLayout(this);
00150   aLay->setMargin(5);
00151   aLay->setSpacing(5);
00152   aLay->addWidget(myNameGrp);
00153   aLay->addWidget(myLabelsGrp);
00154   aLay->addWidget(myTicksGrp);
00155 
00156   // init
00157   myNameGrp->setChecked( true );
00158   myLabelsGrp->setChecked( true );
00159   myTicksGrp->setChecked( true );
00160 
00161   // Adjust label widths
00162   QList< QLabel* >::iterator anIter;
00163   int aMaxWidth = 0;
00164   for (anIter = aLabels.begin(); anIter != aLabels.end(); anIter++)
00165     aMaxWidth = qMax(aMaxWidth, (*anIter)->sizeHint().width());
00166   for (anIter = aLabels.begin(); anIter != aLabels.end(); anIter++)
00167     (*anIter)->setFixedWidth(aMaxWidth);
00168 }
00169 
00170 void ViewerTools_AxisWidgetBase::UseName(const bool toUse)
00171 {
00172   myNameGrp->setChecked(toUse);
00173 }
00174 
00175 void ViewerTools_AxisWidgetBase::SetName(const QString& theName)
00176 {
00177   myAxisName->setText(theName);
00178 }
00179 
00180 void ViewerTools_AxisWidgetBase::SetNameFont(const QColor& theColor,
00181                                              const int theFont,
00182                                              const bool theIsBold,
00183                                              const bool theIsItalic,
00184                                              const bool theIsShadow)
00185 {
00186   myNameFont->SetData(theColor, theFont, theIsBold, theIsItalic, theIsShadow);
00187 }
00188 
00189 /*
00190   Class       : ViewerTools_CubeAxesDlgBase
00191   Description : Dialog for specifying cube axes properties
00192 */
00193 
00197 ViewerTools_CubeAxesDlgBase::ViewerTools_CubeAxesDlgBase(QtxAction* theAction,
00198                                                          QWidget* theParent,
00199                                                          const char* theName):
00200   ViewerTools_DialogBase(theAction,
00201                          theParent,
00202                          theName)
00203 {
00204   setWindowTitle(tr("CAPTION"));
00205 }
00206 
00210 void ViewerTools_CubeAxesDlgBase::initialize()
00211 {
00212   QVBoxLayout* aLay = new QVBoxLayout(this);
00213   aLay->setMargin(5);
00214   aLay->setSpacing(5);
00215   aLay->addWidget(createMainFrame(this));
00216   aLay->addWidget(createButtonFrame(this));
00217 }
00218 
00222 QWidget* ViewerTools_CubeAxesDlgBase::createMainFrame(QWidget* theParent)
00223 {
00224   QFrame* aFrame = new QFrame(theParent);
00225 
00226   myTabWg = new QTabWidget(aFrame);
00227 
00228   myAxes[ 0 ] = createAxisWidget(myTabWg);
00229   myAxes[ 1 ] = createAxisWidget(myTabWg);
00230   myAxes[ 2 ] = createAxisWidget(myTabWg);
00231 
00232   myTabWg->addTab(myAxes[ 0 ], tr("X_AXIS"));
00233   myTabWg->addTab(myAxes[ 1 ], tr("Y_AXIS"));
00234   myTabWg->addTab(myAxes[ 2 ], tr("Z_AXIS"));
00235 
00236   myIsVisible = new QCheckBox(tr("IS_VISIBLE"), aFrame);
00237 
00238   QVBoxLayout* aLay = new QVBoxLayout(aFrame);
00239   aLay->setMargin(0);
00240   aLay->setSpacing(5);
00241   aLay->addWidget(myTabWg);
00242   aLay->addWidget(myIsVisible);
00243 
00244   return aFrame;
00245 }
00246 
00250 QWidget* ViewerTools_CubeAxesDlgBase::createButtonFrame(QWidget* theParent)
00251 {
00252   QFrame* aFrame = new QFrame(theParent);
00253   aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
00254 
00255   myOkBtn    = new QPushButton(tr("BUT_OK"), aFrame);
00256   myApplyBtn = new QPushButton(tr("BUT_APPLY"), aFrame);
00257   myCloseBtn = new QPushButton(tr("BUT_CLOSE"), aFrame);
00258 
00259   QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
00260 
00261   QHBoxLayout* aLay = new QHBoxLayout(aFrame);
00262   aLay->setMargin(5);
00263   aLay->setSpacing(5);
00264 
00265   aLay->addWidget(myOkBtn);
00266   aLay->addWidget(myApplyBtn);
00267   aLay->addItem(aSpacer);
00268   aLay->addWidget(myCloseBtn);
00269 
00270   connect(myOkBtn,    SIGNAL(clicked()), SLOT(onOk()));
00271   connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
00272   connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
00273 
00274   return aFrame;
00275 }
00276 
00280 ViewerTools_CubeAxesDlgBase::~ViewerTools_CubeAxesDlgBase()
00281 {
00282 }
00283 
00287 void ViewerTools_CubeAxesDlgBase::Update()
00288 {
00289 }
00290 
00294 bool ViewerTools_CubeAxesDlgBase::isValid() const
00295 {
00296   return true;
00297 }
00298 
00302 bool ViewerTools_CubeAxesDlgBase::onApply()
00303 {
00304   return true;
00305 }
00306 
00310 void ViewerTools_CubeAxesDlgBase::onOk()
00311 {
00312   if (onApply())
00313     onClose();
00314 }
00315 
00319 void ViewerTools_CubeAxesDlgBase::onClose()
00320 {
00321   reject();
00322 }