1 // Copyright (C) 2007-2010 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, QWidget* parent )
72 : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
75 setWindowTitle( tr("TLT_SETUP_PLOT2D") );
76 setSizeGripEnabled( TRUE );
77 QGridLayout* topLayout = new QGridLayout( this );
78 topLayout->setSpacing( SPACING_SIZE );
79 topLayout->setMargin( MARGIN_SIZE );
81 //myItems.setAutoDelete( false );
86 myView = new QScrollArea( this );
87 QFrame* frame = new QFrame( myView );
88 frame->setFrameStyle( QFrame::Plain | QFrame::NoFrame );
89 QGridLayout* frameLayout = new QGridLayout( frame );
90 frameLayout->setMargin( MARGIN_SIZE ); frameLayout->setSpacing( SPACING_SIZE );
94 QLabel* labAxis = new QLabel( tr( "AXIS_LBL" ), frame );
95 QLabel* labAssigned = new QLabel( tr( "ASSIGNED" ), frame );
96 QLabel* labData = new QLabel( tr( "DATA_LBL" ), frame );
97 QLabel* labUnit = new QLabel( tr( "UNITS_LBL" ), frame );
98 QLabel* labAttr = new QLabel( tr( "ATTRIBUTES_LBL" ), frame );
99 labAxis->setAlignment( Qt::AlignCenter );
100 labAssigned->setAlignment( Qt::AlignCenter );
101 labData->setAlignment( Qt::AlignCenter );
102 labUnit->setAlignment( Qt::AlignCenter );
103 labAttr->setAlignment( Qt::AlignCenter );
104 QFont font = labAxis->font(); font.setBold( true );
105 labAxis->setFont( font );
106 labAssigned->setFont( font );
107 labData->setFont( font );
108 labUnit->setFont( font );
109 labAttr->setFont( font );
111 frameLayout->addWidget( labAxis, 0, 0, 1, 3 );
112 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
113 frameLayout->addWidget( lin, 0, 3 );
115 frameLayout->addWidget( labAssigned, 0, 4 );
116 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
117 frameLayout->addWidget( lin, 0, 5 );
119 frameLayout->addWidget( labData, 0, 6 );
120 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
121 frameLayout->addWidget( lin, 0, 7 );
122 frameLayout->addWidget( labUnit, 0, 8 );
123 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
124 frameLayout->addWidget( lin, 0, 9 );
125 frameLayout->addWidget( labAttr, 0, 10, 1, 5 );
126 //frameLayout->setColStretch( 15, 5 );
127 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::HLine | QFrame::Sunken );
128 frameLayout->addWidget( lin, 1, 0, 1, 16 );
131 _PTR(GenericAttribute) anAttr;
132 _PTR(AttributeTableOfInteger) tblIntAttr;
133 _PTR(AttributeTableOfReal) tblRealAttr;
135 /* Try table of integer */
136 if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) {
140 int nbRows = tblIntAttr->GetNbRows() ;
141 std::vector<std::string> rowTitles = tblIntAttr->GetRowTitles();
142 std::vector<std::string> rowUnits = tblIntAttr->GetRowUnits();
144 for ( int i = 0; i < nbRows; i++ )
145 rows.append( rowTitles[i].c_str() );
147 for ( int i = 0; i < nbRows; i++ ) {
148 VisuGUI_ItemContainer* item = new VisuGUI_ItemContainer( this );
149 item->createWidgets( frame, rows );
150 frameLayout->addWidget( item->myHBtn, row, 0 );
151 frameLayout->addWidget( item->myVBtn, row, 1 );
152 frameLayout->addWidget( item->myV2Btn, row, 2 );
153 frameLayout->addWidget( item->myAssigned, row, 4 );
155 frameLayout->addWidget( item->myTitleLab, row, 6 );
156 if ( rowTitles.size() > 0 )
157 item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) );
158 frameLayout->addWidget( item->myUnitLab, row, 8 );
159 if ( rowUnits.size() > 0 )
160 item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) );
161 frameLayout->addWidget( item->myAutoCheck, row, 10 );
162 frameLayout->addWidget( item->myLineCombo, row, 11 );
163 frameLayout->addWidget( item->myLineSpin, row, 12 );
164 frameLayout->addWidget( item->myMarkerCombo, row, 13 );
165 frameLayout->addWidget( item->myColorBtn, row, 14 );
166 connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
167 connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
168 connect( item, SIGNAL( ver2Toggled( bool ) ), this, SLOT( onV2BtnToggled( bool ) ) );
169 myItems.append( item );
174 MESSAGE("VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg : Exception has been caught (int)!!!");
178 /* Try table of real */
179 else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
180 tblRealAttr = anAttr;
183 int nbRows = tblRealAttr->GetNbRows() ;
184 std::vector<std::string> rowTitles = tblRealAttr->GetRowTitles();
185 std::vector<std::string> rowUnits = tblRealAttr->GetRowUnits();
187 for ( int i = 0; i < nbRows; i++ )
188 rows.append( rowTitles[i].c_str() );
190 for ( int i = 0; i < nbRows; i++ ) {
191 VisuGUI_ItemContainer* item = new VisuGUI_ItemContainer( this );
192 item->createWidgets( frame, rows );
193 frameLayout->addWidget( item->myHBtn, row, 0 );
194 frameLayout->addWidget( item->myVBtn, row, 1 );
195 frameLayout->addWidget( item->myV2Btn, row, 2 );
196 frameLayout->addWidget( item->myAssigned, row, 4 );
198 frameLayout->addWidget( item->myTitleLab, row, 6 );
199 if ( rowTitles.size() > 0 )
200 item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) );
201 frameLayout->addWidget( item->myUnitLab, row, 8 );
202 if ( rowUnits.size() > 0 )
203 item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) );
204 frameLayout->addWidget( item->myAutoCheck, row, 10 );
205 frameLayout->addWidget( item->myLineCombo, row, 11 );
206 frameLayout->addWidget( item->myLineSpin, row, 12 );
207 frameLayout->addWidget( item->myMarkerCombo, row, 13 );
208 frameLayout->addWidget( item->myColorBtn, row, 14 );
209 connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
210 connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
211 connect( item, SIGNAL( ver2Toggled( bool ) ), this, SLOT( onV2BtnToggled( bool ) ) );
212 myItems.append( item );
217 MESSAGE("VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg : Exception has been caught (real)!!!");
221 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
222 frameLayout->addWidget( lin, 2, 3, row, 1 );
223 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
224 frameLayout->addWidget( lin, 2, 5, row, 1 );
225 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
226 frameLayout->addWidget( lin, 2, 7, row, 1 );
227 //frameLayout->setRowStretch( row+1, 5 );
229 myView->setWidget( frame );
230 myView->setAlignment( Qt::AlignCenter );
231 myView->setWidgetResizable( true );
233 myView->setMinimumWidth( frame->sizeHint().width() + MARGIN_SIZE * 2 );
235 /* OK/Cancel/Help buttons */
236 myOkBtn = new QPushButton( tr( "BUT_OK" ), this );
237 myOkBtn->setAutoDefault( TRUE );
238 myOkBtn->setDefault( TRUE );
239 myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this );
240 myCancelBtn->setAutoDefault( TRUE );
241 myHelpBtn = new QPushButton( tr( "BUT_HELP" ), this );
242 myHelpBtn->setAutoDefault( TRUE );
244 topLayout->addWidget( myView, 0, 0, 1, 4 );
245 topLayout->addWidget( myOkBtn, 1, 0 );
246 //topLayout->setColStretch( 1, 5 );
247 topLayout->addWidget( myCancelBtn, 1, 2 );
248 topLayout->addWidget( myHelpBtn, 1, 3 );
250 connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
251 connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
252 connect( myHelpBtn, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
256 /* Center widget inside it's parent widget */
257 resize( DLG_SIZE_WIDTH, DLG_SIZE_HEIGHT );
258 SUIT_Tools::centerWidget( this, parentWidget() );
263 VisuGUI_SetupPlot2dDlg::~VisuGUI_SetupPlot2dDlg()
267 Gets curves info ( indexes of row data in the table for horizontal and verical axes )
269 void VisuGUI_SetupPlot2dDlg::getCurvesSource( int& horIndex, QList<int>& verIndexes,
270 QList<int>& ver2Indexes, QList<int>& zIndices )
272 /* collecting horizontal and vertical axis items */
275 for ( i = 0; i < myItems.count(); i++ ) {
276 if ( myItems.at( i )->isHorizontalOn() ) {
280 if ( myItems.at( i )->isVerticalOn() ) {
281 verIndexes.append( i );
283 else if ( myItems.at( i )->isVertical2On() ) {
284 ver2Indexes.append( i );
286 zIndices.append( myItems.at( i )->assigned() );
291 Gets curve attributes
293 bool VisuGUI_SetupPlot2dDlg::getCurveAttributes( const int vIndex,
300 if ( vIndex >= 0 && vIndex < myItems.count() ) {
301 isAuto = myItems.at( vIndex )->isAutoAssign();
302 marker = myItems.at( vIndex )->getMarker();
303 line = myItems.at( vIndex )->getLine();
304 lineWidth = myItems.at( vIndex )->getLineWidth();
305 color = myItems.at( vIndex )->getColor();
311 Creates and returns curves presentations
313 void VisuGUI_SetupPlot2dDlg::getCurves( QList<Plot2d_Curve*>& container )
315 _PTR(GenericAttribute) anAttr;
316 _PTR(AttributeTableOfInteger) tblIntAttr;
317 _PTR(AttributeTableOfReal) tblRealAttr;
319 /* clearing container contents */
322 /* collecting horizontal and vertical axis items */
325 QList<int> verIndex, ver2Index, zIndices;
326 getCurvesSource( horIndex, verIndex, ver2Index, zIndices );
327 if ( horIndex < 0 || verIndex.isEmpty() && ver2Index.isEmpty() ) /* no curves can be created */
330 /* Try table of integer */
331 if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) {
335 int nbCols = tblIntAttr->GetNbColumns() ;
336 std::vector<std::string> rowTitles = tblIntAttr->GetRowTitles();
337 std::vector<std::string> rowUnits = tblIntAttr->GetRowUnits();
339 for ( i = 0; i < verIndex.count(); i++ ) {
340 SPlot2d_Curve* curve = new SPlot2d_Curve();
342 if ( rowTitles.size() > 0 ) {
343 curve->setHorTitle( QString( rowTitles[ horIndex ].c_str() ) );
344 curve->setVerTitle( QString( rowTitles[ verIndex[i] ].c_str() ) );
347 if ( rowUnits.size() > 0 ) {
348 curve->setHorUnits( QString( rowUnits[ horIndex ].c_str() ) );
349 curve->setVerUnits( QString( rowUnits[ verIndex[i] ].c_str() ) );
353 for ( j = 1; j <= nbCols; j++ ) {
354 if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) )
357 if ( nbPoints > 0 ) {
358 double* xList = new double[ nbPoints ];
359 double* yList = new double[ nbPoints ];
361 for ( j = 1; j <= nbCols; j++ ) {
362 if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) ) {
363 xList[j-1] = tblIntAttr->GetValue( horIndex +1, j );
364 yList[j-1] = tblIntAttr->GetValue( verIndex[i]+1, j );
365 zList.append( QString( "%1" ).arg( tblIntAttr->GetValue( zIndices[i]+1, j ) ) );
368 curve->setData( xList, yList, nbPoints, zList );
371 curve->setLine( (Plot2d::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() );
372 curve->setMarker( (Plot2d::MarkerType)myItems.at( verIndex[i] )->getMarker() );
373 curve->setColor( myItems.at( verIndex[i] )->getColor() );
374 curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() );
375 // add curve into container
376 container.append( curve );
380 MESSAGE("VisuGUI_SetupPlot2dDlg::getCurves : Exception has been caught (int)!!!");
384 /* Try table of real */
385 else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
386 tblRealAttr = anAttr;
389 int nbCols = tblRealAttr->GetNbColumns() ;
390 std::vector<std::string> rowTitles = tblRealAttr->GetRowTitles();
391 std::vector<std::string> rowUnits = tblRealAttr->GetRowUnits();
393 for ( i = 0; i < verIndex.count(); i++ ) {
394 SPlot2d_Curve* curve = new SPlot2d_Curve();
396 if ( rowTitles.size() > 0 ) {
397 curve->setHorTitle( QString( rowTitles[ horIndex ].c_str() ) );
398 curve->setVerTitle( QString( rowTitles[ verIndex[i] ].c_str() ) );
401 if ( rowUnits.size() > 0 ) {
402 curve->setHorUnits( QString( rowUnits[ horIndex ].c_str() ) );
403 curve->setVerUnits( QString( rowUnits[ verIndex[i] ].c_str() ) );
407 for ( j = 1; j <= nbCols; j++ ) {
408 if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) )
411 if ( nbPoints > 0 ) {
412 double* xList = new double[ nbPoints ];
413 double* yList = new double[ nbPoints ];
415 for ( j = 1; j <= nbCols; j++ ) {
416 if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) ) {
417 xList[j-1] = tblRealAttr->GetValue( horIndex +1, j );
418 yList[j-1] = tblRealAttr->GetValue( verIndex[i]+1, j );
419 zList.append( QString( "%1" ).arg( tblIntAttr->GetValue( zIndices[i]+1, j ) ) );
422 curve->setData( xList, yList, nbPoints, zList );
425 curve->setLine( (Plot2d::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() );
426 curve->setMarker( (Plot2d::MarkerType)myItems.at( verIndex[i] )->getMarker() );
427 curve->setColor( myItems.at( verIndex[i] )->getColor() );
428 curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() );
429 // add curve into container
430 container.append( curve );
434 MESSAGE("VisuGUI_SetupPlot2dDlg::getCurves : Exception has been caught (real)!!!");
440 Slot, called when any <H> button is clicked
442 void VisuGUI_SetupPlot2dDlg::onHBtnToggled( bool on )
444 VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender();
446 for ( int i = 0; i < myItems.count(); i++ ) {
447 if ( myItems.at( i ) != item )
448 myItems.at( i )->setHorizontalOn( false );
454 Slot, called when any <V> button is clicked
456 void VisuGUI_SetupPlot2dDlg::onVBtnToggled( bool on )
458 VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender();
459 QList<VisuGUI_ItemContainer*> itemList;
460 //itemList.setAutoDelete( false );
461 item->myAssigned->setEnabled( on );
465 for ( i = 0; i < myItems.count(); i++ ) {
466 if ( myItems.at( i ) != item && !myItems.at( i )->isHorizontalOn() ) {
467 if ( myItems.at( i )->myUnitLab->text() == item->myUnitLab->text() ) {
468 if ( myItems.at( i )->isVerticalOn() )
471 itemList.append( myItems.at( i ) );
474 myItems.at( i )->setVerticalOn( false );
478 if ( totalOn == 0 && !itemList.isEmpty() &&
479 SUIT_MessageBox::information( this,
481 tr( "QUE_WANT_SAME_UNITS" ),
486 for ( i = 0; i < itemList.count(); i++ ) {
487 itemList.at( i )->blockSignals( true );
488 itemList.at( i )->setVerticalOn( true );
489 itemList.at( i )->blockSignals( false );
496 Slot, called when any <V2> button is clicked
498 void VisuGUI_SetupPlot2dDlg::onV2BtnToggled( bool on )
500 VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender();
501 QList<VisuGUI_ItemContainer*> itemList;
502 //itemList.setAutoDelete( false );
503 item->myAssigned->setEnabled( on );
507 for ( i = 0; i < myItems.count(); i++ ) {
508 if ( myItems.at( i ) != item && !myItems.at( i )->isHorizontalOn() ) {
509 if ( myItems.at( i )->myUnitLab->text() == item->myUnitLab->text() ) {
510 if ( myItems.at( i )->isVertical2On() )
513 itemList.append( myItems.at( i ) );
516 myItems.at( i )->setVertical2On( false );
520 if ( totalOn == 0 && !itemList.isEmpty() &&
521 SUIT_MessageBox::information( this,
523 tr( "QUE_WANT_SAME_UNITS" ),
528 for ( i = 0; i < itemList.count(); i++ ) {
529 itemList.at( i )->blockSignals( true );
530 itemList.at( i )->setVertical2On( true );
531 itemList.at( i )->blockSignals( false );
538 Slot, called when <Help> button is clicked
540 void VisuGUI_SetupPlot2dDlg::onHelp()
542 QString aHelpFileName = "creating_curves_page.html";
543 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
545 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
546 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
551 platform = "winapplication";
553 platform = "application";
555 SUIT_MessageBox::warning(0, tr("WRN_WARNING"),
556 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
557 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName),
562 Enables/disables buttons
564 void VisuGUI_SetupPlot2dDlg::enableControls()
568 for ( int i = 0; i < myItems.count(); i++ ) {
569 if ( myItems.at( i )->isHorizontalOn() ) {
574 for ( int i = 0; i < myItems.count(); i++ ) {
575 bool isVOn = myItems.at( i )->isVerticalOn() || myItems.at( i )->isVertical2On();
578 myItems.at( i )->enableWidgets( bHSet && isVOn );
580 myOkBtn->setEnabled( bHSet && bVSet );
584 Provides help on F1 button click
586 void VisuGUI_SetupPlot2dDlg::keyPressEvent( QKeyEvent* e )
588 QDialog::keyPressEvent( e );
589 if ( e->isAccepted() )
592 if ( e->key() == Qt::Key_F1 )
599 // ====================================================================================
603 VisuGUI_ItemContainer::VisuGUI_ItemContainer( QObject* parent )
611 void VisuGUI_ItemContainer::createWidgets( QWidget* parentWidget, const QStringList& lst )
613 myHBtn = new QToolButton( parentWidget );
614 myHBtn->setText( tr( "H" ) );
615 myHBtn->setCheckable( true );
616 myHBtn->setChecked( false );
618 myVBtn = new QToolButton( parentWidget );
619 myVBtn->setText( tr( "V" ) );
620 myVBtn->setCheckable( true );
621 myVBtn->setChecked( false );
623 myV2Btn = new QToolButton( parentWidget );
624 myV2Btn->setText( tr( "V2" ) );
625 myV2Btn->setCheckable( true );
626 myV2Btn->setChecked( false );
628 myTitleLab = new QLabel( parentWidget );
629 myUnitLab = new QLabel( parentWidget );
630 myUnitLab->setAlignment( Qt::AlignCenter);
632 myAutoCheck = new QCheckBox( tr( "AUTO_CHECK_LBL" ), parentWidget );
633 myAutoCheck->setChecked( true );
635 myLineCombo = new QComboBox( parentWidget );
636 myLineCombo->addItem( tr( "NONE_LINE_LBL" ) );
637 myLineCombo->addItem( tr( "SOLID_LINE_LBL" ) );
638 myLineCombo->addItem( tr( "DASH_LINE_LBL" ) );
639 myLineCombo->addItem( tr( "DOT_LINE_LBL" ) );
640 myLineCombo->addItem( tr( "DASHDOT_LINE_LBL" ) );
641 myLineCombo->addItem( tr( "DAHSDOTDOT_LINE_LBL" ) );
642 myLineCombo->setCurrentIndex( 1 ); // SOLID by default
644 myLineSpin = new SalomeApp_IntSpinBox( parentWidget );
645 myLineSpin->setAcceptNames( false );
646 myLineSpin->setMinimum( 0 );
647 myLineSpin->setMaximum( MAX_LINE_WIDTH );
648 myLineSpin->setSingleStep( 1 );
649 myLineSpin->setValue( 0 ); // width = 0 by default
651 myMarkerCombo = new QComboBox( parentWidget );
652 myMarkerCombo->addItem( tr( "NONE_MARKER_LBL" ) );
653 myMarkerCombo->addItem( tr( "CIRCLE_MARKER_LBL" ) );
654 myMarkerCombo->addItem( tr( "RECTANGLE_MARKER_LBL" ) );
655 myMarkerCombo->addItem( tr( "DIAMOND_MARKER_LBL" ) );
656 myMarkerCombo->addItem( tr( "DTRIANGLE_MARKER_LBL" ) );
657 myMarkerCombo->addItem( tr( "UTRIANGLE_MARKER_LBL" ) );
658 myMarkerCombo->addItem( tr( "LTRIANGLE_MARKER_LBL" ) );
659 myMarkerCombo->addItem( tr( "RTRIANGLE_MARKER_LBL" ) );
660 myMarkerCombo->addItem( tr( "CROSS_MARKER_LBL" ) );
661 myMarkerCombo->addItem( tr( "XCROSS_MARKER_LBL" ) );
662 myMarkerCombo->setCurrentIndex( 1 ); // CIRCLE by default
664 myColorBtn = new QtxColorButton( parentWidget );
665 myColorBtn->setMinimumWidth( 20 );
667 myAssigned = new QComboBox( parentWidget );
668 myAssigned->addItem( "" );
669 QStringList::const_iterator anIt = lst.begin(), aLast = lst.end();
670 for( ; anIt!=aLast; anIt++ )
671 myAssigned->addItem( *anIt );
672 myAssigned->setEnabled( false );
674 connect( myAutoCheck, SIGNAL( clicked() ), this, SLOT( onAutoChanged() ) );
675 //connect( myColorBtn, SIGNAL( clicked() ), this, SLOT( onColorChanged() ) );
676 connect( myHBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) );
677 connect( myVBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) );
678 connect( myV2Btn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) );
679 setColor( QColor( 0, 0, 0 ) );
683 Enables attributes widgets
685 void VisuGUI_ItemContainer::enableWidgets( bool enable )
691 Sets horizontal button's state on
693 void VisuGUI_ItemContainer::setHorizontalOn( bool on )
695 myHBtn->setChecked( on );
698 Gets horizontal button's state
700 bool VisuGUI_ItemContainer::isHorizontalOn() const
702 return myHBtn->isChecked();
705 Sets first vertical button's state on
707 void VisuGUI_ItemContainer::setVerticalOn( bool on )
709 myVBtn->setChecked( on );
712 Gets first vertical button's state
714 bool VisuGUI_ItemContainer::isVerticalOn() const
716 return myVBtn->isChecked();
719 Sets second vertical button's state on
721 void VisuGUI_ItemContainer::setVertical2On( bool on )
723 myV2Btn->setChecked( on );
726 Gets second vertical button's state
728 bool VisuGUI_ItemContainer::isVertical2On() const
730 return myV2Btn->isChecked();
733 Sets item AutoAssign flag state
735 void VisuGUI_ItemContainer::setAutoAssign( bool on )
737 myAutoCheck->setChecked( on );
741 Gets item AutoAssign flag state
743 bool VisuGUI_ItemContainer::isAutoAssign() const
745 return myAutoCheck->isChecked();
748 Sets item line type and width
750 void VisuGUI_ItemContainer::setLine( const int line, const int width )
752 myLineCombo->setCurrentIndex( line );
757 int VisuGUI_ItemContainer::getLine() const
759 return myLineCombo->currentIndex();
764 int VisuGUI_ItemContainer::getLineWidth() const
766 return myLineSpin->value();
769 Sets item marker type
771 void VisuGUI_ItemContainer::setMarker( const int marker )
773 myMarkerCombo->setCurrentIndex( marker );
776 Gets item marker type
778 int VisuGUI_ItemContainer::getMarker() const
780 return myMarkerCombo->currentIndex();
786 void VisuGUI_ItemContainer::setColor( const QColor& color )
788 //QPalette pal = myColorBtn->palette();
789 //pal.setColor( myColorBtn->backgroundRole(), color );
790 myColorBtn->setColor( color );
795 QColor VisuGUI_ItemContainer::getColor() const
797 return myColorBtn->color();//palette().color( myColorBtn->backgroundRole() );
800 Enables/disables widgets
802 void VisuGUI_ItemContainer::updateState()
804 myAutoCheck->setEnabled( myEnabled );
805 myLineCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() );
806 myLineSpin->setEnabled( myEnabled && !myAutoCheck->isChecked() );
807 myMarkerCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() );
808 myColorBtn->setEnabled( myEnabled && !myAutoCheck->isChecked() );
811 Slot, called when user clickes <Auto assign> check box
813 void VisuGUI_ItemContainer::onAutoChanged()
816 emit( autoClicked() );
819 <Color> button slot, invokes color selection dialog box
821 /*void VisuGUI_ItemContainer::onColorChanged()
823 QColor color = QColorDialog::getColor( getColor() );
824 if ( color.isValid() ) {
829 <H> and <V> buttons slot
831 void VisuGUI_ItemContainer::onHVToggled( bool on )
833 const QObject* snd = sender();
834 if ( snd == myHBtn ) {
836 if ( myVBtn->isChecked() ) {
837 // blockSignals( true );
838 myVBtn->setChecked( false );
839 // blockSignals( false );
841 else if ( myV2Btn->isChecked() ) {
842 // blockSignals( true );
843 myV2Btn->setChecked( false );
844 // blockSignals( false );
847 emit horToggled( on );
849 else if ( snd == myVBtn ) {
851 if ( myHBtn->isChecked() ) {
852 // blockSignals( true );
853 myHBtn->setChecked( false );
854 // blockSignals( false );
856 else if ( myV2Btn->isChecked() ) {
857 // blockSignals( true );
858 myV2Btn->setChecked( false );
859 // blockSignals( false );
862 emit verToggled( on );
866 if ( myHBtn->isChecked() ) {
867 // blockSignals( true );
868 myHBtn->setChecked( false );
869 // blockSignals( false );
871 else if ( myVBtn->isChecked() ) {
872 // blockSignals( true );
873 myVBtn->setChecked( false );
874 // blockSignals( false );
877 emit ver2Toggled( on );
882 \return index of assigned row (0, if there is no assigned row)
884 int VisuGUI_ItemContainer::assigned() const
886 if( isVerticalOn() || isVertical2On() )
887 return myAssigned->currentIndex()-1;