-// Copyright (C) 2007-2013 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
-//
+// Copyright (C) 2014-2015 EDF-R&D
// 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.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "HYDROGUI_ImmersibleZoneDlg.h"
-#include "HYDROGUI_ColorWidget.h"
#include "HYDROGUI_Tool.h"
#include <QComboBox>
#include <QGroupBox>
#include <QLabel>
#include <QLayout>
-#include <QLineEdit>
-#include <QListWidget>
-#include <QRadioButton>
HYDROGUI_ImmersibleZoneDlg::HYDROGUI_ImmersibleZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle )
-: HYDROGUI_InputPanel( theModule, theTitle )
+: HYDROGUI_BasicZoneDlg( theModule, theTitle,
+ tr( "ZONE_NAME" ), tr( "NAME" ),
+ tr( "ZONE_PARAMETERS" ), tr( "ZONE_BATHYMETRY" ) )
{
- // Zone name
- myObjectNameGroup = new QGroupBox( tr( "ZONE_NAME" ), mainFrame() );
-
- myObjectName = new QLineEdit( myObjectNameGroup );
-
- QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
- aNameLayout->setMargin( 5 );
- aNameLayout->setSpacing( 5 );
- aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
- aNameLayout->addWidget( myObjectName );
-
-
- QGroupBox* aParamGroup = new QGroupBox( tr( "ZONE_PARAMETERS" ), mainFrame() );
-
- QFrame* aPolylineFrame = new QFrame( aParamGroup );
-
- myPolylines = new QComboBox( aPolylineFrame );
+ myPolylines = new QComboBox( myPolylineFrame );
myPolylines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- QBoxLayout* aPolyLayout = new QHBoxLayout( aPolylineFrame );
+ QBoxLayout* aPolyLayout = new QHBoxLayout( myPolylineFrame );
aPolyLayout->setMargin( 0 );
aPolyLayout->setSpacing( 5 );
- aPolyLayout->addWidget( new QLabel( tr( "ZONE_POLYLINE" ), aPolylineFrame ) );
+ aPolyLayout->addWidget( new QLabel( tr( "ZONE_POLYLINE" ), myPolylineFrame ) );
aPolyLayout->addWidget( myPolylines );
-
-
- QFrame* aFillingFrame = new QFrame( aParamGroup );
- QLabel* aFillingLabel = new QLabel( tr( "FILLING_COLOR" ), aFillingFrame );
- myFillingTransparent = new QRadioButton( tr( "TRANSPARENT" ), aFillingFrame );
- myFillingTransparent->setChecked( true );
- myFillingColor = new QRadioButton( tr( "COLOR" ), aFillingFrame );
- myFillingColorBox = new HYDROGUI_ColorWidget( aFillingFrame );
-
- QGridLayout* aFillingLayout = new QGridLayout( aFillingFrame );
- aFillingLayout->setMargin( 0 );
- aFillingLayout->setSpacing( 5 );
- aFillingLayout->addWidget( aFillingLabel, 0, 0, 2, 1 );
- aFillingLayout->addWidget( myFillingTransparent, 0, 1 );
- aFillingLayout->addWidget( myFillingColor, 1, 1 );
- aFillingLayout->addWidget( myFillingColorBox, 1, 2 );
-
-
- myBorderColorGroup = new QGroupBox( tr( "BORDER_COLOR" ), mainFrame() );
- myBorderColorGroup->setCheckable( true );
-
- myBorderColorBox = new HYDROGUI_ColorWidget( myBorderColorGroup );
-
- QBoxLayout* aBorderColorLayout = new QHBoxLayout( myBorderColorGroup );
- aBorderColorLayout->setMargin( 5 );
- aBorderColorLayout->setSpacing( 5 );
- aBorderColorLayout->addWidget( new QLabel( tr( "COLOR" ), myBorderColorGroup ) );
- aBorderColorLayout->addWidget( myBorderColorBox );
-
-
- QBoxLayout* aParamLayout = new QVBoxLayout( aParamGroup );
+
+ QBoxLayout* aParamLayout = new QVBoxLayout( myParamGroup );
aParamLayout->setMargin( 5 );
aParamLayout->setSpacing( 5 );
- aParamLayout->addWidget( aPolylineFrame );
- aParamLayout->addWidget( aFillingFrame );
- aParamLayout->addWidget( myBorderColorGroup );
-
-
- QGroupBox* aBathGroup = new QGroupBox( tr( "ZONE_BATHYMETRY" ), mainFrame() );
-
- myBathymetries = new QComboBox( aPolylineFrame );
- myBathymetries->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-
- QBoxLayout* aBathLayout = new QHBoxLayout( aBathGroup );
- aBathLayout->setMargin( 5 );
- aBathLayout->setSpacing( 5 );
- aBathLayout->addWidget( myBathymetries );
-
-
- // Common
- addWidget( myObjectNameGroup );
- addWidget( aParamGroup );
- addWidget( aBathGroup );
-
- addStretch();
-
+ aParamLayout->addWidget( myPolylineFrame );
// Connect signals and slots
connect( myPolylines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onZoneDefChanged() ) );
- connect( myFillingTransparent, SIGNAL( toggled( bool ) ), this, SLOT( onFillingColorChanged( const bool ) ) );
- connect( myFillingColor, SIGNAL( toggled( bool ) ), this, SLOT( onFillingColorChanged( const bool ) ) );
- connect( myFillingColorBox, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( onFillingColorChanged() ) );
- connect( myBorderColorGroup, SIGNAL( toggled( bool ) ), this, SLOT( onZoneDefChanged() ) );
- connect( myBorderColorBox, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( onZoneDefChanged() ) );
}
HYDROGUI_ImmersibleZoneDlg::~HYDROGUI_ImmersibleZoneDlg()
{
bool isBlocked = blockSignals( true );
- myObjectName->clear();
+ HYDROGUI_BasicZoneDlg::reset();
myPolylines->clear();
- myBathymetries->clear();
-
- myFillingTransparent->setChecked( true );
- myFillingColorBox->resetColor();
-
- myBorderColorGroup->setChecked( false );
- myBorderColorBox->resetColor();
-
+
blockSignals( isBlocked );
onZoneDefChanged();
}
-void HYDROGUI_ImmersibleZoneDlg::setObjectName( const QString& theName )
-{
- myObjectName->setText( theName );
-}
-
-QString HYDROGUI_ImmersibleZoneDlg::getObjectName() const
-{
- return myObjectName->text();
-}
-
void HYDROGUI_ImmersibleZoneDlg::setPolylineNames( const QStringList& thePolylines )
{
bool isBlocked = blockSignals( true );
return myPolylines->currentText();
}
-void HYDROGUI_ImmersibleZoneDlg::setBathymetryNames( const QStringList& theBathymetries )
-{
- bool isBlocked = blockSignals( true );
-
- myBathymetries->clear();
- myBathymetries->addItems( theBathymetries );
-
- blockSignals( isBlocked );
-}
-
-void HYDROGUI_ImmersibleZoneDlg::setBathymetryName( const QString& theName )
-{
- int aNewIdx = myBathymetries->findText( theName );
- myBathymetries->setCurrentIndex( aNewIdx );
-}
-
-QString HYDROGUI_ImmersibleZoneDlg::getBathymetryName() const
-{
- return myBathymetries->currentText();
-}
-
-void HYDROGUI_ImmersibleZoneDlg::setFillingColor( const QColor& theColor )
-{
- bool isBlocked = blockSignals( true );
-
- if( theColor.alpha() == 0 ) // transparent
- myFillingTransparent->setChecked( true );
- else
- myFillingColor->setChecked( true );
-
- myFillingColorBox->setColor( theColor );
-
- blockSignals( isBlocked );
-
- onZoneDefChanged();
-}
-
-QColor HYDROGUI_ImmersibleZoneDlg::getFillingColor() const
-{
- QColor aColor( 255, 255, 255, 0 ); // transparent
- if( myFillingColor->isChecked() )
- aColor = myFillingColorBox->color();
- return aColor;
-}
-
-void HYDROGUI_ImmersibleZoneDlg::setBorderColor( const QColor& theColor )
-{
- bool isBlocked = blockSignals( true );
-
- bool isTransparent = theColor.alpha() == 0;
- myBorderColorGroup->setChecked( !isTransparent );
- myBorderColorBox->setColor( !isTransparent ? theColor : QColor( Qt::black ) );
-
- blockSignals( isBlocked );
-
- onZoneDefChanged();
-}
-
-QColor HYDROGUI_ImmersibleZoneDlg::getBorderColor() const
-{
- QColor aColor( Qt::transparent ); // transparent
- if( myBorderColorGroup->isChecked() )
- aColor = myBorderColorBox->color();
- return aColor;
-}
-
-void HYDROGUI_ImmersibleZoneDlg::onFillingColorChanged()
-{
- if ( !myFillingColor->isChecked() )
- return;
-
- onZoneDefChanged();
-}
-
-void HYDROGUI_ImmersibleZoneDlg::onFillingColorChanged( const bool theIsChecked )
-{
- if ( !theIsChecked )
- return;
-
- onZoneDefChanged();
-}
-
void HYDROGUI_ImmersibleZoneDlg::onZoneDefChanged()
{
if ( signalsBlocked() )
QString aPolylineName = getPolylineName();
emit CreatePreview( aPolylineName );
}
-
-