1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : VisuGUI_SetupPlot2dDlg.cxx
21 // Author : Vadim SANDLER
25 #include "VisuGUI_SetupPlot2dDlg.h"
27 #include "SPlot2d_Curve.h"
29 #include "SUIT_Tools.h"
30 #include "SUIT_MessageBox.h"
31 #include "SUIT_ResourceMgr.h"
32 #include "SUIT_Session.h"
34 #include "LightApp_Application.h"
36 #include <SALOMEDSClient_AttributeTableOfInteger.hxx>
37 #include <SALOMEDSClient_AttributeTableOfReal.hxx>
40 #include <qpushbutton.h>
41 #include <qcheckbox.h>
42 #include <qtoolbutton.h>
43 #include <qcombobox.h>
44 #include <qscrollview.h>
46 #include <qcolordialog.h>
52 #include "utilities.h"
56 #define DLG_SIZE_WIDTH 500
57 #define DLG_SIZE_HEIGHT 400
58 #define MAX_LINE_WIDTH 100
59 #define MARGIN_SIZE 11
60 #define SPACING_SIZE 6
65 VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, QWidget* parent )
67 "VisuGUI_SetupPlot2dDlg",
69 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
71 setCaption( tr("TLT_SETUP_PLOT2D") );
72 setSizeGripEnabled( TRUE );
73 QGridLayout* topLayout = new QGridLayout( this );
74 topLayout->setSpacing( SPACING_SIZE );
75 topLayout->setMargin( MARGIN_SIZE );
77 myItems.setAutoDelete( false );
82 myView = new QScrollView( this );
83 QFrame* frame = new QFrame( myView );
84 frame->setFrameStyle( QFrame::Plain | QFrame::NoFrame );
85 QGridLayout* frameLayout = new QGridLayout( frame, 1, 12 );
86 frameLayout->setMargin( MARGIN_SIZE ); frameLayout->setSpacing( SPACING_SIZE );
90 QLabel* labAxis = new QLabel( tr( "AXIS_LBL" ), frame );
91 QLabel* labAssigned = new QLabel( tr( "ASSIGNED" ), frame );
92 QLabel* labData = new QLabel( tr( "DATA_LBL" ), frame );
93 QLabel* labUnit = new QLabel( tr( "UNITS_LBL" ), frame );
94 QLabel* labAttr = new QLabel( tr( "ATTRIBUTES_LBL" ), frame );
95 labAxis->setAlignment( AlignCenter );
96 labAssigned->setAlignment( AlignCenter );
97 labData->setAlignment( AlignCenter );
98 labUnit->setAlignment( AlignCenter );
99 labAttr->setAlignment( AlignCenter );
100 QFont font = labAxis->font(); font.setBold( true );
101 labAxis->setFont( font );
102 labAssigned->setFont( font );
103 labData->setFont( font );
104 labUnit->setFont( font );
105 labAttr->setFont( font );
107 frameLayout->addMultiCellWidget( labAxis, 0, 0, 0, 1 );
108 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
109 frameLayout->addWidget( lin, 0, 2 );
111 frameLayout->addWidget( labAssigned, 0, 3 );
112 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
113 frameLayout->addWidget( lin, 0, 4 );
115 frameLayout->addWidget( labData, 0, 5 );
116 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
117 frameLayout->addWidget( lin, 0, 6 );
118 frameLayout->addWidget( labUnit, 0, 7 );
119 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
120 frameLayout->addWidget( lin, 0, 8 );
121 frameLayout->addMultiCellWidget( labAttr, 0, 0, 9, 13 );
122 frameLayout->setColStretch( 14, 5 );
123 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::HLine | QFrame::Sunken );
124 frameLayout->addMultiCellWidget( lin, 1, 1, 0, 14 );
127 _PTR(GenericAttribute) anAttr;
128 _PTR(AttributeTableOfInteger) tblIntAttr;
129 _PTR(AttributeTableOfReal) tblRealAttr;
131 /* Try table of integer */
132 if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) {
136 int nbRows = tblIntAttr->GetNbRows() ;
137 vector<string> rowTitles = tblIntAttr->GetRowTitles();
138 vector<string> rowUnits = tblIntAttr->GetRowUnits();
140 for ( int i = 0; i < nbRows; i++ )
141 rows.append( rowTitles[i] );
143 for ( int i = 0; i < nbRows; i++ ) {
144 VisuGUI_ItemContainer* item = new VisuGUI_ItemContainer( this );
145 item->createWidgets( frame, rows );
146 frameLayout->addWidget( item->myHBtn, row, 0 );
147 frameLayout->addWidget( item->myVBtn, row, 1 );
148 frameLayout->addWidget( item->myAssigned, row, 3 );
150 frameLayout->addWidget( item->myTitleLab, row, 5 );
151 if ( rowTitles.size() > 0 )
152 item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) );
153 frameLayout->addWidget( item->myUnitLab, row, 7 );
154 if ( rowUnits.size() > 0 )
155 item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) );
156 frameLayout->addWidget( item->myAutoCheck, row, 9 );
157 frameLayout->addWidget( item->myLineCombo, row, 10 );
158 frameLayout->addWidget( item->myLineSpin, row, 11 );
159 frameLayout->addWidget( item->myMarkerCombo, row, 12 );
160 frameLayout->addWidget( item->myColorBtn, row, 13 );
161 connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
162 connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
163 myItems.append( item );
168 MESSAGE("VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg : Exception has been caught (int)!!!");
172 /* Try table of real */
173 else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
174 tblRealAttr = anAttr;
177 int nbRows = tblRealAttr->GetNbRows();
178 vector<string> rowTitles = tblRealAttr->GetRowTitles();
179 vector<string> rowUnits = tblRealAttr->GetRowUnits();
181 for ( int i = 0; i < nbRows; i++ )
182 rows.append( rowTitles[i] );
184 for ( int i = 0; i < nbRows; i++ ) {
185 VisuGUI_ItemContainer* item = new VisuGUI_ItemContainer( this );
186 item->createWidgets( frame, rows );
187 frameLayout->addWidget( item->myHBtn, row, 0 );
188 frameLayout->addWidget( item->myVBtn, row, 1 );
189 frameLayout->addWidget( item->myAssigned, row, 3 );
191 frameLayout->addWidget( item->myTitleLab, row, 5 );
192 if ( rowTitles.size() > 0 )
193 item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) );
194 frameLayout->addWidget( item->myUnitLab, row, 7 );
195 if ( rowUnits.size() > 0 )
196 item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) );
197 frameLayout->addWidget( item->myAutoCheck, row, 9 );
198 frameLayout->addWidget( item->myLineCombo, row, 10 );
199 frameLayout->addWidget( item->myLineSpin, row, 11 );
200 frameLayout->addWidget( item->myMarkerCombo, row, 12 );
201 frameLayout->addWidget( item->myColorBtn, row, 13 );
202 connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
203 connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
204 myItems.append( item );
209 MESSAGE("VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg : Exception has been caught (real)!!!");
213 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
214 frameLayout->addMultiCellWidget( lin, 2, row+1, 2, 2 );
215 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
216 frameLayout->addMultiCellWidget( lin, 2, row+1, 4, 4 );
217 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
218 frameLayout->addMultiCellWidget( lin, 2, row+1, 6, 6 );
219 frameLayout->setRowStretch( row+1, 5 );
221 myView->addChild( frame, 0, 0 );
222 myView->setResizePolicy( QScrollView::AutoOneFit );
224 myView->setMinimumWidth( frame->sizeHint().width() + MARGIN_SIZE * 2 );
226 /* OK/Cancel/Help buttons */
227 myOkBtn = new QPushButton( tr( "BUT_OK" ), this, "buttonOk" );
228 myOkBtn->setAutoDefault( TRUE );
229 myOkBtn->setDefault( TRUE );
230 myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this, "buttonCancel" );
231 myCancelBtn->setAutoDefault( TRUE );
232 myHelpBtn = new QPushButton( tr( "BUT_HELP" ), this, "buttonHelp" );
233 myHelpBtn->setAutoDefault( TRUE );
235 topLayout->addMultiCellWidget( myView, 0, 0, 0, 3 );
236 topLayout->addWidget( myOkBtn, 1, 0 );
237 topLayout->setColStretch( 1, 5 );
238 topLayout->addWidget( myCancelBtn, 1, 2 );
239 topLayout->addWidget( myHelpBtn, 1, 3 );
241 connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
242 connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
243 connect( myHelpBtn, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
247 /* Center widget inside it's parent widget */
248 resize( DLG_SIZE_WIDTH, DLG_SIZE_HEIGHT );
249 SUIT_Tools::centerWidget( this, parentWidget() );
254 VisuGUI_SetupPlot2dDlg::~VisuGUI_SetupPlot2dDlg()
258 Gets curves info ( indexes of row data in the table for horizontal and verical axes )
260 void VisuGUI_SetupPlot2dDlg::getCurvesSource( int& horIndex, QValueList<int>& verIndexes,
261 QValueList<int>& zIndices )
263 /* collecting horizontal and vertical axis items */
266 for ( i = 0; i < myItems.count(); i++ ) {
267 if ( myItems.at( i )->isHorizontalOn() ) {
270 else if ( myItems.at( i )->isVerticalOn() ) {
271 verIndexes.append( i );
272 zIndices.append( myItems.at( i )->assigned() );
278 Gets curve attributes
280 bool VisuGUI_SetupPlot2dDlg::getCurveAttributes (const int vIndex,
287 if ( vIndex >= 0 && vIndex < myItems.count() ) {
288 isAuto = myItems.at( vIndex )->isAutoAssign();
289 marker = myItems.at( vIndex )->getMarker();
290 line = myItems.at( vIndex )->getLine();
291 lineWidth = myItems.at( vIndex )->getLineWidth();
292 color = myItems.at( vIndex )->getColor();
298 Creates and returns curves presentations
300 void VisuGUI_SetupPlot2dDlg::getCurves( QPtrList<Plot2d_Curve>& container )
302 _PTR(GenericAttribute) anAttr;
303 _PTR(AttributeTableOfInteger) tblIntAttr;
304 _PTR(AttributeTableOfReal) tblRealAttr;
306 /* clearing container contents */
309 /* collecting horizontal and vertical axis items */
312 QValueList<int> verIndex, zIndices;
313 getCurvesSource( horIndex, verIndex, zIndices );
314 if ( horIndex < 0 || verIndex.isEmpty() ) /* no curves can be created */
317 /* Try table of integer */
318 if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) {
322 int nbCols = tblIntAttr->GetNbColumns();
323 vector<string> rowTitles = tblIntAttr->GetRowTitles();
324 vector<string> rowUnits = tblIntAttr->GetRowUnits();
326 for ( i = 0; i < verIndex.count(); i++ ) {
327 SPlot2d_Curve* curve = new SPlot2d_Curve();
329 if ( rowTitles.size() > 0 ) {
330 curve->setHorTitle( QString( rowTitles[ horIndex ].c_str() ) );
331 curve->setVerTitle( QString( rowTitles[ verIndex[i] ].c_str() ) );
334 if ( rowUnits.size() > 0 ) {
335 curve->setHorUnits( QString( rowUnits[ horIndex ].c_str() ) );
336 curve->setVerUnits( QString( rowUnits[ verIndex[i] ].c_str() ) );
340 for ( j = 1; j <= nbCols; j++ ) {
341 if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) )
344 if ( nbPoints > 0 ) {
345 double* xList = new double[ nbPoints ];
346 double* yList = new double[ nbPoints ];
348 for ( j = 1; j <= nbCols; j++ ) {
349 if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) ) {
350 xList[j-1] = tblIntAttr->GetValue( horIndex +1, j );
351 yList[j-1] = tblIntAttr->GetValue( verIndex[i]+1, j );
352 zList.append( QString( "%1" ).arg( tblIntAttr->GetValue( zIndices[i]+1, j ) ) );
355 curve->setData( xList, yList, nbPoints, zList );
358 curve->setLine( (Plot2d_Curve::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() );
359 curve->setMarker( (Plot2d_Curve::MarkerType)myItems.at( verIndex[i] )->getMarker() );
360 curve->setColor( myItems.at( verIndex[i] )->getColor() );
361 curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() );
362 // add curve into container
363 container.append( curve );
367 MESSAGE("VisuGUI_SetupPlot2dDlg::getCurves : Exception has been caught (int)!!!");
371 /* Try table of real */
372 else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
373 tblRealAttr = anAttr;
376 int nbCols = tblRealAttr->GetNbColumns();
377 vector<string> rowTitles = tblRealAttr->GetRowTitles();
378 vector<string> rowUnits = tblRealAttr->GetRowUnits();
380 for ( i = 0; i < verIndex.count(); i++ ) {
381 SPlot2d_Curve* curve = new SPlot2d_Curve();
383 if ( rowTitles.size() > 0 ) {
384 curve->setHorTitle( QString( rowTitles[ horIndex ].c_str() ) );
385 curve->setVerTitle( QString( rowTitles[ verIndex[i] ].c_str() ) );
388 if ( rowUnits.size() > 0 ) {
389 curve->setHorUnits( QString( rowUnits[ horIndex ].c_str() ) );
390 curve->setVerUnits( QString( rowUnits[ verIndex[i] ].c_str() ) );
394 for ( j = 1; j <= nbCols; j++ ) {
395 if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) )
398 if ( nbPoints > 0 ) {
399 double* xList = new double[ nbPoints ];
400 double* yList = new double[ nbPoints ];
402 for ( j = 1; j <= nbCols; j++ ) {
403 if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) ) {
404 xList[j-1] = tblRealAttr->GetValue( horIndex +1, j );
405 yList[j-1] = tblRealAttr->GetValue( verIndex[i]+1, j );
406 zList.append( QString( "%1" ).arg( tblIntAttr->GetValue( zIndices[i]+1, j ) ) );
409 curve->setData( xList, yList, nbPoints, zList );
412 curve->setLine( (Plot2d_Curve::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() );
413 curve->setMarker( (Plot2d_Curve::MarkerType)myItems.at( verIndex[i] )->getMarker() );
414 curve->setColor( myItems.at( verIndex[i] )->getColor() );
415 curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() );
416 // add curve into container
417 container.append( curve );
421 MESSAGE("VisuGUI_SetupPlot2dDlg::getCurves : Exception has been caught (real)!!!");
427 Slot, called when any <H> button is clicked
429 void VisuGUI_SetupPlot2dDlg::onHBtnToggled( bool on )
431 VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender();
433 for ( int i = 0; i < myItems.count(); i++ ) {
434 if ( myItems.at( i ) != item )
435 myItems.at( i )->setHorizontalOn( false );
441 Slot, called when any <V> button is clicked
443 void VisuGUI_SetupPlot2dDlg::onVBtnToggled( bool on )
445 VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender();
446 QPtrList<VisuGUI_ItemContainer> itemList;
447 itemList.setAutoDelete( false );
448 item->myAssigned->setEnabled( on );
452 for ( i = 0; i < myItems.count(); i++ ) {
453 if ( myItems.at( i ) != item && !myItems.at( i )->isHorizontalOn() ) {
454 if ( myItems.at( i )->myUnitLab->text() == item->myUnitLab->text() ) {
455 if ( myItems.at( i )->isVerticalOn() )
458 itemList.append( myItems.at( i ) );
461 myItems.at( i )->setVerticalOn( false );
465 if ( totalOn == 0 && !itemList.isEmpty() &&
466 SUIT_MessageBox::info2( this,
468 tr( "QUE_WANT_SAME_UNITS" ),
472 for ( i = 0; i < itemList.count(); i++ ) {
473 itemList.at( i )->blockSignals( true );
474 itemList.at( i )->setVerticalOn( true );
475 itemList.at( i )->blockSignals( false );
482 Slot, called when <Help> button is clicked
484 void VisuGUI_SetupPlot2dDlg::onHelp()
486 QString aHelpFileName = "plot2d_viewer_page.html";
487 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
489 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
490 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
495 platform = "winapplication";
497 platform = "application";
499 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
500 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
501 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName),
502 QObject::tr("BUT_OK"));
506 Enables/disables buttons
508 void VisuGUI_SetupPlot2dDlg::enableControls()
512 for ( int i = 0; i < myItems.count(); i++ ) {
513 if ( myItems.at( i )->isHorizontalOn() ) {
519 for ( int i = 0; i < myItems.count(); i++ ) {
521 for ( i = 0; i < myItems.count(); i++ ) {
523 if ( myItems.at( i )->isVerticalOn() )
525 myItems.at( i )->enableWidgets( bHSet && myItems.at( i )->isVerticalOn() );
527 myOkBtn->setEnabled( bHSet && bVSet );
531 Provides help on F1 button click
533 void VisuGUI_SetupPlot2dDlg::keyPressEvent( QKeyEvent* e )
535 QDialog::keyPressEvent( e );
536 if ( e->isAccepted() )
539 if ( e->key() == Key_F1 )
546 // ====================================================================================
550 VisuGUI_ItemContainer::VisuGUI_ItemContainer( QObject* parent, const char* name )
551 : QObject( parent, name ),
558 void VisuGUI_ItemContainer::createWidgets( QWidget* parentWidget, const QStringList& lst )
560 myHBtn = new QToolButton( parentWidget );
561 myHBtn->setText( tr( "H" ) );
562 myHBtn->setToggleButton( true );
563 myHBtn->setOn( false );
565 myVBtn = new QToolButton( parentWidget );
566 myVBtn->setText( tr( "V" ) );
567 myVBtn->setToggleButton( true );
568 myVBtn->setOn( false );
570 myTitleLab = new QLabel( parentWidget );
571 myUnitLab = new QLabel( parentWidget );
572 myUnitLab->setAlignment( AlignCenter);
574 myAutoCheck = new QCheckBox( tr( "AUTO_CHECK_LBL" ), parentWidget );
575 myAutoCheck->setChecked( true );
577 myLineCombo = new QComboBox( false, parentWidget );
578 myLineCombo->insertItem( tr( "NONE_LINE_LBL" ) );
579 myLineCombo->insertItem( tr( "SOLID_LINE_LBL" ) );
580 myLineCombo->insertItem( tr( "DASH_LINE_LBL" ) );
581 myLineCombo->insertItem( tr( "DOT_LINE_LBL" ) );
582 myLineCombo->insertItem( tr( "DASHDOT_LINE_LBL" ) );
583 myLineCombo->insertItem( tr( "DAHSDOTDOT_LINE_LBL" ) );
584 myLineCombo->setCurrentItem( 1 ); // SOLID by default
586 myLineSpin = new QSpinBox( 0, MAX_LINE_WIDTH, 1, parentWidget );
587 myLineSpin->setValue( 0 ); // width = 0 by default
589 myMarkerCombo = new QComboBox( false, parentWidget );
590 myMarkerCombo->insertItem( tr( "NONE_MARKER_LBL" ) );
591 myMarkerCombo->insertItem( tr( "CIRCLE_MARKER_LBL" ) );
592 myMarkerCombo->insertItem( tr( "RECTANGLE_MARKER_LBL" ) );
593 myMarkerCombo->insertItem( tr( "DIAMOND_MARKER_LBL" ) );
594 myMarkerCombo->insertItem( tr( "DTRIANGLE_MARKER_LBL" ) );
595 myMarkerCombo->insertItem( tr( "UTRIANGLE_MARKER_LBL" ) );
596 myMarkerCombo->insertItem( tr( "LTRIANGLE_MARKER_LBL" ) );
597 myMarkerCombo->insertItem( tr( "RTRIANGLE_MARKER_LBL" ) );
598 myMarkerCombo->insertItem( tr( "CROSS_MARKER_LBL" ) );
599 myMarkerCombo->insertItem( tr( "XCROSS_MARKER_LBL" ) );
600 myMarkerCombo->setCurrentItem( 1 ); // CIRCLE by default
602 myColorBtn = new QToolButton( parentWidget );
603 myColorBtn->setMinimumWidth( 20 );
605 myAssigned = new QComboBox( false, parentWidget );
606 myAssigned->insertItem( "" );
607 QStringList::const_iterator anIt = lst.begin(), aLast = lst.end();
608 for( ; anIt!=aLast; anIt++ )
609 myAssigned->insertItem( *anIt );
610 myAssigned->setEnabled( false );
612 connect( myAutoCheck, SIGNAL( clicked() ), this, SLOT( onAutoChanged() ) );
613 connect( myColorBtn, SIGNAL( clicked() ), this, SLOT( onColorChanged() ) );
614 connect( myHBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) );
615 connect( myVBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) );
616 setColor( QColor( 0, 0, 0 ) );
620 Enables attributes widgets
622 void VisuGUI_ItemContainer::enableWidgets( bool enable )
628 Sets horizontal button's state on
630 void VisuGUI_ItemContainer::setHorizontalOn( bool on )
635 Gets horizontal button's state
637 bool VisuGUI_ItemContainer::isHorizontalOn() const
639 return myHBtn->isOn();
642 Sets vertical button's state on
644 void VisuGUI_ItemContainer::setVerticalOn( bool on )
649 Gets vertical button's state
651 bool VisuGUI_ItemContainer::isVerticalOn() const
653 return myVBtn->isOn();
656 Sets item AutoAssign flag state
658 void VisuGUI_ItemContainer::setAutoAssign( bool on )
660 myAutoCheck->setChecked( on );
664 Gets item AutoAssign flag state
666 bool VisuGUI_ItemContainer::isAutoAssign() const
668 return myAutoCheck->isChecked();
671 Sets item line type and width
673 void VisuGUI_ItemContainer::setLine( const int line, const int width )
675 myLineCombo->setCurrentItem( line );
680 int VisuGUI_ItemContainer::getLine() const
682 return myLineCombo->currentItem();
687 int VisuGUI_ItemContainer::getLineWidth() const
689 return myLineSpin->value();
692 Sets item marker type
694 void VisuGUI_ItemContainer::setMarker( const int marker )
696 myMarkerCombo->setCurrentItem( marker );
699 Gets item marker type
701 int VisuGUI_ItemContainer::getMarker() const
703 return myMarkerCombo->currentItem();
708 void VisuGUI_ItemContainer::setColor( const QColor& color )
710 QPalette pal = myColorBtn->palette();
711 QColorGroup ca = pal.active();
712 ca.setColor( QColorGroup::Button, color );
713 QColorGroup ci = pal.inactive();
714 ci.setColor( QColorGroup::Button, color );
716 pal.setInactive( ci );
717 myColorBtn->setPalette( pal );
722 QColor VisuGUI_ItemContainer::getColor() const
724 return myColorBtn->palette().active().button();
727 Enables/disables widgets
729 void VisuGUI_ItemContainer::updateState()
731 myAutoCheck->setEnabled( myEnabled );
732 myLineCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() );
733 myLineSpin->setEnabled( myEnabled && !myAutoCheck->isChecked() );
734 myMarkerCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() );
735 myColorBtn->setEnabled( myEnabled && !myAutoCheck->isChecked() );
738 Slot, called when user clickes <Auto assign> check box
740 void VisuGUI_ItemContainer::onAutoChanged()
743 emit( autoClicked() );
746 <Color> button slot, invokes color selection dialog box
748 void VisuGUI_ItemContainer::onColorChanged()
750 QColor color = QColorDialog::getColor( getColor() );
751 if ( color.isValid() ) {
756 <H> and <V> buttons slot
758 void VisuGUI_ItemContainer::onHVToggled( bool on )
760 const QObject* snd = sender();
761 if ( snd == myHBtn ) {
763 if ( myVBtn->isOn() ) {
764 // blockSignals( true );
765 myVBtn->setOn( false );
766 // blockSignals( false );
769 emit horToggled( on );
773 if ( myHBtn->isOn() ) {
774 // blockSignals( true );
775 myHBtn->setOn( false );
776 // blockSignals( false );
779 emit verToggled( on );
784 \return index of assigned row (0, if there is no assigned row)
786 int VisuGUI_ItemContainer::assigned() const
788 if ( isVerticalOn() )
789 return myAssigned->currentItem()-1;