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* labData = new QLabel( tr( "DATA_LBL" ), frame );
92 QLabel* labUnit = new QLabel( tr( "UNITS_LBL" ), frame );
93 QLabel* labAttr = new QLabel( tr( "ATTRIBUTES_LBL" ), frame );
94 labAxis->setAlignment( AlignCenter );
95 labData->setAlignment( AlignCenter );
96 labUnit->setAlignment( AlignCenter );
97 labAttr->setAlignment( AlignCenter );
98 QFont font = labAxis->font(); font.setBold( true );
99 labAxis->setFont( font );
100 labData->setFont( font );
101 labUnit->setFont( font );
102 labAttr->setFont( font );
104 frameLayout->addMultiCellWidget( labAxis, 0, 0, 0, 1 );
105 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
106 frameLayout->addWidget( lin, 0, 2 );
107 frameLayout->addWidget( labData, 0, 3 );
108 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
109 frameLayout->addWidget( lin, 0, 4 );
110 frameLayout->addWidget( labUnit, 0, 5 );
111 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
112 frameLayout->addWidget( lin, 0, 6 );
113 frameLayout->addMultiCellWidget( labAttr, 0, 0, 7, 11 );
114 frameLayout->setColStretch( 12, 5 );
115 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::HLine | QFrame::Sunken );
116 frameLayout->addMultiCellWidget( lin, 1, 1, 0, 12 );
119 _PTR(GenericAttribute) anAttr;
120 _PTR(AttributeTableOfInteger) tblIntAttr;
121 _PTR(AttributeTableOfReal) tblRealAttr;
123 /* Try table of integer */
124 if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) {
128 int nbRows = tblIntAttr->GetNbRows() ;
129 vector<string> rowTitles = tblIntAttr->GetRowTitles();
130 vector<string> rowUnits = tblIntAttr->GetRowUnits();
131 for ( int i = 0; i < nbRows; i++ ) {
132 VisuGUI_ItemContainer* item = new VisuGUI_ItemContainer( this );
133 item->createWidgets( frame );
134 frameLayout->addWidget( item->myHBtn, row, 0 );
135 frameLayout->addWidget( item->myVBtn, row, 1 );
136 frameLayout->addWidget( item->myTitleLab, row, 3 );
137 if ( rowTitles.size() > 0 )
138 item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) );
139 frameLayout->addWidget( item->myUnitLab, row, 5 );
140 if ( rowUnits.size() > 0 )
141 item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) );
142 frameLayout->addWidget( item->myAutoCheck, row, 7 );
143 frameLayout->addWidget( item->myLineCombo, row, 8 );
144 frameLayout->addWidget( item->myLineSpin, row, 9 );
145 frameLayout->addWidget( item->myMarkerCombo, row, 10 );
146 frameLayout->addWidget( item->myColorBtn, row, 11 );
147 connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
148 connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
149 myItems.append( item );
154 MESSAGE("VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg : Exception has been caught (int)!!!");
158 /* Try table of real */
159 else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
160 tblRealAttr = anAttr;
163 int nbRows = tblRealAttr->GetNbRows() ;
164 vector<string> rowTitles = tblRealAttr->GetRowTitles();
165 vector<string> rowUnits = tblRealAttr->GetRowUnits();
166 for ( int i = 0; i < nbRows; i++ ) {
167 VisuGUI_ItemContainer* item = new VisuGUI_ItemContainer( this );
168 item->createWidgets( frame );
169 frameLayout->addWidget( item->myHBtn, row, 0 );
170 frameLayout->addWidget( item->myVBtn, row, 1 );
171 frameLayout->addWidget( item->myTitleLab, row, 3 );
172 if ( rowTitles.size() > 0 )
173 item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) );
174 frameLayout->addWidget( item->myUnitLab, row, 5 );
175 if ( rowUnits.size() > 0 )
176 item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) );
177 frameLayout->addWidget( item->myAutoCheck, row, 7 );
178 frameLayout->addWidget( item->myLineCombo, row, 8 );
179 frameLayout->addWidget( item->myLineSpin, row, 9 );
180 frameLayout->addWidget( item->myMarkerCombo, row, 10 );
181 frameLayout->addWidget( item->myColorBtn, row, 11 );
182 connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
183 connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
184 myItems.append( item );
189 MESSAGE("VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg : Exception has been caught (real)!!!");
193 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
194 frameLayout->addMultiCellWidget( lin, 2, row+1, 2, 2 );
195 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
196 frameLayout->addMultiCellWidget( lin, 2, row+1, 4, 4 );
197 lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
198 frameLayout->addMultiCellWidget( lin, 2, row+1, 6, 6 );
199 frameLayout->setRowStretch( row+1, 5 );
201 myView->addChild( frame, 0, 0 );
202 myView->setResizePolicy( QScrollView::AutoOneFit );
204 myView->setMinimumWidth( frame->sizeHint().width() + MARGIN_SIZE * 2 );
206 /* OK/Cancel/Help buttons */
207 myOkBtn = new QPushButton( tr( "BUT_OK" ), this, "buttonOk" );
208 myOkBtn->setAutoDefault( TRUE );
209 myOkBtn->setDefault( TRUE );
210 myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this, "buttonCancel" );
211 myCancelBtn->setAutoDefault( TRUE );
212 myHelpBtn = new QPushButton( tr( "BUT_HELP" ), this, "buttonHelp" );
213 myHelpBtn->setAutoDefault( TRUE );
215 topLayout->addMultiCellWidget( myView, 0, 0, 0, 3 );
216 topLayout->addWidget( myOkBtn, 1, 0 );
217 topLayout->setColStretch( 1, 5 );
218 topLayout->addWidget( myCancelBtn, 1, 2 );
219 topLayout->addWidget( myHelpBtn, 1, 3 );
221 connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
222 connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
223 connect( myHelpBtn, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
227 /* Center widget inside it's parent widget */
228 resize( DLG_SIZE_WIDTH, DLG_SIZE_HEIGHT );
229 SUIT_Tools::centerWidget( this, parentWidget() );
234 VisuGUI_SetupPlot2dDlg::~VisuGUI_SetupPlot2dDlg()
238 Gets curves info ( indexes of row data in the table for horizontal and verical axes )
240 void VisuGUI_SetupPlot2dDlg::getCurvesSource( int& horIndex, QValueList<int>& verIndexes )
242 /* collecting horizontal and vertical axis items */
245 for ( i = 0; i < myItems.count(); i++ ) {
246 if ( myItems.at( i )->isHorizontalOn() ) {
249 else if ( myItems.at( i )->isVerticalOn() ) {
250 verIndexes.append( i );
255 Gets curve attributes
257 bool VisuGUI_SetupPlot2dDlg::getCurveAttributes( const int vIndex,
264 if ( vIndex >= 0 && vIndex < myItems.count() ) {
265 isAuto = myItems.at( vIndex )->isAutoAssign();
266 marker = myItems.at( vIndex )->getMarker();
267 line = myItems.at( vIndex )->getLine();
268 lineWidth = myItems.at( vIndex )->getLineWidth();
269 color = myItems.at( vIndex )->getColor();
275 Creates and returns curves presentations
277 void VisuGUI_SetupPlot2dDlg::getCurves( QPtrList<Plot2d_Curve>& container )
279 _PTR(GenericAttribute) anAttr;
280 _PTR(AttributeTableOfInteger) tblIntAttr;
281 _PTR(AttributeTableOfReal) tblRealAttr;
283 /* clearing container contents */
286 /* collecting horizontal and vertical axis items */
289 QValueList<int> verIndex;
290 getCurvesSource( horIndex, verIndex );
291 if ( horIndex < 0 || verIndex.isEmpty() ) /* no curves can be created */
294 /* Try table of integer */
295 if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) {
299 int nbCols = tblIntAttr->GetNbColumns() ;
300 vector<string> rowTitles = tblIntAttr->GetRowTitles();
301 vector<string> rowUnits = tblIntAttr->GetRowUnits();
303 for ( i = 0; i < verIndex.count(); i++ ) {
304 SPlot2d_Curve* curve = new SPlot2d_Curve();
306 if ( rowTitles.size() > 0 ) {
307 curve->setHorTitle( QString( rowTitles[ horIndex ].c_str() ) );
308 curve->setVerTitle( QString( rowTitles[ verIndex[i] ].c_str() ) );
311 if ( rowUnits.size() > 0 ) {
312 curve->setHorUnits( QString( rowUnits[ horIndex ].c_str() ) );
313 curve->setVerUnits( QString( rowUnits[ verIndex[i] ].c_str() ) );
317 for ( j = 1; j <= nbCols; j++ ) {
318 if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) )
321 if ( nbPoints > 0 ) {
322 double* xList = new double[ nbPoints ];
323 double* yList = new double[ nbPoints ];
324 for ( j = 1; j <= nbCols; j++ ) {
325 if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) ) {
326 xList[j-1] = tblIntAttr->GetValue( horIndex +1, j );
327 yList[j-1] = tblIntAttr->GetValue( verIndex[i]+1, j );
330 curve->setData( xList, yList, nbPoints );
333 curve->setLine( (Plot2d_Curve::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() );
334 curve->setMarker( (Plot2d_Curve::MarkerType)myItems.at( verIndex[i] )->getMarker() );
335 curve->setColor( myItems.at( verIndex[i] )->getColor() );
336 curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() );
337 // add curve into container
338 container.append( curve );
342 MESSAGE("VisuGUI_SetupPlot2dDlg::getCurves : Exception has been caught (int)!!!");
346 /* Try table of real */
347 else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
348 tblRealAttr = anAttr;
351 int nbCols = tblRealAttr->GetNbColumns() ;
352 vector<string> rowTitles = tblRealAttr->GetRowTitles();
353 vector<string> rowUnits = tblRealAttr->GetRowUnits();
355 for ( i = 0; i < verIndex.count(); i++ ) {
356 SPlot2d_Curve* curve = new SPlot2d_Curve();
358 if ( rowTitles.size() > 0 ) {
359 curve->setHorTitle( QString( rowTitles[ horIndex ].c_str() ) );
360 curve->setVerTitle( QString( rowTitles[ verIndex[i] ].c_str() ) );
363 if ( rowUnits.size() > 0 ) {
364 curve->setHorUnits( QString( rowUnits[ horIndex ].c_str() ) );
365 curve->setVerUnits( QString( rowUnits[ verIndex[i] ].c_str() ) );
369 for ( j = 1; j <= nbCols; j++ ) {
370 if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) )
373 if ( nbPoints > 0 ) {
374 double* xList = new double[ nbPoints ];
375 double* yList = new double[ nbPoints ];
376 for ( j = 1; j <= nbCols; j++ ) {
377 if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) ) {
378 xList[j-1] = tblRealAttr->GetValue( horIndex +1, j );
379 yList[j-1] = tblRealAttr->GetValue( verIndex[i]+1, j );
382 curve->setData( xList, yList, nbPoints );
385 curve->setLine( (Plot2d_Curve::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() );
386 curve->setMarker( (Plot2d_Curve::MarkerType)myItems.at( verIndex[i] )->getMarker() );
387 curve->setColor( myItems.at( verIndex[i] )->getColor() );
388 curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() );
389 // add curve into container
390 container.append( curve );
394 MESSAGE("VisuGUI_SetupPlot2dDlg::getCurves : Exception has been caught (real)!!!");
400 Slot, called when any <H> button is clicked
402 void VisuGUI_SetupPlot2dDlg::onHBtnToggled( bool on )
404 VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender();
406 for ( int i = 0; i < myItems.count(); i++ ) {
407 if ( myItems.at( i ) != item )
408 myItems.at( i )->setHorizontalOn( false );
414 Slot, called when any <V> button is clicked
416 void VisuGUI_SetupPlot2dDlg::onVBtnToggled( bool on )
418 VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender();
419 QPtrList<VisuGUI_ItemContainer> itemList;
420 itemList.setAutoDelete( false );
424 for ( i = 0; i < myItems.count(); i++ ) {
425 if ( myItems.at( i ) != item && !myItems.at( i )->isHorizontalOn() ) {
426 if ( myItems.at( i )->myUnitLab->text() == item->myUnitLab->text() ) {
427 if ( myItems.at( i )->isVerticalOn() )
430 itemList.append( myItems.at( i ) );
433 myItems.at( i )->setVerticalOn( false );
437 if ( totalOn == 0 && !itemList.isEmpty() &&
438 SUIT_MessageBox::info2( this,
440 tr( "QUE_WANT_SAME_UNITS" ),
444 for ( i = 0; i < itemList.count(); i++ ) {
445 itemList.at( i )->blockSignals( true );
446 itemList.at( i )->setVerticalOn( true );
447 itemList.at( i )->blockSignals( false );
454 Slot, called when <Help> button is clicked
456 void VisuGUI_SetupPlot2dDlg::onHelp()
458 QString aHelpFileName = "/files/creating_curves.htm";
459 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
461 VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
462 app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
465 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
466 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
467 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
468 QObject::tr("BUT_OK"));
472 Enables/disables buttons
474 void VisuGUI_SetupPlot2dDlg::enableControls()
478 for ( int i = 0; i < myItems.count(); i++ ) {
479 if ( myItems.at( i )->isHorizontalOn() ) {
485 for ( int i = 0; i < myItems.count(); i++ ) {
487 for ( i = 0; i < myItems.count(); i++ ) {
489 if ( myItems.at( i )->isVerticalOn() )
491 myItems.at( i )->enableWidgets( bHSet && myItems.at( i )->isVerticalOn() );
493 myOkBtn->setEnabled( bHSet && bVSet );
496 // ====================================================================================
500 VisuGUI_ItemContainer::VisuGUI_ItemContainer( QObject* parent, const char* name )
501 : QObject( parent, name ),
508 void VisuGUI_ItemContainer::createWidgets( QWidget* parentWidget )
510 myHBtn = new QToolButton( parentWidget );
511 myHBtn->setText( tr( "H" ) );
512 myHBtn->setToggleButton( true );
513 myHBtn->setOn( false );
515 myVBtn = new QToolButton( parentWidget );
516 myVBtn->setText( tr( "V" ) );
517 myVBtn->setToggleButton( true );
518 myVBtn->setOn( false );
520 myTitleLab = new QLabel( parentWidget );
521 myUnitLab = new QLabel( parentWidget );
522 myUnitLab->setAlignment( AlignCenter);
524 myAutoCheck = new QCheckBox( tr( "AUTO_CHECK_LBL" ), parentWidget );
525 myAutoCheck->setChecked( true );
527 myLineCombo = new QComboBox( false, parentWidget );
528 myLineCombo->insertItem( tr( "NONE_LINE_LBL" ) );
529 myLineCombo->insertItem( tr( "SOLID_LINE_LBL" ) );
530 myLineCombo->insertItem( tr( "DASH_LINE_LBL" ) );
531 myLineCombo->insertItem( tr( "DOT_LINE_LBL" ) );
532 myLineCombo->insertItem( tr( "DASHDOT_LINE_LBL" ) );
533 myLineCombo->insertItem( tr( "DAHSDOTDOT_LINE_LBL" ) );
534 myLineCombo->setCurrentItem( 1 ); // SOLID by default
536 myLineSpin = new QSpinBox( 0, MAX_LINE_WIDTH, 1, parentWidget );
537 myLineSpin->setValue( 0 ); // width = 0 by default
539 myMarkerCombo = new QComboBox( false, parentWidget );
540 myMarkerCombo->insertItem( tr( "NONE_MARKER_LBL" ) );
541 myMarkerCombo->insertItem( tr( "CIRCLE_MARKER_LBL" ) );
542 myMarkerCombo->insertItem( tr( "RECTANGLE_MARKER_LBL" ) );
543 myMarkerCombo->insertItem( tr( "DIAMOND_MARKER_LBL" ) );
544 myMarkerCombo->insertItem( tr( "DTRIANGLE_MARKER_LBL" ) );
545 myMarkerCombo->insertItem( tr( "UTRIANGLE_MARKER_LBL" ) );
546 myMarkerCombo->insertItem( tr( "LTRIANGLE_MARKER_LBL" ) );
547 myMarkerCombo->insertItem( tr( "RTRIANGLE_MARKER_LBL" ) );
548 myMarkerCombo->insertItem( tr( "CROSS_MARKER_LBL" ) );
549 myMarkerCombo->insertItem( tr( "XCROSS_MARKER_LBL" ) );
550 myMarkerCombo->setCurrentItem( 1 ); // CIRCLE by default
552 myColorBtn = new QToolButton( parentWidget );
553 myColorBtn->setMinimumWidth( 20 );
555 connect( myAutoCheck, SIGNAL( clicked() ), this, SLOT( onAutoChanged() ) );
556 connect( myColorBtn, SIGNAL( clicked() ), this, SLOT( onColorChanged() ) );
557 connect( myHBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) );
558 connect( myVBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) );
559 setColor( QColor( 0, 0, 0 ) );
563 Enables attributes widgets
565 void VisuGUI_ItemContainer::enableWidgets( bool enable )
571 Sets horizontal button's state on
573 void VisuGUI_ItemContainer::setHorizontalOn( bool on )
578 Gets horizontal button's state
580 bool VisuGUI_ItemContainer::isHorizontalOn() const
582 return myHBtn->isOn();
585 Sets vertical button's state on
587 void VisuGUI_ItemContainer::setVerticalOn( bool on )
592 Gets vertical button's state
594 bool VisuGUI_ItemContainer::isVerticalOn() const
596 return myVBtn->isOn();
599 Sets item AutoAssign flag state
601 void VisuGUI_ItemContainer::setAutoAssign( bool on )
603 myAutoCheck->setChecked( on );
607 Gets item AutoAssign flag state
609 bool VisuGUI_ItemContainer::isAutoAssign() const
611 return myAutoCheck->isChecked();
614 Sets item line type and width
616 void VisuGUI_ItemContainer::setLine( const int line, const int width )
618 myLineCombo->setCurrentItem( line );
623 int VisuGUI_ItemContainer::getLine() const
625 return myLineCombo->currentItem();
630 int VisuGUI_ItemContainer::getLineWidth() const
632 return myLineSpin->value();
635 Sets item marker type
637 void VisuGUI_ItemContainer::setMarker( const int marker )
639 myMarkerCombo->setCurrentItem( marker );
642 Gets item marker type
644 int VisuGUI_ItemContainer::getMarker() const
646 return myMarkerCombo->currentItem();
651 void VisuGUI_ItemContainer::setColor( const QColor& color )
653 QPalette pal = myColorBtn->palette();
654 QColorGroup ca = pal.active();
655 ca.setColor( QColorGroup::Button, color );
656 QColorGroup ci = pal.inactive();
657 ci.setColor( QColorGroup::Button, color );
659 pal.setInactive( ci );
660 myColorBtn->setPalette( pal );
665 QColor VisuGUI_ItemContainer::getColor() const
667 return myColorBtn->palette().active().button();
670 Enables/disables widgets
672 void VisuGUI_ItemContainer::updateState()
674 myAutoCheck->setEnabled( myEnabled );
675 myLineCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() );
676 myLineSpin->setEnabled( myEnabled && !myAutoCheck->isChecked() );
677 myMarkerCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() );
678 myColorBtn->setEnabled( myEnabled && !myAutoCheck->isChecked() );
681 Slot, called when user clickes <Auto assign> check box
683 void VisuGUI_ItemContainer::onAutoChanged()
686 emit( autoClicked() );
689 <Color> button slot, invokes color selection dialog box
691 void VisuGUI_ItemContainer::onColorChanged()
693 QColor color = QColorDialog::getColor( getColor() );
694 if ( color.isValid() ) {
699 <H> and <V> buttons slot
701 void VisuGUI_ItemContainer::onHVToggled( bool on )
703 const QObject* snd = sender();
704 if ( snd == myHBtn ) {
706 if ( myVBtn->isOn() ) {
707 // blockSignals( true );
708 myVBtn->setOn( false );
709 // blockSignals( false );
712 emit horToggled( on );
716 if ( myHBtn->isOn() ) {
717 // blockSignals( true );
718 myHBtn->setOn( false );
719 // blockSignals( false );
722 emit verToggled( on );