1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU VISUGUI : GUI of VISU component
23 // File : VisuGUI_ScalarBarDlg.cxx
24 // Author : Laurent CORNABE & Hubert ROLLAND
28 #include "VisuGUI_ScalarBarDlg.h"
31 #include "VisuGUI_Tools.h"
32 #include "VisuGUI_ViewTools.h"
33 #include "VisuGUI_InputPane.h"
35 #include "SVTK_ViewWindow.h"
36 #include "SVTK_FontWidget.h"
38 #include "VISUConfig.hh"
39 #include "VISU_Convertor.hxx"
41 #include "VISU_ScalarMapPL.hxx"
42 #include "VISU_ScalarMap_i.hh"
43 #include "VISU_ScalarMapAct.h"
45 #include "VISU_Result_i.hh"
46 #include "VISU_ColoredPrs3dFactory.hh"
48 #include "LightApp_Application.h"
50 #include "SUIT_Session.h"
51 #include "SUIT_MessageBox.h"
52 #include "SUIT_ResourceMgr.h"
58 #include <QColorDialog>
60 #include <QPushButton>
61 #include <QGridLayout>
64 #include <vtkTextProperty.h>
71 VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule)
72 : VisuGUI_ScalarBarBaseDlg(theModule)
74 setWindowTitle(tr("DLG_PROP_TITLE"));
75 setSizeGripEnabled(TRUE);
77 QVBoxLayout* TopLayout = new QVBoxLayout(this);
78 TopLayout->setSpacing(6);
79 TopLayout->setMargin(11);
81 myTabBox = new QTabWidget(this);
82 myInputPane = new VisuGUI_InputPane(VISU::TSCALARMAP, theModule, this);
83 myTabBox->addTab(GetScalarPane(), "Scalar Bar");
84 myTabBox->addTab(myInputPane, "Input");
86 TopLayout->addWidget(myTabBox);
88 // Common buttons ===========================================================
89 QGroupBox* GroupButtons = new QGroupBox( this );
90 //GroupButtons->setColumnLayout(0, Qt::Vertical );
91 //GroupButtons->layout()->setSpacing( 0 );
92 //GroupButtons->layout()->setMargin( 0 );
93 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons );
94 GroupButtonsLayout->setAlignment( Qt::AlignTop );
95 GroupButtonsLayout->setSpacing( 6 );
96 GroupButtonsLayout->setMargin( 11 );
98 QPushButton* buttonOk = new QPushButton( tr("BUT_OK"), GroupButtons );
99 buttonOk->setAutoDefault( TRUE );
100 buttonOk->setDefault( TRUE );
101 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
102 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
104 QPushButton* buttonCancel = new QPushButton( tr("BUT_CANCEL") , GroupButtons );
105 buttonCancel->setAutoDefault( TRUE );
106 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
108 QPushButton* buttonHelp = new QPushButton( tr("BUT_HELP") , GroupButtons );
109 buttonHelp->setAutoDefault( TRUE );
110 GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
112 TopLayout->addWidget( GroupButtons );
114 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
115 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
116 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
119 VisuGUI_ScalarBarDlg::~VisuGUI_ScalarBarDlg()
123 Called when <Help> button is clicked, shows the corresponding help page in defined browser
125 QString VisuGUI_ScalarBarDlg::GetContextHelpFilePath()
127 return "scalar_map_page.html";
131 Initialize dialog from the presentation
133 void VisuGUI_ScalarBarDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
137 myPrsCopy = VISU::TSameAsFactory<VISU::TSCALARMAP>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
139 VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit);
144 myInputPane->initFromPrsObject( myPrsCopy );
145 myTabBox->setCurrentIndex( 0 );
149 Store dialog to the presentation
151 int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
153 if (!myInputPane->check() || !GetScalarPane()->check())
156 int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
157 anIsOk &= GetScalarPane()->storeToPrsObject( myPrsCopy );
159 VISU::TSameAsFactory<VISU::TSCALARMAP>().Copy(myPrsCopy, thePrs);