1 // Copyright (C) 2007-2012 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
23 // File : VisuGUI_SetupPlot2dDlg.cxx
24 // Author : Vadim SANDLER
28 #include "VisuGUI_SetupPlot2dDlg.h"
30 #include "SPlot2d_Curve.h"
32 #include "SUIT_Tools.h"
33 #include "SUIT_MessageBox.h"
34 #include "SUIT_ResourceMgr.h"
35 #include "SUIT_Session.h"
37 #include "LightApp_Application.h"
39 #include <SalomeApp_IntSpinBox.h>
41 #include <QtxColorButton.h>
43 #include <SALOMEDSClient_AttributeTableOfInteger.hxx>
44 #include <SALOMEDSClient_AttributeTableOfReal.hxx>
47 #include <QPushButton>
49 #include <QToolButton>
51 #include <QScrollArea>
53 #include <QColorDialog>
60 #include "utilities.h"
62 #define DLG_SIZE_WIDTH 500
63 #define DLG_SIZE_HEIGHT 400
64 #define MAX_LINE_WIDTH 100
65 #define MARGIN_SIZE 11
66 #define SPACING_SIZE 6
71 VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, VISU::Table_i* table , QWidget* parent )
72 : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
76 setWindowTitle( tr("TLT_SETUP_PLOT2D") );
77 setSizeGripEnabled( TRUE );
78 QGridLayout* topLayout = new QGridLayout( this );
79 topLayout->setSpacing( SPACING_SIZE );
80 topLayout->setMargin( MARGIN_SIZE );
82 //myItems.setAutoDelete( false );
87 myView = new QScrollArea( this );
88 QFrame* frame = new QFrame( myView );
89 frame->setFrameStyle( QFrame::Plain | QFrame::NoFrame );
90 QGridLayout* frameLayout = new QGridLayout( frame );
91 frameLayout->setMargin( MARGIN_SIZE ); frameLayout->setSpacing( SPACING_SIZE );
95 QLabel* labAxis = new QLabel( tr( "AXIS_LBL" ), frame );
96 QLabel* labAssigned = new QLabel( tr( "ASSIGNED" ), frame );
97 QLabel* labData = new QLabel( tr( "DATA_LBL" ), frame );
98 QLabel* labUnit = new QLabel( tr( "UNITS_LBL" ), frame );
99 QLabel* labDvtn = new QLabel( tr( "DVTN_LBL" ), frame );
100 QLabel* labAttr = new QLabel( tr( "ATTRIBUTES_LBL" ), frame );
101 labAxis->setAlignment( Qt::AlignCenter );
102 labAssigned->setAlignment( Qt::AlignCenter );
103 labData->setAlignment( Qt::AlignCenter );
104 labUnit->setAlignment( Qt::AlignCenter );
105 labDvtn->setAlignment( Qt::AlignCenter );
106 labAttr->setAlignment( Qt::AlignCenter );
107 QFont font = labAxis->font(); font.setBold( true );
108 labAxis->setFont( font );
109 labAssigned->setFont( font );
110 labData->setFont( font );
111 labUnit->setFont( font );
112 labDvtn->setFont( font );
113 labAttr->setFont( font );
115 frameLayout->addWidget( labAxis, 0, 0, 1, 3 );
116 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
117 frameLayout->addWidget( lin, 0, 3 );
119 frameLayout->addWidget( labAssigned, 0, 4 );
120 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
121 frameLayout->addWidget( lin, 0, 5 );
123 frameLayout->addWidget( labData, 0, 6 );
124 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
125 frameLayout->addWidget( lin, 0, 7 );
127 frameLayout->addWidget( labUnit, 0, 8 );
128 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
129 frameLayout->addWidget( lin, 0, 9 );
131 frameLayout->addWidget( labDvtn, 0, 10 );
132 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
133 frameLayout->addWidget( lin, 0, 11 );
135 frameLayout->addWidget( labAttr, 0, 12, 1, 5 );
136 //frameLayout->setColStretch( 15, 5 );
137 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::HLine | QFrame::Sunken );
138 frameLayout->addWidget( lin, 1, 0, 1, 17 );
141 _PTR(GenericAttribute) anAttr;
142 _PTR(AttributeTableOfInteger) tblIntAttr;
143 _PTR(AttributeTableOfReal) tblRealAttr;
145 /* Try table of integer */
146 if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) {
150 int nbRows = tblIntAttr->GetNbRows() ;
151 std::vector<std::string> rowTitles = tblIntAttr->GetRowTitles();
152 std::vector<std::string> rowUnits = tblIntAttr->GetRowUnits();
154 for ( int i = 0; i < nbRows; i++ ) {
155 if(myTable && myTable->isDeviationRow(i)) continue;
156 rows.append( rowTitles[i].c_str() );
160 for ( int i = 0; i < nbRows; i++ ) {
161 if(myTable && myTable->isDeviationRow(i)) continue;
162 VisuGUI_ItemContainer* item = new VisuGUI_ItemContainer( this );
163 item->createWidgets( frame, rows );
164 frameLayout->addWidget( item->myHBtn, row, 0 );
165 frameLayout->addWidget( item->myVBtn, row, 1 );
166 frameLayout->addWidget( item->myV2Btn, row, 2 );
167 frameLayout->addWidget( item->myAssigned, row, 4 );
169 frameLayout->addWidget( item->myTitleLab, row, 6 );
170 if ( rowTitles.size() > 0 )
171 item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) );
172 frameLayout->addWidget( item->myUnitLab, row, 8 );
173 if ( rowUnits.size() > 0 )
174 item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) );
176 frameLayout->addWidget( item->myDvtnLab, row, 10 );
177 if(myTable && myTable->hasDeviationData(i)) {
178 QString lbl = VISU::Table_i::deviationLabel(myTable->getDeviationInfo(i));
180 item->myDvtnLab->setText(lbl);
183 frameLayout->addWidget( item->myAutoCheck, row, 12 );
184 frameLayout->addWidget( item->myLineCombo, row, 13 );
185 frameLayout->addWidget( item->myLineSpin, row, 14 );
186 frameLayout->addWidget( item->myMarkerCombo, row, 15 );
187 frameLayout->addWidget( item->myColorBtn, row, 16 );
188 connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
189 connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
190 connect( item, SIGNAL( ver2Toggled( bool ) ), this, SLOT( onV2BtnToggled( bool ) ) );
191 myItems.append( item );
192 myIdxMap[nbItems] = i;
198 MESSAGE("VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg : Exception has been caught (int)!!!");
202 /* Try table of real */
203 else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
204 tblRealAttr = anAttr;
207 int nbRows = tblRealAttr->GetNbRows() ;
208 std::vector<std::string> rowTitles = tblRealAttr->GetRowTitles();
209 std::vector<std::string> rowUnits = tblRealAttr->GetRowUnits();
211 for ( int i = 0; i < nbRows; i++ ) {
212 if(myTable && myTable->isDeviationRow(i)) continue;
213 rows.append( rowTitles[i].c_str() );
216 for ( int i = 0; i < nbRows; i++ ) {
217 if(myTable && myTable->isDeviationRow(i)) continue;
218 VisuGUI_ItemContainer* item = new VisuGUI_ItemContainer( this );
219 item->createWidgets( frame, rows );
220 frameLayout->addWidget( item->myHBtn, row, 0 );
221 frameLayout->addWidget( item->myVBtn, row, 1 );
222 frameLayout->addWidget( item->myV2Btn, row, 2 );
223 frameLayout->addWidget( item->myAssigned, row, 4 );
225 frameLayout->addWidget( item->myTitleLab, row, 6 );
226 if ( rowTitles.size() > 0 )
227 item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) );
228 frameLayout->addWidget( item->myUnitLab, row, 8 );
229 if ( rowUnits.size() > 0 )
230 item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) );
232 frameLayout->addWidget( item->myDvtnLab, row, 10 );
234 frameLayout->addWidget( item->myDvtnLab, row, 10 );
235 if(myTable && myTable->hasDeviationData(i)) {
236 QString lbl = VISU::Table_i::deviationLabel(myTable->getDeviationInfo(i));
238 item->myDvtnLab->setText(lbl);
241 frameLayout->addWidget( item->myAutoCheck, row, 12 );
242 frameLayout->addWidget( item->myLineCombo, row, 13 );
243 frameLayout->addWidget( item->myLineSpin, row, 14 );
244 frameLayout->addWidget( item->myMarkerCombo, row, 15 );
245 frameLayout->addWidget( item->myColorBtn, row, 16 );
246 connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
247 connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
248 connect( item, SIGNAL( ver2Toggled( bool ) ), this, SLOT( onV2BtnToggled( bool ) ) );
249 myItems.append( item );
250 myIdxMap[nbItems] = i;
256 MESSAGE("VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg : Exception has been caught (real)!!!");
260 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
261 frameLayout->addWidget( lin, 2, 3, row, 1 );
262 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
263 frameLayout->addWidget( lin, 2, 5, row, 1 );
264 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
265 frameLayout->addWidget( lin, 2, 7, row, 1 );
266 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
267 frameLayout->addWidget( lin, 2, 9, row, 1 );
268 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
269 frameLayout->addWidget( lin, 2, 11, row, 1 );
271 //frameLayout->setRowStretch( row+1, 5 );
273 myView->setWidget( frame );
274 myView->setAlignment( Qt::AlignCenter );
275 myView->setWidgetResizable( true );
277 myView->setMinimumWidth( frame->sizeHint().width() + MARGIN_SIZE * 2 );
279 /* OK/Cancel/Help buttons */
280 myOkBtn = new QPushButton( tr( "BUT_OK" ), this );
281 myOkBtn->setAutoDefault( TRUE );
282 myOkBtn->setDefault( TRUE );
283 myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this );
284 myCancelBtn->setAutoDefault( TRUE );
285 myHelpBtn = new QPushButton( tr( "BUT_HELP" ), this );
286 myHelpBtn->setAutoDefault( TRUE );
288 topLayout->addWidget( myView, 0, 0, 1, 4 );
289 topLayout->addWidget( myOkBtn, 1, 0 );
290 //topLayout->setColStretch( 1, 5 );
291 topLayout->addWidget( myCancelBtn, 1, 2 );
292 topLayout->addWidget( myHelpBtn, 1, 3 );
294 connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
295 connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
296 connect( myHelpBtn, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
300 /* Center widget inside it's parent widget */
301 resize( DLG_SIZE_WIDTH, DLG_SIZE_HEIGHT );
302 SUIT_Tools::centerWidget( this, parentWidget() );
307 VisuGUI_SetupPlot2dDlg::~VisuGUI_SetupPlot2dDlg()
311 Gets curves info ( indexes of row data in the table for horizontal and verical axes )
313 void VisuGUI_SetupPlot2dDlg::getCurvesSource( int& horIndex, QList<int>& verIndexes,
314 QList<int>& ver2Indexes, QList<int>& zIndices )
316 /* collecting horizontal and vertical axis items */
319 for ( i = 0; i < myItems.count(); i++ ) {
320 if ( myItems.at( i )->isHorizontalOn() ) {
324 if ( myItems.at( i )->isVerticalOn() ) {
325 verIndexes.append( i );
327 else if ( myItems.at( i )->isVertical2On() ) {
328 ver2Indexes.append( i );
330 zIndices.append( idx(myItems.at( i )->assigned()) );
335 Gets curve attributes
337 bool VisuGUI_SetupPlot2dDlg::getCurveAttributes( const int vIndex,
344 if ( vIndex >= 0 && vIndex < myItems.count() ) {
345 isAuto = myItems.at( vIndex )->isAutoAssign();
346 marker = myItems.at( vIndex )->getMarker();
347 line = myItems.at( vIndex )->getLine();
348 lineWidth = myItems.at( vIndex )->getLineWidth();
349 color = myItems.at( vIndex )->getColor();
355 Creates and returns curves presentations
357 void VisuGUI_SetupPlot2dDlg::getCurves( QList<Plot2d_Curve*>& container )
359 _PTR(GenericAttribute) anAttr;
360 _PTR(AttributeTableOfInteger) tblIntAttr;
361 _PTR(AttributeTableOfReal) tblRealAttr;
363 /* clearing container contents */
366 /* collecting horizontal and vertical axis items */
369 QList<int> verIndex, ver2Index, zIndices;
370 getCurvesSource( horIndex, verIndex, ver2Index, zIndices );
371 if ( horIndex < 0 || verIndex.isEmpty() && ver2Index.isEmpty() ) /* no curves can be created */
374 /* Try table of integer */
375 if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) {
379 int nbCols = tblIntAttr->GetNbColumns() ;
380 std::vector<std::string> rowTitles = tblIntAttr->GetRowTitles();
381 std::vector<std::string> rowUnits = tblIntAttr->GetRowUnits();
383 for ( i = 0; i < verIndex.count(); i++ ) {
384 SPlot2d_Curve* curve = new SPlot2d_Curve();
386 if ( rowTitles.size() > 0 ) {
387 curve->setHorTitle( QString( rowTitles[ idx(horIndex) ].c_str() ) );
388 curve->setVerTitle( QString( rowTitles[ idx(verIndex[i]) ].c_str() ) );
391 if ( rowUnits.size() > 0 ) {
392 curve->setHorUnits( QString( rowUnits[ idx(horIndex) ].c_str() ) );
393 curve->setVerUnits( QString( rowUnits[ idx(verIndex[i]) ].c_str() ) );
397 for ( j = 1; j <= nbCols; j++ ) {
398 if ( tblIntAttr->HasValue( idx(horIndex) + 1, j ) && tblIntAttr->HasValue( idx(verIndex[i])+1, j ) )
401 if ( nbPoints > 0 ) {
402 double* xList = new double[ nbPoints ];
403 double* yList = new double[ nbPoints ];
405 for ( j = 1; j <= nbCols; j++ ) {
406 if ( tblIntAttr->HasValue( idx(horIndex)+1, j ) && tblIntAttr->HasValue( idx(verIndex[i])+1, j ) ) {
407 xList[j-1] = tblIntAttr->GetValue( idx(horIndex) +1, j );
408 yList[j-1] = tblIntAttr->GetValue( idx(verIndex[i])+1, j );
409 zList.append( QString( "%1" ).arg( tblIntAttr->GetValue( idx(zIndices[i])+1, j ) ) );
412 curve->setData( xList, yList, nbPoints, zList );
415 curve->setLine( (Plot2d::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() );
416 curve->setMarker( (Plot2d::MarkerType)myItems.at( verIndex[i] )->getMarker() );
417 curve->setColor( myItems.at( verIndex[i] )->getColor() );
418 curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() );
419 // add curve into container
420 container.append( curve );
424 MESSAGE("VisuGUI_SetupPlot2dDlg::getCurves : Exception has been caught (int)!!!");
428 /* Try table of real */
429 else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
430 tblRealAttr = anAttr;
433 int nbCols = tblRealAttr->GetNbColumns() ;
434 std::vector<std::string> rowTitles = tblRealAttr->GetRowTitles();
435 std::vector<std::string> rowUnits = tblRealAttr->GetRowUnits();
437 for ( i = 0; i < verIndex.count(); i++ ) {
438 SPlot2d_Curve* curve = new SPlot2d_Curve();
440 if ( rowTitles.size() > 0 ) {
441 curve->setHorTitle( QString( rowTitles[ idx(horIndex) ].c_str() ) );
442 curve->setVerTitle( QString( rowTitles[ idx(verIndex[i]) ].c_str() ) );
445 if ( rowUnits.size() > 0 ) {
446 curve->setHorUnits( QString( rowUnits[ idx(horIndex) ].c_str() ) );
447 curve->setVerUnits( QString( rowUnits[ idx(verIndex[i]) ].c_str() ) );
451 for ( j = 1; j <= nbCols; j++ ) {
452 if ( tblRealAttr->HasValue( idx(horIndex)+1, j ) && tblRealAttr->HasValue( idx(verIndex[i])+1, j ) )
455 if ( nbPoints > 0 ) {
456 double* xList = new double[ nbPoints ];
457 double* yList = new double[ nbPoints ];
459 for ( j = 1; j <= nbCols; j++ ) {
460 if ( tblRealAttr->HasValue( idx(horIndex)+1, j ) && tblRealAttr->HasValue( idx(verIndex[i])+1, j ) ) {
461 xList[j-1] = tblRealAttr->GetValue( idx(horIndex) +1, j );
462 yList[j-1] = tblRealAttr->GetValue( idx(verIndex[i])+1, j );
463 zList.append( QString( "%1" ).arg( tblIntAttr->GetValue( idx(zIndices[i])+1, j ) ) );
466 curve->setData( xList, yList, nbPoints, zList );
469 curve->setLine( (Plot2d::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() );
470 curve->setMarker( (Plot2d::MarkerType)myItems.at( verIndex[i] )->getMarker() );
471 curve->setColor( myItems.at( verIndex[i] )->getColor() );
472 curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() );
473 // add curve into container
474 container.append( curve );
478 MESSAGE("VisuGUI_SetupPlot2dDlg::getCurves : Exception has been caught (real)!!!");
484 Slot, called when any <H> button is clicked
486 void VisuGUI_SetupPlot2dDlg::onHBtnToggled( bool on )
488 VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender();
490 for ( int i = 0; i < myItems.count(); i++ ) {
491 if ( myItems.at( i ) != item )
492 myItems.at( i )->setHorizontalOn( false );
498 Slot, called when any <V> button is clicked
500 void VisuGUI_SetupPlot2dDlg::onVBtnToggled( bool on )
502 VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender();
503 QList<VisuGUI_ItemContainer*> itemList;
504 //itemList.setAutoDelete( false );
505 item->myAssigned->setEnabled( on );
509 for ( i = 0; i < myItems.count(); i++ ) {
510 if ( myItems.at( i ) != item && !myItems.at( i )->isHorizontalOn() ) {
511 if ( myItems.at( i )->myUnitLab->text() == item->myUnitLab->text() ) {
512 if ( myItems.at( i )->isVerticalOn() )
515 itemList.append( myItems.at( i ) );
518 myItems.at( i )->setVerticalOn( false );
522 if ( totalOn == 0 && !itemList.isEmpty() &&
523 SUIT_MessageBox::information( this,
525 tr( "QUE_WANT_SAME_UNITS" ),
530 for ( i = 0; i < itemList.count(); i++ ) {
531 itemList.at( i )->blockSignals( true );
532 itemList.at( i )->setVerticalOn( true );
533 itemList.at( i )->blockSignals( false );
540 Slot, called when any <V2> button is clicked
542 void VisuGUI_SetupPlot2dDlg::onV2BtnToggled( bool on )
544 VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender();
545 QList<VisuGUI_ItemContainer*> itemList;
546 //itemList.setAutoDelete( false );
547 item->myAssigned->setEnabled( on );
551 for ( i = 0; i < myItems.count(); i++ ) {
552 if ( myItems.at( i ) != item && !myItems.at( i )->isHorizontalOn() ) {
553 if ( myItems.at( i )->myUnitLab->text() == item->myUnitLab->text() ) {
554 if ( myItems.at( i )->isVertical2On() )
557 itemList.append( myItems.at( i ) );
560 myItems.at( i )->setVertical2On( false );
564 if ( totalOn == 0 && !itemList.isEmpty() &&
565 SUIT_MessageBox::information( this,
567 tr( "QUE_WANT_SAME_UNITS" ),
572 for ( i = 0; i < itemList.count(); i++ ) {
573 itemList.at( i )->blockSignals( true );
574 itemList.at( i )->setVertical2On( true );
575 itemList.at( i )->blockSignals( false );
582 Slot, called when <Help> button is clicked
584 void VisuGUI_SetupPlot2dDlg::onHelp()
586 QString aHelpFileName = "creating_curves_page.html";
587 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
589 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
590 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
595 platform = "winapplication";
597 platform = "application";
599 SUIT_MessageBox::warning(0, tr("WRN_WARNING"),
600 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
601 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName),
606 Enables/disables buttons
608 void VisuGUI_SetupPlot2dDlg::enableControls()
612 for ( int i = 0; i < myItems.count(); i++ ) {
613 if ( myItems.at( i )->isHorizontalOn() ) {
618 for ( int i = 0; i < myItems.count(); i++ ) {
619 bool isVOn = myItems.at( i )->isVerticalOn() || myItems.at( i )->isVertical2On();
622 myItems.at( i )->enableWidgets( bHSet && isVOn );
624 myOkBtn->setEnabled( bHSet && bVSet );
628 Provides help on F1 button click
630 void VisuGUI_SetupPlot2dDlg::keyPressEvent( QKeyEvent* e )
632 QDialog::keyPressEvent( e );
633 if ( e->isAccepted() )
636 if ( e->key() == Qt::Key_F1 )
643 // ====================================================================================
647 VisuGUI_ItemContainer::VisuGUI_ItemContainer( QObject* parent )
655 void VisuGUI_ItemContainer::createWidgets( QWidget* parentWidget, const QStringList& lst )
657 myHBtn = new QToolButton( parentWidget );
658 myHBtn->setText( tr( "H" ) );
659 myHBtn->setCheckable( true );
660 myHBtn->setChecked( false );
662 myVBtn = new QToolButton( parentWidget );
663 myVBtn->setText( tr( "V" ) );
664 myVBtn->setCheckable( true );
665 myVBtn->setChecked( false );
667 myV2Btn = new QToolButton( parentWidget );
668 myV2Btn->setText( tr( "V2" ) );
669 myV2Btn->setCheckable( true );
670 myV2Btn->setChecked( false );
672 myTitleLab = new QLabel( parentWidget );
673 myUnitLab = new QLabel( parentWidget );
674 myUnitLab->setAlignment( Qt::AlignCenter);
676 myDvtnLab = new QLabel( parentWidget );
677 myDvtnLab->setAlignment( Qt::AlignCenter);
679 myAutoCheck = new QCheckBox( tr( "AUTO_CHECK_LBL" ), parentWidget );
680 myAutoCheck->setChecked( true );
682 myLineCombo = new QComboBox( parentWidget );
683 myLineCombo->addItem( tr( "NONE_LINE_LBL" ) );
684 myLineCombo->addItem( tr( "SOLID_LINE_LBL" ) );
685 myLineCombo->addItem( tr( "DASH_LINE_LBL" ) );
686 myLineCombo->addItem( tr( "DOT_LINE_LBL" ) );
687 myLineCombo->addItem( tr( "DASHDOT_LINE_LBL" ) );
688 myLineCombo->addItem( tr( "DAHSDOTDOT_LINE_LBL" ) );
689 myLineCombo->setCurrentIndex( 1 ); // SOLID by default
691 myLineSpin = new SalomeApp_IntSpinBox( parentWidget );
692 myLineSpin->setAcceptNames( false );
693 myLineSpin->setMinimum( 0 );
694 myLineSpin->setMaximum( MAX_LINE_WIDTH );
695 myLineSpin->setSingleStep( 1 );
696 myLineSpin->setValue( 0 ); // width = 0 by default
698 myMarkerCombo = new QComboBox( parentWidget );
699 myMarkerCombo->addItem( tr( "NONE_MARKER_LBL" ) );
700 myMarkerCombo->addItem( tr( "CIRCLE_MARKER_LBL" ) );
701 myMarkerCombo->addItem( tr( "RECTANGLE_MARKER_LBL" ) );
702 myMarkerCombo->addItem( tr( "DIAMOND_MARKER_LBL" ) );
703 myMarkerCombo->addItem( tr( "DTRIANGLE_MARKER_LBL" ) );
704 myMarkerCombo->addItem( tr( "UTRIANGLE_MARKER_LBL" ) );
705 myMarkerCombo->addItem( tr( "LTRIANGLE_MARKER_LBL" ) );
706 myMarkerCombo->addItem( tr( "RTRIANGLE_MARKER_LBL" ) );
707 myMarkerCombo->addItem( tr( "CROSS_MARKER_LBL" ) );
708 myMarkerCombo->addItem( tr( "XCROSS_MARKER_LBL" ) );
709 myMarkerCombo->setCurrentIndex( 1 ); // CIRCLE by default
711 myColorBtn = new QtxColorButton( parentWidget );
712 myColorBtn->setMinimumWidth( 20 );
714 myAssigned = new QComboBox( parentWidget );
715 myAssigned->addItem( "" );
716 QStringList::const_iterator anIt = lst.begin(), aLast = lst.end();
717 for( ; anIt!=aLast; anIt++ )
718 myAssigned->addItem( *anIt );
719 myAssigned->setEnabled( false );
721 connect( myAutoCheck, SIGNAL( clicked() ), this, SLOT( onAutoChanged() ) );
722 //connect( myColorBtn, SIGNAL( clicked() ), this, SLOT( onColorChanged() ) );
723 connect( myHBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) );
724 connect( myVBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) );
725 connect( myV2Btn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) );
726 setColor( QColor( 0, 0, 0 ) );
730 Enables attributes widgets
732 void VisuGUI_ItemContainer::enableWidgets( bool enable )
738 Sets horizontal button's state on
740 void VisuGUI_ItemContainer::setHorizontalOn( bool on )
742 myHBtn->setChecked( on );
745 Gets horizontal button's state
747 bool VisuGUI_ItemContainer::isHorizontalOn() const
749 return myHBtn->isChecked();
752 Sets first vertical button's state on
754 void VisuGUI_ItemContainer::setVerticalOn( bool on )
756 myVBtn->setChecked( on );
759 Gets first vertical button's state
761 bool VisuGUI_ItemContainer::isVerticalOn() const
763 return myVBtn->isChecked();
766 Sets second vertical button's state on
768 void VisuGUI_ItemContainer::setVertical2On( bool on )
770 myV2Btn->setChecked( on );
773 Gets second vertical button's state
775 bool VisuGUI_ItemContainer::isVertical2On() const
777 return myV2Btn->isChecked();
780 Sets item AutoAssign flag state
782 void VisuGUI_ItemContainer::setAutoAssign( bool on )
784 myAutoCheck->setChecked( on );
788 Gets item AutoAssign flag state
790 bool VisuGUI_ItemContainer::isAutoAssign() const
792 return myAutoCheck->isChecked();
795 Sets item line type and width
797 void VisuGUI_ItemContainer::setLine( const int line, const int width )
799 myLineCombo->setCurrentIndex( line );
804 int VisuGUI_ItemContainer::getLine() const
806 return myLineCombo->currentIndex();
811 int VisuGUI_ItemContainer::getLineWidth() const
813 return myLineSpin->value();
816 Sets item marker type
818 void VisuGUI_ItemContainer::setMarker( const int marker )
820 myMarkerCombo->setCurrentIndex( marker );
823 Gets item marker type
825 int VisuGUI_ItemContainer::getMarker() const
827 return myMarkerCombo->currentIndex();
833 void VisuGUI_ItemContainer::setColor( const QColor& color )
835 //QPalette pal = myColorBtn->palette();
836 //pal.setColor( myColorBtn->backgroundRole(), color );
837 myColorBtn->setColor( color );
842 QColor VisuGUI_ItemContainer::getColor() const
844 return myColorBtn->color();//palette().color( myColorBtn->backgroundRole() );
847 Enables/disables widgets
849 void VisuGUI_ItemContainer::updateState()
851 myAutoCheck->setEnabled( myEnabled );
852 myLineCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() );
853 myLineSpin->setEnabled( myEnabled && !myAutoCheck->isChecked() );
854 myMarkerCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() );
855 myColorBtn->setEnabled( myEnabled && !myAutoCheck->isChecked() );
858 Slot, called when user clickes <Auto assign> check box
860 void VisuGUI_ItemContainer::onAutoChanged()
863 emit( autoClicked() );
866 <Color> button slot, invokes color selection dialog box
868 /*void VisuGUI_ItemContainer::onColorChanged()
870 QColor color = QColorDialog::getColor( getColor() );
871 if ( color.isValid() ) {
876 <H> and <V> buttons slot
878 void VisuGUI_ItemContainer::onHVToggled( bool on )
880 const QObject* snd = sender();
881 if ( snd == myHBtn ) {
883 if ( myVBtn->isChecked() ) {
884 // blockSignals( true );
885 myVBtn->setChecked( false );
886 // blockSignals( false );
888 else if ( myV2Btn->isChecked() ) {
889 // blockSignals( true );
890 myV2Btn->setChecked( false );
891 // blockSignals( false );
894 emit horToggled( on );
896 else if ( snd == myVBtn ) {
898 if ( myHBtn->isChecked() ) {
899 // blockSignals( true );
900 myHBtn->setChecked( false );
901 // blockSignals( false );
903 else if ( myV2Btn->isChecked() ) {
904 // blockSignals( true );
905 myV2Btn->setChecked( false );
906 // blockSignals( false );
909 emit verToggled( on );
913 if ( myHBtn->isChecked() ) {
914 // blockSignals( true );
915 myHBtn->setChecked( false );
916 // blockSignals( false );
918 else if ( myVBtn->isChecked() ) {
919 // blockSignals( true );
920 myVBtn->setChecked( false );
921 // blockSignals( false );
924 emit ver2Toggled( on );
929 \return index of assigned row (0, if there is no assigned row)
931 int VisuGUI_ItemContainer::assigned() const
933 if( isVerticalOn() || isVertical2On() )
934 return myAssigned->currentIndex()-1;