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 // File : VisuGUI_SetupPlot2dDlg.cxx
23 // Author : Vadim SANDLER
27 #include "VisuGUI_SetupPlot2dDlg.h"
29 #include "SPlot2d_Curve.h"
31 #include "SUIT_Tools.h"
32 #include "SUIT_MessageBox.h"
33 #include "SUIT_ResourceMgr.h"
34 #include "SUIT_Session.h"
36 #include "LightApp_Application.h"
38 #include <QtxColorButton.h>
40 #include <SALOMEDSClient_AttributeTableOfInteger.hxx>
41 #include <SALOMEDSClient_AttributeTableOfReal.hxx>
44 #include <QPushButton>
46 #include <QToolButton>
48 #include <QScrollArea>
50 #include <QColorDialog>
58 #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, 2 );
112 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
113 frameLayout->addWidget( lin, 0, 2 );
115 frameLayout->addWidget( labAssigned, 0, 3 );
116 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
117 frameLayout->addWidget( lin, 0, 4 );
119 frameLayout->addWidget( labData, 0, 5 );
120 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
121 frameLayout->addWidget( lin, 0, 6 );
122 frameLayout->addWidget( labUnit, 0, 7 );
123 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
124 frameLayout->addWidget( lin, 0, 8 );
125 frameLayout->addWidget( labAttr, 0, 9, 1, 5 );
126 //frameLayout->setColStretch( 14, 5 );
127 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::HLine | QFrame::Sunken );
128 frameLayout->addWidget( lin, 1, 0, 1, 15 );
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 vector<string> rowTitles = tblIntAttr->GetRowTitles();
142 vector<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->myAssigned, row, 3 );
154 frameLayout->addWidget( item->myTitleLab, row, 5 );
155 if ( rowTitles.size() > 0 )
156 item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) );
157 frameLayout->addWidget( item->myUnitLab, row, 7 );
158 if ( rowUnits.size() > 0 )
159 item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) );
160 frameLayout->addWidget( item->myAutoCheck, row, 9 );
161 frameLayout->addWidget( item->myLineCombo, row, 10 );
162 frameLayout->addWidget( item->myLineSpin, row, 11 );
163 frameLayout->addWidget( item->myMarkerCombo, row, 12 );
164 frameLayout->addWidget( item->myColorBtn, row, 13 );
165 connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
166 connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
167 myItems.append( item );
172 MESSAGE("VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg : Exception has been caught (int)!!!");
176 /* Try table of real */
177 else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
178 tblRealAttr = anAttr;
181 int nbRows = tblRealAttr->GetNbRows() ;
182 vector<string> rowTitles = tblRealAttr->GetRowTitles();
183 vector<string> rowUnits = tblRealAttr->GetRowUnits();
185 for ( int i = 0; i < nbRows; i++ )
186 rows.append( rowTitles[i].c_str() );
188 for ( int i = 0; i < nbRows; i++ ) {
189 VisuGUI_ItemContainer* item = new VisuGUI_ItemContainer( this );
190 item->createWidgets( frame, rows );
191 frameLayout->addWidget( item->myHBtn, row, 0 );
192 frameLayout->addWidget( item->myVBtn, row, 1 );
193 frameLayout->addWidget( item->myAssigned, row, 3 );
195 frameLayout->addWidget( item->myTitleLab, row, 5 );
196 if ( rowTitles.size() > 0 )
197 item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) );
198 frameLayout->addWidget( item->myUnitLab, row, 7 );
199 if ( rowUnits.size() > 0 )
200 item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) );
201 frameLayout->addWidget( item->myAutoCheck, row, 9 );
202 frameLayout->addWidget( item->myLineCombo, row, 10 );
203 frameLayout->addWidget( item->myLineSpin, row, 11 );
204 frameLayout->addWidget( item->myMarkerCombo, row, 12 );
205 frameLayout->addWidget( item->myColorBtn, row, 13 );
206 connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
207 connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
208 myItems.append( item );
213 MESSAGE("VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg : Exception has been caught (real)!!!");
217 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
218 frameLayout->addWidget( lin, 2, 2, row, 1 );
219 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
220 frameLayout->addWidget( lin, 2, 4, row, 1 );
221 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
222 frameLayout->addWidget( lin, 2, 6, row, 1 );
223 //frameLayout->setRowStretch( row+1, 5 );
225 myView->setWidget( frame );
226 myView->setAlignment( Qt::AlignCenter );
227 myView->setWidgetResizable( true );
229 myView->setMinimumWidth( frame->sizeHint().width() + MARGIN_SIZE * 2 );
231 /* OK/Cancel/Help buttons */
232 myOkBtn = new QPushButton( tr( "BUT_OK" ), this );
233 myOkBtn->setAutoDefault( TRUE );
234 myOkBtn->setDefault( TRUE );
235 myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this );
236 myCancelBtn->setAutoDefault( TRUE );
237 myHelpBtn = new QPushButton( tr( "BUT_HELP" ), this );
238 myHelpBtn->setAutoDefault( TRUE );
240 topLayout->addWidget( myView, 0, 0, 1, 4 );
241 topLayout->addWidget( myOkBtn, 1, 0 );
242 //topLayout->setColStretch( 1, 5 );
243 topLayout->addWidget( myCancelBtn, 1, 2 );
244 topLayout->addWidget( myHelpBtn, 1, 3 );
246 connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
247 connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
248 connect( myHelpBtn, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
252 /* Center widget inside it's parent widget */
253 resize( DLG_SIZE_WIDTH, DLG_SIZE_HEIGHT );
254 SUIT_Tools::centerWidget( this, parentWidget() );
259 VisuGUI_SetupPlot2dDlg::~VisuGUI_SetupPlot2dDlg()
263 Gets curves info ( indexes of row data in the table for horizontal and verical axes )
265 void VisuGUI_SetupPlot2dDlg::getCurvesSource( int& horIndex, QList<int>& verIndexes,
266 QList<int>& zIndices )
268 /* collecting horizontal and vertical axis items */
271 for ( i = 0; i < myItems.count(); i++ ) {
272 if ( myItems.at( i )->isHorizontalOn() ) {
275 else if ( myItems.at( i )->isVerticalOn() ) {
276 verIndexes.append( i );
277 zIndices.append( myItems.at( i )->assigned() );
283 Gets curve attributes
285 bool VisuGUI_SetupPlot2dDlg::getCurveAttributes( const int vIndex,
292 if ( vIndex >= 0 && vIndex < myItems.count() ) {
293 isAuto = myItems.at( vIndex )->isAutoAssign();
294 marker = myItems.at( vIndex )->getMarker();
295 line = myItems.at( vIndex )->getLine();
296 lineWidth = myItems.at( vIndex )->getLineWidth();
297 color = myItems.at( vIndex )->getColor();
303 Creates and returns curves presentations
305 void VisuGUI_SetupPlot2dDlg::getCurves( QList<Plot2d_Curve*>& container )
307 _PTR(GenericAttribute) anAttr;
308 _PTR(AttributeTableOfInteger) tblIntAttr;
309 _PTR(AttributeTableOfReal) tblRealAttr;
311 /* clearing container contents */
314 /* collecting horizontal and vertical axis items */
317 QList<int> verIndex, zIndices;
318 getCurvesSource( horIndex, verIndex, zIndices );
319 if ( horIndex < 0 || verIndex.isEmpty() ) /* no curves can be created */
322 /* Try table of integer */
323 if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) {
327 int nbCols = tblIntAttr->GetNbColumns() ;
328 vector<string> rowTitles = tblIntAttr->GetRowTitles();
329 vector<string> rowUnits = tblIntAttr->GetRowUnits();
331 for ( i = 0; i < verIndex.count(); i++ ) {
332 SPlot2d_Curve* curve = new SPlot2d_Curve();
334 if ( rowTitles.size() > 0 ) {
335 curve->setHorTitle( QString( rowTitles[ horIndex ].c_str() ) );
336 curve->setVerTitle( QString( rowTitles[ verIndex[i] ].c_str() ) );
339 if ( rowUnits.size() > 0 ) {
340 curve->setHorUnits( QString( rowUnits[ horIndex ].c_str() ) );
341 curve->setVerUnits( QString( rowUnits[ verIndex[i] ].c_str() ) );
345 for ( j = 1; j <= nbCols; j++ ) {
346 if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) )
349 if ( nbPoints > 0 ) {
350 double* xList = new double[ nbPoints ];
351 double* yList = new double[ nbPoints ];
353 for ( j = 1; j <= nbCols; j++ ) {
354 if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) ) {
355 xList[j-1] = tblIntAttr->GetValue( horIndex +1, j );
356 yList[j-1] = tblIntAttr->GetValue( verIndex[i]+1, j );
357 zList.append( QString( "%1" ).arg( tblIntAttr->GetValue( zIndices[i]+1, j ) ) );
360 curve->setData( xList, yList, nbPoints, zList );
363 curve->setLine( (Plot2d::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() );
364 curve->setMarker( (Plot2d::MarkerType)myItems.at( verIndex[i] )->getMarker() );
365 curve->setColor( myItems.at( verIndex[i] )->getColor() );
366 curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() );
367 // add curve into container
368 container.append( curve );
372 MESSAGE("VisuGUI_SetupPlot2dDlg::getCurves : Exception has been caught (int)!!!");
376 /* Try table of real */
377 else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
378 tblRealAttr = anAttr;
381 int nbCols = tblRealAttr->GetNbColumns() ;
382 vector<string> rowTitles = tblRealAttr->GetRowTitles();
383 vector<string> rowUnits = tblRealAttr->GetRowUnits();
385 for ( i = 0; i < verIndex.count(); i++ ) {
386 SPlot2d_Curve* curve = new SPlot2d_Curve();
388 if ( rowTitles.size() > 0 ) {
389 curve->setHorTitle( QString( rowTitles[ horIndex ].c_str() ) );
390 curve->setVerTitle( QString( rowTitles[ verIndex[i] ].c_str() ) );
393 if ( rowUnits.size() > 0 ) {
394 curve->setHorUnits( QString( rowUnits[ horIndex ].c_str() ) );
395 curve->setVerUnits( QString( rowUnits[ verIndex[i] ].c_str() ) );
399 for ( j = 1; j <= nbCols; j++ ) {
400 if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) )
403 if ( nbPoints > 0 ) {
404 double* xList = new double[ nbPoints ];
405 double* yList = new double[ nbPoints ];
407 for ( j = 1; j <= nbCols; j++ ) {
408 if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) ) {
409 xList[j-1] = tblRealAttr->GetValue( horIndex +1, j );
410 yList[j-1] = tblRealAttr->GetValue( verIndex[i]+1, j );
411 zList.append( QString( "%1" ).arg( tblIntAttr->GetValue( zIndices[i]+1, j ) ) );
414 curve->setData( xList, yList, nbPoints, zList );
417 curve->setLine( (Plot2d::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() );
418 curve->setMarker( (Plot2d::MarkerType)myItems.at( verIndex[i] )->getMarker() );
419 curve->setColor( myItems.at( verIndex[i] )->getColor() );
420 curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() );
421 // add curve into container
422 container.append( curve );
426 MESSAGE("VisuGUI_SetupPlot2dDlg::getCurves : Exception has been caught (real)!!!");
432 Slot, called when any <H> button is clicked
434 void VisuGUI_SetupPlot2dDlg::onHBtnToggled( bool on )
436 VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender();
438 for ( int i = 0; i < myItems.count(); i++ ) {
439 if ( myItems.at( i ) != item )
440 myItems.at( i )->setHorizontalOn( false );
446 Slot, called when any <V> button is clicked
448 void VisuGUI_SetupPlot2dDlg::onVBtnToggled( bool on )
450 VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender();
451 QList<VisuGUI_ItemContainer*> itemList;
452 //itemList.setAutoDelete( false );
453 item->myAssigned->setEnabled( on );
457 for ( i = 0; i < myItems.count(); i++ ) {
458 if ( myItems.at( i ) != item && !myItems.at( i )->isHorizontalOn() ) {
459 if ( myItems.at( i )->myUnitLab->text() == item->myUnitLab->text() ) {
460 if ( myItems.at( i )->isVerticalOn() )
463 itemList.append( myItems.at( i ) );
466 myItems.at( i )->setVerticalOn( false );
470 if ( totalOn == 0 && !itemList.isEmpty() &&
471 SUIT_MessageBox::information( this,
473 tr( "QUE_WANT_SAME_UNITS" ),
478 for ( i = 0; i < itemList.count(); i++ ) {
479 itemList.at( i )->blockSignals( true );
480 itemList.at( i )->setVerticalOn( true );
481 itemList.at( i )->blockSignals( false );
488 Slot, called when <Help> button is clicked
490 void VisuGUI_SetupPlot2dDlg::onHelp()
492 QString aHelpFileName = "creating_curves_page.html";
493 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
495 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
496 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
501 platform = "winapplication";
503 platform = "application";
505 SUIT_MessageBox::warning(0, tr("WRN_WARNING"),
506 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
507 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName),
512 Enables/disables buttons
514 void VisuGUI_SetupPlot2dDlg::enableControls()
518 for ( int i = 0; i < myItems.count(); i++ ) {
519 if ( myItems.at( i )->isHorizontalOn() ) {
525 for ( int i = 0; i < myItems.count(); i++ ) {
527 for ( i = 0; i < myItems.count(); i++ ) {
529 if ( myItems.at( i )->isVerticalOn() )
531 myItems.at( i )->enableWidgets( bHSet && myItems.at( i )->isVerticalOn() );
533 myOkBtn->setEnabled( bHSet && bVSet );
537 Provides help on F1 button click
539 void VisuGUI_SetupPlot2dDlg::keyPressEvent( QKeyEvent* e )
541 QDialog::keyPressEvent( e );
542 if ( e->isAccepted() )
545 if ( e->key() == Qt::Key_F1 )
552 // ====================================================================================
556 VisuGUI_ItemContainer::VisuGUI_ItemContainer( QObject* parent )
564 void VisuGUI_ItemContainer::createWidgets( QWidget* parentWidget, const QStringList& lst )
566 myHBtn = new QToolButton( parentWidget );
567 myHBtn->setText( tr( "H" ) );
568 myHBtn->setCheckable( true );
569 myHBtn->setChecked( false );
571 myVBtn = new QToolButton( parentWidget );
572 myVBtn->setText( tr( "V" ) );
573 myVBtn->setCheckable( true );
574 myVBtn->setChecked( false );
576 myTitleLab = new QLabel( parentWidget );
577 myUnitLab = new QLabel( parentWidget );
578 myUnitLab->setAlignment( Qt::AlignCenter);
580 myAutoCheck = new QCheckBox( tr( "AUTO_CHECK_LBL" ), parentWidget );
581 myAutoCheck->setChecked( true );
583 myLineCombo = new QComboBox( parentWidget );
584 myLineCombo->addItem( tr( "NONE_LINE_LBL" ) );
585 myLineCombo->addItem( tr( "SOLID_LINE_LBL" ) );
586 myLineCombo->addItem( tr( "DASH_LINE_LBL" ) );
587 myLineCombo->addItem( tr( "DOT_LINE_LBL" ) );
588 myLineCombo->addItem( tr( "DASHDOT_LINE_LBL" ) );
589 myLineCombo->addItem( tr( "DAHSDOTDOT_LINE_LBL" ) );
590 myLineCombo->setCurrentIndex( 1 ); // SOLID by default
592 myLineSpin = new QSpinBox( parentWidget );
593 myLineSpin->setMinimum( 0 );
594 myLineSpin->setMaximum( MAX_LINE_WIDTH );
595 myLineSpin->setSingleStep( 1 );
596 myLineSpin->setValue( 0 ); // width = 0 by default
598 myMarkerCombo = new QComboBox( parentWidget );
599 myMarkerCombo->addItem( tr( "NONE_MARKER_LBL" ) );
600 myMarkerCombo->addItem( tr( "CIRCLE_MARKER_LBL" ) );
601 myMarkerCombo->addItem( tr( "RECTANGLE_MARKER_LBL" ) );
602 myMarkerCombo->addItem( tr( "DIAMOND_MARKER_LBL" ) );
603 myMarkerCombo->addItem( tr( "DTRIANGLE_MARKER_LBL" ) );
604 myMarkerCombo->addItem( tr( "UTRIANGLE_MARKER_LBL" ) );
605 myMarkerCombo->addItem( tr( "LTRIANGLE_MARKER_LBL" ) );
606 myMarkerCombo->addItem( tr( "RTRIANGLE_MARKER_LBL" ) );
607 myMarkerCombo->addItem( tr( "CROSS_MARKER_LBL" ) );
608 myMarkerCombo->addItem( tr( "XCROSS_MARKER_LBL" ) );
609 myMarkerCombo->setCurrentIndex( 1 ); // CIRCLE by default
611 myColorBtn = new QtxColorButton( parentWidget );
612 myColorBtn->setMinimumWidth( 20 );
614 myAssigned = new QComboBox( parentWidget );
615 myAssigned->addItem( "" );
616 QStringList::const_iterator anIt = lst.begin(), aLast = lst.end();
617 for( ; anIt!=aLast; anIt++ )
618 myAssigned->addItem( *anIt );
619 myAssigned->setEnabled( false );
621 connect( myAutoCheck, SIGNAL( clicked() ), this, SLOT( onAutoChanged() ) );
622 //connect( myColorBtn, SIGNAL( clicked() ), this, SLOT( onColorChanged() ) );
623 connect( myHBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) );
624 connect( myVBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) );
625 setColor( QColor( 0, 0, 0 ) );
629 Enables attributes widgets
631 void VisuGUI_ItemContainer::enableWidgets( bool enable )
637 Sets horizontal button's state on
639 void VisuGUI_ItemContainer::setHorizontalOn( bool on )
641 myHBtn->setChecked( on );
644 Gets horizontal button's state
646 bool VisuGUI_ItemContainer::isHorizontalOn() const
648 return myHBtn->isChecked();
651 Sets vertical button's state on
653 void VisuGUI_ItemContainer::setVerticalOn( bool on )
655 myVBtn->setChecked( on );
658 Gets vertical button's state
660 bool VisuGUI_ItemContainer::isVerticalOn() const
662 return myVBtn->isChecked();
665 Sets item AutoAssign flag state
667 void VisuGUI_ItemContainer::setAutoAssign( bool on )
669 myAutoCheck->setChecked( on );
673 Gets item AutoAssign flag state
675 bool VisuGUI_ItemContainer::isAutoAssign() const
677 return myAutoCheck->isChecked();
680 Sets item line type and width
682 void VisuGUI_ItemContainer::setLine( const int line, const int width )
684 myLineCombo->setCurrentIndex( line );
689 int VisuGUI_ItemContainer::getLine() const
691 return myLineCombo->currentIndex();
696 int VisuGUI_ItemContainer::getLineWidth() const
698 return myLineSpin->value();
701 Sets item marker type
703 void VisuGUI_ItemContainer::setMarker( const int marker )
705 myMarkerCombo->setCurrentIndex( marker );
708 Gets item marker type
710 int VisuGUI_ItemContainer::getMarker() const
712 return myMarkerCombo->currentIndex();
718 void VisuGUI_ItemContainer::setColor( const QColor& color )
720 //QPalette pal = myColorBtn->palette();
721 //pal.setColor( myColorBtn->backgroundRole(), color );
722 myColorBtn->setColor( color );
727 QColor VisuGUI_ItemContainer::getColor() const
729 return myColorBtn->color();//palette().color( myColorBtn->backgroundRole() );
732 Enables/disables widgets
734 void VisuGUI_ItemContainer::updateState()
736 myAutoCheck->setEnabled( myEnabled );
737 myLineCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() );
738 myLineSpin->setEnabled( myEnabled && !myAutoCheck->isChecked() );
739 myMarkerCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() );
740 myColorBtn->setEnabled( myEnabled && !myAutoCheck->isChecked() );
743 Slot, called when user clickes <Auto assign> check box
745 void VisuGUI_ItemContainer::onAutoChanged()
748 emit( autoClicked() );
751 <Color> button slot, invokes color selection dialog box
753 /*void VisuGUI_ItemContainer::onColorChanged()
755 QColor color = QColorDialog::getColor( getColor() );
756 if ( color.isValid() ) {
761 <H> and <V> buttons slot
763 void VisuGUI_ItemContainer::onHVToggled( bool on )
765 const QObject* snd = sender();
766 if ( snd == myHBtn ) {
768 if ( myVBtn->isChecked() ) {
769 // blockSignals( true );
770 myVBtn->setChecked( false );
771 // blockSignals( false );
774 emit horToggled( on );
778 if ( myHBtn->isChecked() ) {
779 // blockSignals( true );
780 myHBtn->setChecked( false );
781 // blockSignals( false );
784 emit verToggled( on );
789 \return index of assigned row (0, if there is no assigned row)
791 int VisuGUI_ItemContainer::assigned() const
794 return myAssigned->currentIndex()-1;