1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 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
24 // File : VisuGUI_ScalarBarDlg.cxx
25 // Author : Laurent CORNABE & Hubert ROLLAND
29 #include "VisuGUI_ScalarBarDlg.h"
32 #include "VisuGUI_Tools.h"
33 #include "VisuGUI_ViewTools.h"
34 #include "VisuGUI_InputPane.h"
36 #include "SVTK_ViewWindow.h"
37 #include "SVTK_FontWidget.h"
39 #include "VISUConfig.hh"
40 #include "VISU_Convertor.hxx"
42 #include "VISU_ScalarMapPL.hxx"
43 #include "VISU_ScalarMap_i.hh"
44 #include "VISU_ScalarMapAct.h"
46 #include "VISU_Result_i.hh"
47 #include "VISU_ColoredPrs3dFactory.hh"
49 #include "LightApp_Application.h"
51 #include "SUIT_Session.h"
52 #include "SUIT_MessageBox.h"
53 #include "SUIT_ResourceMgr.h"
57 #include <qvalidator.h>
58 #include <qcolordialog.h>
59 #include <qtabwidget.h>
60 #include <vtkTextProperty.h>
67 VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule)
68 : VisuGUI_ScalarBarBaseDlg(theModule)
70 setName("VisuGUI_ScalarBarDlg");
71 setCaption(tr("DLG_PROP_TITLE"));
72 setSizeGripEnabled(TRUE);
74 QVBoxLayout* TopLayout = new QVBoxLayout(this);
75 TopLayout->setSpacing(6);
76 TopLayout->setMargin(11);
78 myTabBox = new QTabWidget(this);
79 myInputPane = new VisuGUI_InputPane(VISU::TSCALARMAP, theModule, this);
80 myTabBox->addTab(GetScalarPane(), "Scalar Bar");
81 myTabBox->addTab(myInputPane, "Input");
83 TopLayout->addWidget(myTabBox);
85 // Common buttons ===========================================================
86 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
87 GroupButtons->setColumnLayout(0, Qt::Vertical );
88 GroupButtons->layout()->setSpacing( 0 );
89 GroupButtons->layout()->setMargin( 0 );
90 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
91 GroupButtonsLayout->setAlignment( Qt::AlignTop );
92 GroupButtonsLayout->setSpacing( 6 );
93 GroupButtonsLayout->setMargin( 11 );
95 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
96 buttonOk->setAutoDefault( TRUE );
97 buttonOk->setDefault( TRUE );
98 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
99 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
101 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
102 buttonCancel->setAutoDefault( TRUE );
103 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
105 QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
106 buttonHelp->setAutoDefault( TRUE );
107 GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
109 TopLayout->addWidget( GroupButtons );
111 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
112 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
113 connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
116 VisuGUI_ScalarBarDlg::~VisuGUI_ScalarBarDlg()
120 Called when <Help> button is clicked, shows the corresponding help page in defined browser
122 QString VisuGUI_ScalarBarDlg::GetContextHelpFilePath()
124 return "scalar_map_page.html";
128 Initialize dialog from the presentation
130 void VisuGUI_ScalarBarDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
134 myPrsCopy = VISU::TSameAsFactory<VISU::TSCALARMAP>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
136 VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit);
141 myInputPane->initFromPrsObject(myPrsCopy);
142 myTabBox->setCurrentPage( 0 );
146 Store dialog to the presentation
148 int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
150 if (!myInputPane->check() || !GetScalarPane()->check())
153 int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
154 anIsOk &= GetScalarPane()->storeToPrsObject( myPrsCopy );
156 VISU::TSameAsFactory<VISU::TSCALARMAP>().Copy(myPrsCopy, thePrs);