]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_ScalarBarDlg.cxx
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/visu.git] / src / VISUGUI / VisuGUI_ScalarBarDlg.cxx
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : VisuGUI_ScalarBarDlg.cxx
25 //  Author : Laurent CORNABE & Hubert ROLLAND
26 //  Module : VISU
27 //  $Header$
28
29 #include "VisuGUI_ScalarBarDlg.h"
30
31 #include "VisuGUI.h"
32 #include "VisuGUI_Tools.h"
33 #include "VisuGUI_ViewTools.h"
34 #include "VisuGUI_InputPane.h"
35
36 #include "SVTK_ViewWindow.h"
37 #include "SVTK_FontWidget.h"
38
39 #include "VISUConfig.hh"
40 #include "VISU_Convertor.hxx"
41
42 #include "VISU_ScalarMapPL.hxx"
43 #include "VISU_ScalarMap_i.hh"
44 #include "VISU_ScalarMapAct.h"
45
46 #include "VISU_Result_i.hh"
47 #include "VISU_ColoredPrs3dFactory.hh"
48
49 #include "LightApp_Application.h"
50
51 #include "SUIT_Session.h"
52 #include "SUIT_MessageBox.h"
53 #include "SUIT_ResourceMgr.h"
54
55 #include <limits.h>
56 #include <qlayout.h>
57 #include <qvalidator.h>
58 #include <qcolordialog.h>
59 #include <qtabwidget.h>
60 #include <vtkTextProperty.h>
61
62 using namespace std;
63
64 /*!
65   Constructor
66 */
67 VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule)
68   : VisuGUI_ScalarBarBaseDlg(theModule)
69 {
70   setName("VisuGUI_ScalarBarDlg");
71   setCaption(tr("DLG_PROP_TITLE"));
72   setSizeGripEnabled(TRUE);
73
74   QVBoxLayout* TopLayout = new QVBoxLayout(this);
75   TopLayout->setSpacing(6);
76   TopLayout->setMargin(11);
77
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");
82
83   TopLayout->addWidget(myTabBox);
84
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 );
94
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 );
100
101   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
102   buttonCancel->setAutoDefault( TRUE );
103   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
104
105   QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
106   buttonHelp->setAutoDefault( TRUE );
107   GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
108
109   TopLayout->addWidget( GroupButtons );
110
111   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
112   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
113   connect( buttonHelp,   SIGNAL( clicked() ), this, SLOT( onHelp() ) );
114 }
115
116 VisuGUI_ScalarBarDlg::~VisuGUI_ScalarBarDlg()
117 {}
118
119 /*!
120   Called when <Help> button is clicked, shows the corresponding help page in defined browser
121 */
122 QString VisuGUI_ScalarBarDlg::GetContextHelpFilePath()
123 {
124   return "scalar_map_page.html";
125 }
126
127 /*!
128   Initialize dialog from the presentation
129 */
130 void VisuGUI_ScalarBarDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
131                                               bool theInit )
132 {
133   if( theInit )
134     myPrsCopy = VISU::TSameAsFactory<VISU::TSCALARMAP>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
135
136   VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit);
137
138   if( !theInit )
139     return;
140
141   myInputPane->initFromPrsObject(myPrsCopy);
142   myTabBox->setCurrentPage( 0 );
143 }
144
145 /*!
146   Store dialog to the presentation
147 */
148 int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
149 {
150   if (!myInputPane->check() || !GetScalarPane()->check())
151     return 0;
152
153   int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
154   anIsOk &= GetScalarPane()->storeToPrsObject( myPrsCopy );
155
156   VISU::TSameAsFactory<VISU::TSCALARMAP>().Copy(myPrsCopy, thePrs);
157
158   return anIsOk;
159 }