-// VISU VISUGUI : GUI of VISU component
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+// VISU VISUGUI : GUI of VISU component
// File : VisuGUI_VectorsDlg.cxx
// Author : Laurent CORNABE & Hubert ROLLAND
// Module : VISU
// $Header$
-
+//
#include "VisuGUI_VectorsDlg.h"
#include "VisuGUI.h"
-//#include "VisuGUI_Selection.h"
#include "VisuGUI_Tools.h"
+#include "VisuGUI_InputPane.h"
+#include "VISU_ColoredPrs3dFactory.hh"
#include "VISU_Vectors_i.hh"
#include "LightApp_Application.h"
#include "SalomeApp_Module.h"
#include "SUIT_ResourceMgr.h"
#include "SUIT_Session.h"
-#include <qlayout.h>
-#include <qcolordialog.h>
-#include <qtabwidget.h>
+#include <QtxColorButton.h>
+
+#include <QLayout>
+#include <QColorDialog>
+#include <QTabWidget>
+#include <QButtonGroup>
+#include <QGroupBox>
+#include <QRadioButton>
+#include <QCheckBox>
+#include <QLabel>
+#include <QSpinBox>
+#include <QPushButton>
+#include <QKeyEvent>
+
+#include <limits>
using namespace std;
Constructor
*/
VisuGUI_VectorsDlg::VisuGUI_VectorsDlg (SalomeApp_Module* theModule)
- : QDialog(VISU::GetDesktop(theModule), "VisuGUI_VectorsDlg", true,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+ : VisuGUI_ScalarBarBaseDlg(theModule)
{
- setCaption(tr("DLG_TITLE"));
+ setWindowTitle(tr("DLG_TITLE"));
setSizeGripEnabled(TRUE);
QVBoxLayout* TopLayout = new QVBoxLayout( this );
TopLayout->setSpacing( 6 );
TopLayout->setMargin( 11 );
- QTabWidget* aTabBox = new QTabWidget(this);
+ myTabBox = new QTabWidget(this);
- QVBox* aBox = new QVBox(this);
- aBox->setMargin( 11 );
+ QWidget* aBox = new QWidget(this);
+ QVBoxLayout* aVBLay = new QVBoxLayout( aBox );
+ aVBLay->setMargin( 11 );
- TopGroup = new QButtonGroup( aBox, "TopGroup" );
- TopGroup->setColumnLayout(0, Qt::Vertical );
- TopGroup->layout()->setSpacing( 0 );
- TopGroup->layout()->setMargin( 5 );
- QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
+ TopGroup = new QGroupBox( aBox );
+ aVBLay->addWidget( TopGroup );
+ //TopGroup->setColumnLayout(0, Qt::Vertical );
+ //TopGroup->layout()->setSpacing( 0 );
+ //TopGroup->layout()->setMargin( 5 );
+ QGridLayout* TopGroupLayout = new QGridLayout( TopGroup );
TopGroupLayout->setAlignment( Qt::AlignTop );
TopGroupLayout->setSpacing( 6 );
TopGroupLayout->setMargin( 11 );
// Scale factor
- ScaleLabel = new QLabel (tr("LBL_SCALE_FACTOR"), TopGroup, "ScaleLabel");
+ ScaleLabel = new QLabel (tr("LBL_SCALE_FACTOR"), TopGroup );
+
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+ int aPrecision = aResourceMgr->integerValue( "VISU", "floating_point_precision", 0 );
- ScalFact = new QtxDblSpinBox( 1e-20, 1.0E+38, 0.1, TopGroup );
- ScalFact->setPrecision( 5 );
+ ScalFact = new QtxDoubleSpinBox( 0, 1.0E+38, 0.1, aPrecision*(-1), 32, TopGroup );
ScalFact->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
ScalFact->setValue( 0.1 );
TopGroupLayout->addWidget( ScalFact, 0, 1 );
// Line width
- LineWidLabel = new QLabel (tr("LBL_LINE_WIDTH"), TopGroup, "LineWidLabel");
+ LineWidLabel = new QLabel (tr("LBL_LINE_WIDTH"), TopGroup );
- LinWid = new QSpinBox( 1, 10, 1, TopGroup, "LinWid" );
+ LinWid = new QSpinBox( TopGroup );
+ LinWid->setMinimum( 1 );
+ LinWid->setMaximum( 10 );
+ LinWid->setSingleStep( 1 );
+
LinWid->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
LinWid->setValue( 1 );
TopGroupLayout->addWidget( LinWid, 1, 1 );
// Color
- UseMagn = new QCheckBox (tr("MAGNITUDE_COLORING_CHK"), TopGroup, "UseMagn");
+ UseMagn = new QCheckBox (tr("MAGNITUDE_COLORING_CHK"), TopGroup);
//UseMagn->setText(tr("MAGNITUDE_COLORING_CHK"));
- SelColor = new QPushButton (tr("SEL_COLOR_BTN"), TopGroup, "SelColor");
+ SelColor = new QtxColorButton (TopGroup);
+ SelColor->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ SelColor->setText( tr("SEL_COLOR_BTN") );
/* ColorLab = new QLabel( TopGroup, "ColorLab" );
ColorLab->setFixedSize( SelColor->sizeHint().height(), SelColor->sizeHint().height() );
TopGroupLayout->addWidget( SelColor, 2, 1 );
// Gliphs
- UseGlyph = new QCheckBox (tr("USE_GLYPHS_CHK"), TopGroup, "UseGlyph");
+ UseGlyph = new QCheckBox (tr("USE_GLYPHS_CHK"), TopGroup);
- TypeGlyph = new QButtonGroup (tr("GLYPH_TYPE_GRP"), TopGroup, "TypeGlyph");
- TypeGlyph->setColumnLayout(0, Qt::Vertical );
- TypeGlyph->layout()->setSpacing( 0 );
- TypeGlyph->layout()->setMargin( 0 );
- QGridLayout* TypeGlyphLayout = new QGridLayout( TypeGlyph->layout() );
+ TypeGlyph = new QButtonGroup ( TopGroup);
+ TypeGB = new QGroupBox( tr("GLYPH_TYPE_GRP"), TopGroup );
+ //TypeGlyph->setColumnLayout(0, Qt::Vertical );
+ //TypeGlyph->layout()->setSpacing( 0 );
+ //TypeGlyph->layout()->setMargin( 0 );
+ QGridLayout* TypeGlyphLayout = new QGridLayout( TypeGB );
TypeGlyphLayout->setAlignment( Qt::AlignTop );
TypeGlyphLayout->setSpacing( 6 );
TypeGlyphLayout->setMargin( 11 );
- RBArrows = new QRadioButton (tr("ARROWS_BTN") , TypeGlyph, "RBArrows");
+ RBArrows = new QRadioButton (tr("ARROWS_BTN"), TypeGB );
TypeGlyphLayout->addWidget( RBArrows, 0, 0 );
- RBCones2 = new QRadioButton (tr("CONES2_BTN"), TypeGlyph, "RBCones2");
+ RBCones2 = new QRadioButton (tr("CONES2_BTN"), TypeGB );
TypeGlyphLayout->addWidget( RBCones2, 1, 0 );
- RBCones6 = new QRadioButton (tr("CONES6_BTN"), TypeGlyph, "RBCones6");
+ RBCones6 = new QRadioButton (tr("CONES6_BTN"), TypeGB );
TypeGlyphLayout->addWidget( RBCones6, 2, 0 );
- PosGlyph = new QButtonGroup (tr("GLYPH_POSITION_GRP"), TopGroup, "PosGlyph");
- PosGlyph->setColumnLayout(0, Qt::Vertical );
- PosGlyph->layout()->setSpacing( 0 );
- PosGlyph->layout()->setMargin( 0 );
- QGridLayout* PosGlyphLayout = new QGridLayout( PosGlyph->layout() );
+ TypeGlyph->addButton( RBArrows );
+ TypeGlyph->addButton( RBCones2 );
+ TypeGlyph->addButton( RBCones6 );
+
+ PosGlyph = new QButtonGroup ( TopGroup );
+ PosGB = new QGroupBox( tr("GLYPH_POSITION_GRP"), TopGroup );
+ //PosGlyph->setColumnLayout(0, Qt::Vertical );
+ //PosGlyph->layout()->setSpacing( 0 );
+ //PosGlyph->layout()->setMargin( 0 );
+ QGridLayout* PosGlyphLayout = new QGridLayout( PosGB );
PosGlyphLayout->setAlignment( Qt::AlignTop );
PosGlyphLayout->setSpacing( 6 );
PosGlyphLayout->setMargin( 11 );
- RBTail = new QRadioButton (tr("TAIL_BTN" ), PosGlyph, "RBTail");
+ RBTail = new QRadioButton (tr("TAIL_BTN" ), PosGB );
PosGlyphLayout->addWidget( RBTail, 0, 0 );
- RBCent = new QRadioButton (tr("CENTER_BTN"), PosGlyph, "RBCent");
+ RBCent = new QRadioButton (tr("CENTER_BTN"), PosGB );
PosGlyphLayout->addWidget( RBCent, 1, 0 );
- RBHead = new QRadioButton (tr("HEAD_BTN" ), PosGlyph, "RBHead");
+ RBHead = new QRadioButton (tr("HEAD_BTN" ), PosGB );
PosGlyphLayout->addWidget( RBHead, 2, 0 );
- TopGroupLayout->addMultiCellWidget( UseGlyph, 3, 3, 0, 2 );
- TopGroupLayout->addWidget( TypeGlyph, 4, 0 );
- TopGroupLayout->addMultiCellWidget( PosGlyph, 4, 4, 1, 2 );
+ PosGlyph->addButton( RBTail );
+ PosGlyph->addButton( RBCent );
+ PosGlyph->addButton( RBHead );
+
+ TopGroupLayout->addWidget( UseGlyph, 3, 0, 1, 3 );
+ TopGroupLayout->addWidget( TypeGB, 4, 0 );
+ TopGroupLayout->addWidget( PosGB, 4, 1, 1, 2 );
// Common buttons ===========================================================
- GroupButtons = new QGroupBox( this, "GroupButtons" );
- GroupButtons->setColumnLayout(0, Qt::Vertical );
- GroupButtons->layout()->setSpacing( 0 );
- GroupButtons->layout()->setMargin( 0 );
- QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+ GroupButtons = new QGroupBox( this );
+ //GroupButtons->setColumnLayout(0, Qt::Vertical );
+ //GroupButtons->layout()->setSpacing( 0 );
+ //GroupButtons->layout()->setMargin( 0 );
+ QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
- buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
+ buttonOk = new QPushButton( tr( "BUT_OK" ), GroupButtons );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
- buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
+ buttonCancel = new QPushButton( tr( "BUT_CANCEL" ) , GroupButtons );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
- buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
+ buttonHelp = new QPushButton( tr( "BUT_HELP" ) , GroupButtons );
buttonHelp->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
// top layout
- aTabBox->addTab(aBox, "Vectors");
- myScalarPane = new VisuGUI_ScalarBarPane(this, false);
- myScalarPane->setMargin( 5 );
- aTabBox->addTab(myScalarPane, "Scalar Bar");
+ myTabBox->addTab(aBox, "Vectors");
+ myInputPane = new VisuGUI_InputPane(VISU::TVECTORS, theModule, this);
+ myTabBox->addTab(GetScalarPane(), "Scalar Bar");
+ myTabBox->addTab(myInputPane, "Input");
- TopLayout->addWidget( aTabBox );
+ TopLayout->addWidget( myTabBox );
TopLayout->addWidget( GroupButtons );
// signals and slots connections
connect( UseGlyph, SIGNAL( clicked() ), this, SLOT( enableGlyphType() ) );
- connect( SelColor, SIGNAL( clicked() ), this, SLOT( setVColor() ) );
+ //connect( SelColor, SIGNAL( clicked() ), this, SLOT( setVColor() ) );
connect( UseMagn, SIGNAL( clicked() ), this, SLOT( enableSetColor() ) );
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
enableSetColor();
}
+VisuGUI_VectorsDlg::~VisuGUI_VectorsDlg()
+{}
+
+void VisuGUI_VectorsDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
+ bool theInit )
+{
+ if ( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TVECTORS>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
+ VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit);
-void VisuGUI_VectorsDlg::initFromPrsObject(VISU::Vectors_i* thePrs) {
- myScalarPane->initFromPrsObject(thePrs);
- setScaleFactor(thePrs->GetScale());
- setLineWidth((int)thePrs->GetLineWidth());
- setUseMagnColor(thePrs->IsColored());
- SALOMEDS::Color anOldColor = thePrs->GetColor();
+ setScaleFactor(myPrsCopy->GetScale());
+ setLineWidth((int)myPrsCopy->GetLineWidth());
+ setUseMagnColor(myPrsCopy->IsColored());
+ SALOMEDS::Color anOldColor = myPrsCopy->GetColor();
QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
setColor(aColor);
- if (thePrs->GetGlyphType() != VISU::Vectors::NONE) {
+ if (myPrsCopy->GetGlyphType() != VISU::Vectors::NONE) {
setUseGlyphs(true);
- setGlyphType(thePrs->GetGlyphType());
- setGlyphPos(thePrs->GetGlyphPos());
+ setGlyphType(myPrsCopy->GetGlyphType());
+ setGlyphPos(myPrsCopy->GetGlyphPos());
} else
setUseGlyphs(false);
enableSetColor();
+
+ if( !theInit )
+ return;
+
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->setCurrentIndex( 0 );
}
-int VisuGUI_VectorsDlg::storeToPrsObject(VISU::Vectors_i* thePrs) {
- myScalarPane->storeToPrsObject(thePrs);
- thePrs->SetScale(getScaleFactor());
- thePrs->SetLineWidth(getLineWidth());
- thePrs->ShowColored(getUseMagnColor());
- if(!thePrs->IsColored()){
+int VisuGUI_VectorsDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
+{
+ if(!myInputPane->check() || !GetScalarPane()->check())
+ return 0;
+
+ int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= GetScalarPane()->storeToPrsObject( myPrsCopy );
+
+ myPrsCopy->SetScale(getScaleFactor());
+ myPrsCopy->SetLineWidth(getLineWidth());
+ myPrsCopy->ShowColored(getUseMagnColor());
+ if(!myPrsCopy->IsColored()){
+ QColor aSelectedColor = SelColor->color();
SALOMEDS::Color aColor;
- aColor.R = myColor.red()/255.;
- aColor.G = myColor.green()/255.;
- aColor.B = myColor.blue()/255.;
- thePrs->SetColor(aColor);
+ aColor.R = aSelectedColor.red()/255.;
+ aColor.G = aSelectedColor.green()/255.;
+ aColor.B = aSelectedColor.blue()/255.;
+ myPrsCopy->SetColor(aColor);
}
if (getUseGlyphs()) {
- thePrs->SetGlyphPos(getGlyphPos());
- thePrs->SetGlyphType(getGlyphType());
+ myPrsCopy->SetGlyphPos(getGlyphPos());
+ myPrsCopy->SetGlyphType(getGlyphType());
} else
- thePrs->SetGlyphType(VISU::Vectors::NONE);
- return 1;
+ myPrsCopy->SetGlyphType(VISU::Vectors::NONE);
+
+ VISU::TSameAsFactory<VISU::TVECTORS>().Copy(myPrsCopy, thePrs);
+
+ return anIsOk;
}
*/
void VisuGUI_VectorsDlg::enableGlyphType()
{
- TypeGlyph->setEnabled( UseGlyph->isChecked() );
- PosGlyph->setEnabled( UseGlyph->isChecked() );
+ TypeGB->setEnabled( UseGlyph->isChecked() );
+ PosGB->setEnabled( UseGlyph->isChecked() );
}
/*!
/*!
Called when "Select Color" buttonx clicked
*/
-void VisuGUI_VectorsDlg::setVColor()
+/*void VisuGUI_VectorsDlg::setVColor()
{
QColor cnew = QColorDialog::getColor( myColor, this );
if ( cnew.isValid() )
setColor( cnew );
-}
+}*/
/*!
Sets Scale factor
*/
-void VisuGUI_VectorsDlg::setScaleFactor( double sf )
+void VisuGUI_VectorsDlg::setScaleFactor(double theFactor)
{
- ScalFact->setValue( sf );
+ double step = 0.1;
+ if (fabs(theFactor) > std::numeric_limits<double>::epsilon()) {
+ int degree = int(log10(fabs(theFactor))) - 1;
+ if (fabs(theFactor) < 1) {
+ // as logarithm value is negative in this case
+ // and it is truncated to the bigger integer
+ degree -= 1;
+ }
+ step = pow(10., double(degree));
+ }
+
+ ScalFact->setSingleStep(step);
+ ScalFact->setValue(theFactor);
}
/*!
*/
void VisuGUI_VectorsDlg::setColor( QColor color )
{
- myColor = color;
- SelColor->setPaletteBackgroundColor(myColor);
-/* QPalette pal = ColorLab->palette();
- QColorGroup ca = pal.active();
- ca.setColor( QColorGroup::Background, myColor );
- pal.setActive( ca );
- ColorLab->setPalette( pal );*/
+ //myColor = color;
+ //QPalette aPal = SelColor->palette();
+ //aPal.setColor( SelColor->backgroundRole(), myColor );
+ //SelColor->setPalette( aPal );
+ SelColor->setColor( color );
}
/*!
enableSetColor();
}
-
-void VisuGUI_VectorsDlg::accept() {
- if (myScalarPane->check())
- {
- myScalarPane->deletePreview();
- QDialog::accept();
- }
-}
-
-void VisuGUI_VectorsDlg::reject()
-{
- myScalarPane->deletePreview();
- QDialog::reject();
-}
-
-void VisuGUI_VectorsDlg::onHelp()
+QString VisuGUI_VectorsDlg::GetContextHelpFilePath()
{
- QString aHelpFileName = "/files/vectors_presentation.htm";
- LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
- if (app) {
- VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
- app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
- }
- else {
- SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
- QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
- arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
- QObject::tr("BUT_OK"));
- }
+ return "vectors_page.html";
}