#include <BRepTools.hxx>
#endif
+#include <QColor>
#include <QStringList>
#define PYTHON_CHANNEL_ID "KIND_CHANNEL"
}
}
+QColor HYDROData_Channel::DefaultFillingColor()
+{
+ return QColor( Qt::blue );
+}
+
+QColor HYDROData_Channel::DefaultBorderColor()
+{
+ return QColor( Qt::transparent );
+}
+
+QColor HYDROData_Channel::getDefaultFillingColor() const
+{
+ return DefaultFillingColor();
+}
+
+QColor HYDROData_Channel::getDefaultBorderColor() const
+{
+ return DefaultBorderColor();
+}
+
bool HYDROData_Channel::SetGuideLine( const Handle(HYDROData_Polyline3D)& theGuideLine )
{
Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
*/
HYDRODATA_EXPORT virtual void Update();
+ /**
+ * Returns default filling color for new channel.
+ */
+ HYDRODATA_EXPORT static QColor DefaultFillingColor();
+
+ /**
+ * Returns default border color for new channel.
+ */
+ HYDRODATA_EXPORT static QColor DefaultBorderColor();
+
public:
// Public methods to work with Channel
HYDRODATA_EXPORT virtual void RemoveProfile();
+protected:
+
+ /**
+ * Returns default filling color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
+
+ /**
+ * Returns default border color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
+
protected:
friend class HYDROData_Iterator;
#include <TopoDS_Shape.hxx>
+#include <QColor>
#include <QStringList>
#define PYTHON_DIGUE_ID "KIND_DIGUE"
return aResList;
}
+QColor HYDROData_Digue::DefaultFillingColor()
+{
+ return QColor( Qt::red );
+}
+
+QColor HYDROData_Digue::DefaultBorderColor()
+{
+ return QColor( Qt::transparent );
+}
+QColor HYDROData_Digue::getDefaultFillingColor() const
+{
+ return DefaultFillingColor();
+}
+
+QColor HYDROData_Digue::getDefaultBorderColor() const
+{
+ return DefaultBorderColor();
+}
*/
HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+ /**
+ * Returns default filling color for new digue.
+ */
+ HYDRODATA_EXPORT static QColor DefaultFillingColor();
+
+ /**
+ * Returns default border color for new digue.
+ */
+ HYDRODATA_EXPORT static QColor DefaultBorderColor();
+
+protected:
+
+ /**
+ * Returns default filling color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
+
+ /**
+ * Returns default border color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
+
protected:
friend class HYDROData_Iterator;
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
+#include <QColor>
+
IMPLEMENT_STANDARD_HANDLE(HYDROData_IPolyline, HYDROData_Entity)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IPolyline, HYDROData_Entity)
{
}
+void HYDROData_IPolyline::SetWireColor( const QColor& theColor )
+{
+ SetColor( theColor, DataTag_WireColor );
+}
+
+QColor HYDROData_IPolyline::GetWireColor() const
+{
+ return GetColor( DefaultWireColor(), DataTag_WireColor );
+}
+
+QColor HYDROData_IPolyline::DefaultWireColor()
+{
+ return QColor( Qt::black );
+}
+
int HYDROData_IPolyline::NbPoints( const int theSectionIndex ) const
{
return GetPoints( theSectionIndex ).Length();
DataTag_Points,
DataTag_Sections,
DataTag_PolylineShape,
+ DataTag_WireColor,
};
public:
DEFINE_STANDARD_RTTI(HYDROData_IPolyline);
+public:
+
+ /**
+ * Sets wire color for object.
+ */
+ HYDRODATA_EXPORT virtual void SetWireColor( const QColor& theColor );
+
+ /**
+ * Returns wire color of object.
+ */
+ HYDRODATA_EXPORT virtual QColor GetWireColor() const;
+
+ /**
+ * Returns default wire color for new object.
+ */
+ HYDRODATA_EXPORT static QColor DefaultWireColor();
+
+public:
+
/**
* Returns the 3D presentation of all points.
*/
TopoDS_Shape HYDROData_ImmersibleZone::GetShape3D() const
{
- // TODO
return getTopShape();
}
QColor HYDROData_ImmersibleZone::DefaultFillingColor()
{
- return QColor( Qt::green );
+ return QColor( Qt::darkBlue );
}
QColor HYDROData_ImmersibleZone::DefaultBorderColor()
return QColor( Qt::transparent );
}
+QColor HYDROData_ImmersibleZone::getDefaultFillingColor() const
+{
+ return DefaultFillingColor();
+}
+
+QColor HYDROData_ImmersibleZone::getDefaultBorderColor() const
+{
+ return DefaultBorderColor();
+}
+
void HYDROData_ImmersibleZone::SetPolyline( const Handle(HYDROData_PolylineXY)& thePolyline )
{
SetReferenceObject( thePolyline, DataTag_Polyline );
*/
HYDRODATA_EXPORT virtual void RemovePolyline();
+protected:
+
+ /**
+ * Returns default filling color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
+
+ /**
+ * Returns default border color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
+
private:
TopoDS_Shape generateTopShape() const;
QColor HYDROData_Object::GetFillingColor() const
{
- return GetColor( DefaultFillingColor(), DataTag_FillingColor );
+ return GetColor( getDefaultFillingColor(), DataTag_FillingColor );
}
void HYDROData_Object::SetBorderColor( const QColor& theColor )
QColor HYDROData_Object::GetBorderColor() const
{
- return GetColor( DefaultBorderColor(), DataTag_BorderColor );
+ return GetColor( getDefaultBorderColor(), DataTag_BorderColor );
}
QColor HYDROData_Object::DefaultFillingColor()
QColor HYDROData_Object::DefaultBorderColor()
{
return QColor( Qt::transparent );
-}
\ No newline at end of file
+}
+
+QColor HYDROData_Object::getDefaultFillingColor() const
+{
+ return DefaultFillingColor();
+}
+
+QColor HYDROData_Object::getDefaultBorderColor() const
+{
+ return DefaultBorderColor();
+}
+
*/
HYDRODATA_EXPORT static QColor DefaultBorderColor();
+protected:
+
+ /**
+ * Returns default filling color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
+
+ /**
+ * Returns default border color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
+
protected:
/**
#include <BRepTools.hxx>
#include <BRep_Builder.hxx>
+
#include <IGESControl_Reader.hxx>
#include <IGESData_IGESModel.hxx>
+
#include <STEPControl_Reader.hxx>
+
#include <Interface_Static.hxx>
+
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
+
#include <TDataStd_AsciiString.hxx>
+
#include <TColStd_SequenceOfAsciiString.hxx>
+
#include <TopExp_Explorer.hxx>
+#include <QColor>
#include <QFile>
#include <QFileInfo>
#include <QStringList>
return getShape3D();
}
+QColor HYDROData_Obstacle::DefaultFillingColor()
+{
+ return QColor( Qt::yellow );
+}
+
+QColor HYDROData_Obstacle::DefaultBorderColor()
+{
+ return QColor( Qt::transparent );
+}
+
+QColor HYDROData_Obstacle::getDefaultFillingColor() const
+{
+ return DefaultFillingColor();
+}
+
+QColor HYDROData_Obstacle::getDefaultBorderColor() const
+{
+ return DefaultBorderColor();
+}
+
bool HYDROData_Obstacle::ImportFromFile( const QString& theFilePath )
{
// Check the file existence
*/
HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
+ /**
+ * Returns default filling color for new obstacle.
+ */
+ HYDRODATA_EXPORT static QColor DefaultFillingColor();
+
+ /**
+ * Returns default border color for new obstacle.
+ */
+ HYDRODATA_EXPORT static QColor DefaultBorderColor();
+
+
+public:
+
/**
* Imports shape from file containing geometrical object and sets this
* shape as the obstacle shape.
*/
HYDRODATA_EXPORT QString GetGeomObjectEntry() const;
+protected:
+
+ /**
+ * Returns default filling color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
+
+ /**
+ * Returns default border color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
+
protected:
friend class HYDROData_Iterator;
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
+#include <QColor>
#include <QStringList>
#define PYTHON_POLYLINE_ID "KIND_POLYLINE"
SetShape3D( aResWire );
}
+QColor HYDROData_Polyline3D::DefaultFillingColor()
+{
+ return QColor( Qt::transparent );
+}
+
+QColor HYDROData_Polyline3D::DefaultBorderColor()
+{
+ return QColor( Qt::red );
+}
+
+QColor HYDROData_Polyline3D::getDefaultFillingColor() const
+{
+ return DefaultFillingColor();
+}
+
+QColor HYDROData_Polyline3D::getDefaultBorderColor() const
+{
+ return DefaultBorderColor();
+}
+
bool HYDROData_Polyline3D::SetPolylineXY( const Handle(HYDROData_PolylineXY)& thePolyline )
{
if ( thePolyline.IsNull() )
*/
HYDRODATA_EXPORT virtual void Update();
+ /**
+ * Returns default filling color for new 3D polyline.
+ */
+ HYDRODATA_EXPORT static QColor DefaultFillingColor();
+
+ /**
+ * Returns default border color for new 3D polyline.
+ */
+ HYDRODATA_EXPORT static QColor DefaultBorderColor();
+
public:
// Public methods to work with 3D polyline
protected:
+ /**
+ * Returns default filling color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
+
+ /**
+ * Returns default border color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
+
/**
* Checks and if necessary create child 3D object.
* Reimplemented to prevent creation of 3D child object.
#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <QColor>
#include <QPainterPath>
#include <QVariant>
return aVarData;
}
+QColor HYDROData_PolylineXY::DefaultWireColor()
+{
+ return QColor( Qt::red );
+}
+
TopoDS_Shape HYDROData_PolylineXY::GetShape()
{
return getPolylineShape();
*/
HYDRODATA_EXPORT virtual QVariant GetDataVariant();
+ /**
+ * Returns default wire color for new polyline.
+ */
+ HYDRODATA_EXPORT static QColor DefaultWireColor();
+
public:
/**
#include <OSD_File.hxx>
#include <OSD_Protection.hxx>
+#include <QColor>
#include <QStringList>
#define PYTHON_PROFILE_ID "KIND_PROFILE"
{
}
+QStringList HYDROData_Profile::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+{
+ QStringList aResList;
+
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+ if ( aDocument.IsNull() )
+ return aResList;
+
+ QString aDocName = aDocument->GetDocPyName();
+ QString aProfileName = GetName();
+
+ aResList << QString( "%1 = %2.CreateObject( %3 );" )
+ .arg( aProfileName ).arg( aDocName ).arg( PYTHON_PROFILE_ID );
+ aResList << QString( "%1.SetName( \"%1\" );" ).arg( aProfileName );
+
+ return aResList;
+}
+
TopoDS_Shape HYDROData_Profile::GetTopShape() const
{
TopoDS_Wire aWire;
SetShape3D( aWire );
}
-/**
- * Dump object to Python script representation.
- */
-QStringList HYDROData_Profile::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QColor HYDROData_Profile::DefaultFillingColor()
{
- QStringList aResList;
+ return QColor( Qt::transparent );
+}
- Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
- if ( aDocument.IsNull() )
- return aResList;
-
- QString aDocName = aDocument->GetDocPyName();
- QString aProfileName = GetName();
+QColor HYDROData_Profile::DefaultBorderColor()
+{
+ return QColor( Qt::black );
+}
- aResList << QString( "%1 = %2.CreateObject( %3 );" )
- .arg( aProfileName ).arg( aDocName ).arg( PYTHON_PROFILE_ID );
- aResList << QString( "%1.SetName( \"%1\" );" ).arg( aProfileName );
+QColor HYDROData_Profile::getDefaultFillingColor() const
+{
+ return DefaultFillingColor();
+}
- return aResList;
+QColor HYDROData_Profile::getDefaultBorderColor() const
+{
+ return DefaultBorderColor();
}
bool HYDROData_Profile::IsValid() const
aProfile->SetName( aProfileName );
aProfile->SetFilePath( theFileName );
+
+ aProfile->SetBorderColor( HYDROData_Profile::DefaultBorderColor() );
}
return !aCreatedProfiles.IsEmpty();
*/
HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_PROFILE; }
+ /**
+ * Dump object to Python script representation.
+ */
+ HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+
/**
* Returns the top shape of the object.
*/
HYDRODATA_EXPORT virtual void Update();
/**
- * Dump object to Python script representation.
+ * Returns default filling color for new profile.
*/
- HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+ HYDRODATA_EXPORT static QColor DefaultFillingColor();
+
+ /**
+ * Returns default border color for new profile.
+ */
+ HYDRODATA_EXPORT static QColor DefaultBorderColor();
+
+public:
/**
* Check profile data and returns true if profile is valid.
protected:
+ /**
+ * Returns default filling color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
+
+ /**
+ * Returns default border color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
+
/**
* Checks and if necessary create child 3D object.
* Reimplemented to prevent creation of 3D child object.
#include "HYDROData_PolylineXY.h"
#include "HYDROData_Profile.h"
-#include <BRep_Builder.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeWire.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-
#include <TDataStd_RealArray.hxx>
+#include <Precision.hxx>
+
+#include <NCollection_DataMap.hxx>
+
+#include <TColStd_Array1OfReal.hxx>
+#include <TColStd_ListOfReal.hxx>
+#include <TColStd_ListIteratorOfListOfReal.hxx>
+#include <TCollection_CompareOfReal.hxx>
+#include <TColgp_Array1OfPnt.hxx>
+#include <TColgp_HArray1OfPnt.hxx>
+
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
+
+#include <Bnd_Box.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+
+#include <BRepBndLib.hxx>
#include <BRepProj_Projection.hxx>
#include <BRepExtrema_ExtCC.hxx>
+#include <BRepCheck_Analyzer.hxx>
+
+#include <gp.hxx>
#include <gp_Ax1.hxx>
#include <gp_Ax2.hxx>
#include <gp_Ax3.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pln.hxx>
-#include <gp.hxx>
-#include <Bnd_Box.hxx>
-#include <BRepBndLib.hxx>
-#include <TColStd_Array1OfReal.hxx>
-#include <Precision.hxx>
-#include <QStringList>
-#include <NCollection_DataMap.hxx>
-typedef NCollection_DataMap<Standard_Real, Handle(HYDROData_Profile)> HYDROData_DataMapOfRealOfHDProfile;
-#include <TColStd_ListOfReal.hxx>
-#include <TColStd_ListIteratorOfListOfReal.hxx>
-#include <TCollection_CompareOfReal.hxx>
-#include <SortTools_QuickSortOfReal.hxx>
-#include <TColgp_Array1OfPnt.hxx>
-#include <TColgp_HArray1OfPnt.hxx>
#include <GeomAPI_Interpolate.hxx>
#include <Geom_BSplineCurve.hxx>
+
#include <TopTools_Array1OfShape.hxx>
-#include <BRepCheck_Analyzer.hxx>
+
+#include <SortTools_QuickSortOfReal.hxx>
+
+#include <QColor>
+#include <QStringList>
//#define DEB_STREAM 1
#ifdef DEB_STREAM
#define PYTHON_STREAM_ID "KIND_STREAM"
+typedef NCollection_DataMap<Standard_Real, Handle(HYDROData_Profile)> HYDROData_DataMapOfRealOfHDProfile;
+
IMPLEMENT_STANDARD_HANDLE(HYDROData_Stream,HYDROData_NaturalObject)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Stream,HYDROData_NaturalObject)
{
return getTopShape();
}
+
TopoDS_Shape HYDROData_Stream::GetShape3D() const
{
return getShape3D();
}
- Handle(Geom_BSplineCurve) HYDROData_Stream::buildInterpolationCurve(const Handle(TColgp_HArray1OfPnt)& theArrayOfPnt)
+
+Handle(Geom_BSplineCurve) HYDROData_Stream::buildInterpolationCurve(
+ const Handle(TColgp_HArray1OfPnt)& theArrayOfPnt )
{
Handle(Geom_BSplineCurve) aBSpline;
GeomAPI_Interpolate anInterpolator (theArrayOfPnt, Standard_False, 1.0e-5);
aBSpline = anInterpolator.Curve();
return aBSpline;
}
+
void HYDROData_Stream::Update()
{
HYDROData_NaturalObject::Update();
}
+QColor HYDROData_Stream::DefaultFillingColor()
+{
+ return QColor( Qt::green );
+}
+
+QColor HYDROData_Stream::DefaultBorderColor()
+{
+ return QColor( Qt::transparent );
+}
+
+QColor HYDROData_Stream::getDefaultFillingColor() const
+{
+ return DefaultFillingColor();
+}
+
+QColor HYDROData_Stream::getDefaultBorderColor() const
+{
+ return DefaultBorderColor();
+}
+
bool HYDROData_Stream::SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis )
{
Handle(HYDROData_PolylineXY) aPrevAxis = GetHydraulicAxis();
*/
HYDRODATA_EXPORT virtual void Update();
+ /**
+ * Returns default filling color for new stream.
+ */
+ HYDRODATA_EXPORT static QColor DefaultFillingColor();
+
+ /**
+ * Returns default border color for new stream.
+ */
+ HYDRODATA_EXPORT static QColor DefaultBorderColor();
+
public:
// Public methods to work with Stream
*/
Handle(Geom_BSplineCurve) buildInterpolationCurve(const Handle(TColgp_HArray1OfPnt)& theArrayOfPnt);
+ /**
+ * Returns default filling color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultFillingColor() const;
+
+ /**
+ * Returns default border color for new object.
+ */
+ HYDRODATA_EXPORT virtual QColor getDefaultBorderColor() const;
+
private:
void setParametersArray( const TColStd_Array1OfReal& theArray );
}
bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg )
{
HYDROGUI_ChannelDlg* aPanel = ::qobject_cast<HYDROGUI_ChannelDlg*>( inputPanel() );
if ( !aPanel )
myEditedObject->SetName( anObjectName );
- if ( !myIsEdit ) {
+ if ( !myIsEdit )
+ {
myEditedObject->SetFillingColor( HYDROData_Channel::DefaultFillingColor() );
myEditedObject->SetBorderColor( HYDROData_Channel::DefaultBorderColor() );
}
protected:
virtual void erasePreview();
+
virtual Handle(HYDROData_Channel) getObjectToEdit() const;
protected:
#include <QRadioButton>
#include <QPushButton>
-HYDROGUI_ColorDlg::HYDROGUI_ColorDlg( QWidget* theParent )
-: QDialog( theParent )
+HYDROGUI_ColorDlg::HYDROGUI_ColorDlg( QWidget* theParent, bool theIsOneColor )
+: QDialog( theParent ),
+ myIsOneColor( theIsOneColor )
{
- // Filling color
- QFrame* aFillingFrame = new QFrame( this );
- 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( 5 );
- 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 );
-
- // Border color
- myBorderColorGroup = new QGroupBox( tr( "BORDER_COLOR" ), this );
- 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 );
+ QVBoxLayout* aMainLayout = new QVBoxLayout( this );
+ aMainLayout->setMargin( 5 );
+ aMainLayout->setSpacing( 5 );
+
+ if ( !theIsOneColor )
+ {
+ // Filling color
+ QFrame* aFillingFrame = new QFrame( this );
+ 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( 5 );
+ 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 );
+
+ // Border color
+ myBorderColorGroup = new QGroupBox( tr( "BORDER_COLOR" ), this );
+ 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 );
+
+ aMainLayout->addWidget( aFillingFrame );
+ aMainLayout->addWidget( myBorderColorGroup );
+ }
+ else
+ {
+ QFrame* aColorFrame = new QFrame( this );
+ QLabel* aColorLabel = new QLabel( tr( "OBJECT_COLOR" ), aColorFrame );
+ myColorBox = new HYDROGUI_ColorWidget( aColorFrame );
+ myColorBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
+ myColorBox->setFixedHeight( 20 );
+
+ QBoxLayout* aColorLayout = new QHBoxLayout( aColorFrame );
+ aColorLayout->setMargin( 10 );
+ aColorLayout->setSpacing( 5 );
+ aColorLayout->addWidget( aColorLabel );
+ aColorLayout->addWidget( myColorBox );
+
+ aMainLayout->addWidget( aColorFrame );
+ }
// Buttons
QPushButton* anOkButton = new QPushButton( tr( "OK" ), this );
aButtonsLayout->addWidget( aCancelButton );
// Common
- QVBoxLayout* aMainLayout = new QVBoxLayout( this );
- aMainLayout->setMargin( 5 );
- aMainLayout->setSpacing( 5 );
-
- aMainLayout->addWidget( aFillingFrame );
- aMainLayout->addWidget( myBorderColorGroup );
aMainLayout->addStretch();
aMainLayout->addLayout( aButtonsLayout );
connect( anOkButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( aCancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
- setFixedSize( 300, 150 );
+ setFixedSize( 300, theIsOneColor ? 90 : 150 );
}
HYDROGUI_ColorDlg::~HYDROGUI_ColorDlg()
{
}
-void HYDROGUI_ColorDlg::setFillingColor( const QColor& theColor )
+void HYDROGUI_ColorDlg::setFirstColor( const QColor& theColor )
{
- if( theColor.alpha() == 0 ) // transparent
- myFillingTransparent->setChecked( true );
+ if ( !myIsOneColor )
+ {
+ if( theColor.alpha() == 0 ) // transparent
+ myFillingTransparent->setChecked( true );
+ else
+ myFillingColor->setChecked( true );
+
+ myFillingColorBox->setColor( theColor );
+ }
else
- myFillingColor->setChecked( true );
-
- myFillingColorBox->setColor( theColor );
+ {
+ myColorBox->setColor( theColor );
+ }
}
-QColor HYDROGUI_ColorDlg::getFillingColor() const
+QColor HYDROGUI_ColorDlg::getFirstColor() const
{
- QColor aColor( 255, 255, 255, 0 ); // transparent
- if( myFillingColor->isChecked() )
- aColor = myFillingColorBox->color();
+ QColor aColor;
+ if ( !myIsOneColor )
+ {
+ aColor = QColor( 255, 255, 255, 0 ); // transparent
+ if( myFillingColor->isChecked() )
+ aColor = myFillingColorBox->color();
+ }
+ else
+ {
+ aColor = myColorBox->color();
+ }
+
return aColor;
}
-void HYDROGUI_ColorDlg::setBorderColor( const QColor& theColor )
+void HYDROGUI_ColorDlg::setSecondColor( const QColor& theColor )
{
+ if ( myIsOneColor )
+ return;
+
bool isTransparent = theColor.alpha() == 0;
myBorderColorGroup->setChecked( !isTransparent );
myBorderColorBox->setColor( !isTransparent ? theColor : QColor( Qt::black ) );
}
-QColor HYDROGUI_ColorDlg::getBorderColor() const
+QColor HYDROGUI_ColorDlg::getSecondColor() const
{
QColor aColor( Qt::transparent ); // transparent
+
+ if ( myIsOneColor )
+ return aColor;
+
if( myBorderColorGroup->isChecked() )
aColor = myBorderColorBox->color();
+
return aColor;
}
Q_OBJECT
public:
- HYDROGUI_ColorDlg( QWidget* );
+ HYDROGUI_ColorDlg( QWidget* theParent, bool theIsOneColor );
virtual ~HYDROGUI_ColorDlg();
- void setFillingColor( const QColor& theColor );
- QColor getFillingColor() const;
+ void setFirstColor( const QColor& theColor );
+ QColor getFirstColor() const;
- void setBorderColor( const QColor& theColor );
- QColor getBorderColor() const;
+ void setSecondColor( const QColor& theColor );
+ QColor getSecondColor() const;
protected slots:
QGroupBox* myBorderColorGroup;
HYDROGUI_ColorWidget* myBorderColorBox;
+
+ HYDROGUI_ColorWidget* myColorBox;
+
+ bool myIsOneColor;
};
#endif
#include "HYDROGUI_DigueDlg.h"
#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_Shape.h"
#include <HYDROData_Document.h>
#include <HYDROData_Digue.h>
}
}
+bool HYDROGUI_DigueOp::processApply( int& theUpdateFlags,
+ QString& theErrorMsg )
+{
+ if ( !HYDROGUI_ChannelOp::processApply( theUpdateFlags, theErrorMsg ) )
+ return false;
+
+ if ( !myIsEdit )
+ {
+ myEditedObject->SetFillingColor( HYDROData_Digue::DefaultFillingColor() );
+ myEditedObject->SetBorderColor( HYDROData_Digue::DefaultBorderColor() );
+ }
+
+ return true;
+}
+
HYDROGUI_InputPanel* HYDROGUI_DigueOp::createInputPanel() const
{
HYDROGUI_DigueDlg* aPanel = new HYDROGUI_DigueDlg( module(), getName() );
protected:
- virtual void startOperation();
+ virtual void startOperation();
+
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
virtual HYDROGUI_InputPanel* createInputPanel() const;
+protected:
+
virtual Handle(HYDROData_Channel) getObjectToEdit() const;
private:
QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_IMMERSIBLE_ZONE_NAME" ) );
- QColor aFillingColor( HYDROData_ImmersibleZone::DefaultFillingColor() );
- QColor aBorderColor( HYDROData_ImmersibleZone::DefaultBorderColor() );
QString aSelectedPolyline, aSelectedBathymetry;
QStringList aSelectedBathymetries;
{
anObjectName = myEditedObject->GetName();
- aFillingColor = myEditedObject->GetFillingColor();
- aBorderColor = myEditedObject->GetBorderColor();
-
Handle(HYDROData_PolylineXY) aRefPolyline = myEditedObject->GetPolyline();
if ( !aRefPolyline.IsNull() )
aSelectedPolyline = aRefPolyline->GetName();
aZoneObj->SetName( anObjectName );
- if ( !myIsEdit ) {
+ if ( !myIsEdit )
+ {
aZoneObj->SetFillingColor( HYDROData_ImmersibleZone::DefaultFillingColor() );
aZoneObj->SetBorderColor( HYDROData_ImmersibleZone::DefaultBorderColor() );
}
if ( anObstacleToEdit.IsNull() ) {
anObstacle =
Handle(HYDROData_Obstacle)::DownCast( doc()->CreateObject(KIND_OBSTACLE) );
+
+ anObstacle->SetFillingColor( HYDROData_Obstacle::DefaultFillingColor() );
+ anObstacle->SetBorderColor( HYDROData_Obstacle::DefaultBorderColor() );
} else {
anObstacle = anObstacleToEdit;
}
// If the obstacle for edit is null - create new obstacle object
if ( anObstacle.IsNull() ) {
anObstacle = Handle(HYDROData_Obstacle)::DownCast( doc()->CreateObject(KIND_OBSTACLE) );
+
+ anObstacle->SetFillingColor( HYDROData_Obstacle::DefaultFillingColor() );
+ anObstacle->SetBorderColor( HYDROData_Obstacle::DefaultBorderColor() );
}
if ( !anObstacle.IsNull() ) {
#include "HYDROGUI_VTKPrsDisplayer.h"
#include "HYDROGUI_AbstractDisplayer.h"
#include "HYDROGUI_PolylineOp.h"
+#include "HYDROGUI_SetColorOp.h"
#include <HYDROData_Image.h>
#include <HYDROData_Profile.h>
bool anIsStream = false;
bool anIsChannel = false;
bool anIsDigue = false;
- bool anIsGeomObject = false;
bool anIsDummyObject3D = false;
+ bool anIsObjectCanBeColored = false;
// check the selected GEOM objects
if ( anIsObjectBrowser && !HYDROGUI_Tool::GetSelectedGeomObjects( this ).isEmpty() ) {
anIsDummyObject3D = true;
}
- anIsGeomObject = HYDROData_Tool::IsGeometryObject( anObject );
+ if ( !anIsObjectCanBeColored )
+ anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject );
}
// Check if all selected objects are profiles
}
// Add set color action for geometrical objects
- if ( anIsGeomObject )
+ if ( anIsObjectCanBeColored )
{
theMenu->addAction( action( SetColorId ) );
theMenu->addSeparator();
aResult->SetProfileUZ( aProfileUZ );
aResult->SetPolylineXY( aPolyline );
+ if( !myIsEdit )
+ {
+ aResult->SetBorderColor( HYDROData_Polyline3D::DefaultBorderColor() );
+ }
+
aResult->Update();
if( !myIsEdit )
{
- size_t aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
+ size_t aViewId = HYDROGUI_Tool::GetActiveOCCViewId( module() );
module()->setObjectVisible( aViewId, anObject1, false );
module()->setObjectVisible( aViewId, anObject2, false );
module()->setObjectVisible( aViewId, aResult, true );
}
}
+ if ( !myIsEdit )
+ {
+ aPolylineObj->SetWireColor( HYDROData_PolylineXY::DefaultWireColor() );
+ }
+
// Update the wire of polyline
aPolylineObj->Update();
aProfileUZ->SetSectionType( 0, aSectType );
+ if ( !myIsEdit )
+ {
+ aProfileObj->SetBorderColor( HYDROData_Profile::DefaultBorderColor() );
+ }
+
aProfileObj->Update();
theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_UpdateFlags.h"
+#include <HYDROData_Object.h>
+#include <HYDROData_IPolyline.h>
+
#include <LightApp_Application.h>
#include <LightApp_UpdateFlags.h>
{
}
+bool HYDROGUI_SetColorOp::CanObjectBeColored( const Handle(HYDROData_Entity)& theObject )
+{
+ if ( theObject.IsNull() )
+ return false;
+
+ return theObject->IsKind( STANDARD_TYPE(HYDROData_Object) ) ||
+ theObject->IsKind( STANDARD_TYPE(HYDROData_IPolyline) );
+}
+
void HYDROGUI_SetColorOp::startOperation()
{
HYDROGUI_Operation::startOperation();
// Get the selected object
- myEditedObject = Handle(HYDROData_Object)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ //myEditedObject = Handle(HYDROData_Object)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ myEditedObject = HYDROGUI_Tool::GetSelectedObject( module() );
+ if ( !CanObjectBeColored( myEditedObject ) )
+ {
+ abort();
+ return;
+ }
+
+ bool anIsOneColor = false;
+
+ // Get colors from the object
+ QColor aFirstColor, aSecondColor;
+ if ( myEditedObject->IsKind( STANDARD_TYPE(HYDROData_Object) ) )
+ {
+ Handle(HYDROData_Object) aGeomObject =
+ Handle(HYDROData_Object)::DownCast( myEditedObject );
+
+ if ( myEditedObject->GetKind() == KIND_POLYLINE ||
+ myEditedObject->GetKind() == KIND_PROFILE )
+ {
+ aFirstColor = aGeomObject->GetBorderColor();
+ anIsOneColor = true;
+ }
+ else
+ {
+ aFirstColor = aGeomObject->GetFillingColor();
+ aSecondColor = aGeomObject->GetBorderColor();
+ }
+ }
+ else if ( myEditedObject->IsKind( STANDARD_TYPE(HYDROData_IPolyline) ) )
+ {
+ Handle(HYDROData_IPolyline) aPolyObject =
+ Handle(HYDROData_IPolyline)::DownCast( myEditedObject );
- if( !myEditedObject.IsNull() ) {
- // Get colors from the object
- QColor aFillingColor = myEditedObject->GetFillingColor();
- QColor aBorderColor = myEditedObject->GetBorderColor();
+ aFirstColor = aPolyObject->GetWireColor();
- // Create color dialog
- myColorDlg = new HYDROGUI_ColorDlg( module()->getApp()->desktop() );
- myColorDlg->setModal( true );
- myColorDlg->setWindowTitle( getName() );
+ anIsOneColor = true;
+ }
- // Set colors from the object
- myColorDlg->setFillingColor( aFillingColor );
- myColorDlg->setBorderColor( aBorderColor );
+ // Create color dialog
+ myColorDlg = new HYDROGUI_ColorDlg( module()->getApp()->desktop(), anIsOneColor );
+ myColorDlg->setModal( true );
+ myColorDlg->setWindowTitle( getName() );
- // Connect the dialog to operation slots
- connect( myColorDlg, SIGNAL( accepted() ), this, SLOT( onApply() ) );
- connect( myColorDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
+ // Set colors from the object
+ myColorDlg->setFirstColor( aFirstColor );
+ myColorDlg->setSecondColor( aSecondColor );
- // Show the dialog
- myColorDlg->exec();
- }
+ // Connect the dialog to operation slots
+ connect( myColorDlg, SIGNAL( accepted() ), this, SLOT( onApply() ) );
+ connect( myColorDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
+
+ // Show the dialog
+ myColorDlg->exec();
}
bool HYDROGUI_SetColorOp::processApply( int& theUpdateFlags,
QString& theErrorMsg )
{
- bool anIsOk = false;
-
- if ( myColorDlg && myEditedObject ) {
- QColor aFillingColor = myColorDlg->getFillingColor();
- QColor aBorderColor = myColorDlg->getBorderColor();
-
- myEditedObject->SetFillingColor( aFillingColor );
- myEditedObject->SetBorderColor( aBorderColor );
-
- theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+ if ( !myColorDlg || myEditedObject.IsNull() )
+ return false;
+
+ QColor aFirstColor = myColorDlg->getFirstColor();
+ QColor aSecondColor = myColorDlg->getSecondColor();
+
+ if ( myEditedObject->IsKind( STANDARD_TYPE(HYDROData_Object) ) )
+ {
+ Handle(HYDROData_Object) aGeomObject =
+ Handle(HYDROData_Object)::DownCast( myEditedObject );
+
+ if ( myEditedObject->GetKind() == KIND_POLYLINE ||
+ myEditedObject->GetKind() == KIND_PROFILE )
+ {
+ aGeomObject->SetBorderColor( aFirstColor );
+ }
+ else
+ {
+ aGeomObject->SetFillingColor( aFirstColor );
+ aGeomObject->SetBorderColor( aSecondColor );
+ }
+ }
+ else if ( myEditedObject->IsKind( STANDARD_TYPE(HYDROData_IPolyline) ) )
+ {
+ Handle(HYDROData_IPolyline) aPolyObject =
+ Handle(HYDROData_IPolyline)::DownCast( myEditedObject );
- anIsOk = true;
+ aPolyObject->SetWireColor( aFirstColor );
}
+
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
- return anIsOk;
+ return true;
}
#include "HYDROGUI_Operation.h"
-#include <HYDROData_Object.h>
+#include <HYDROData_Entity.h>
class HYDROGUI_ColorDlg;
HYDROGUI_SetColorOp( HYDROGUI_Module* theModule );
virtual ~HYDROGUI_SetColorOp();
+
+ static bool CanObjectBeColored( const Handle(HYDROData_Entity)& theObject );
+
protected:
virtual void startOperation();
private:
HYDROGUI_ColorDlg* myColorDlg;
- Handle(HYDROData_Object) myEditedObject;
+ Handle(HYDROData_Entity) myEditedObject;
};
#endif
\ No newline at end of file
updateShape( false, false );
}
}
+
+ QColor aWireColor = aPolyline->GetWireColor();
+ setBorderColor( aWireColor, false, false );
}
else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Polyline3D) ) )
{
updateShape( false, false );
}
}
+
+ QColor aWireColor = aPolyline->GetBorderColor();
+ setBorderColor( aWireColor, false, false );
}
else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Zone) ) )
{
}
setWire( aProfileWire, false, false );
+
+ QColor aWireColor = aProfile->GetBorderColor();
+ setBorderColor( aWireColor, false, false );
}
else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Stream) ) ||
myObject->IsKind( STANDARD_TYPE(HYDROData_Channel) ) ||
// Set the object name
myEditedObject->SetName( anObjectName );
+ if ( !myIsEdit )
+ {
+ myEditedObject->SetFillingColor( HYDROData_Stream::DefaultFillingColor() );
+ myEditedObject->SetBorderColor( HYDROData_Stream::DefaultBorderColor() );
+ }
+
// Erase preview
erasePreview();
<source>FILLING_COLOR</source>
<translation>Filling color</translation>
</message>
+ <message>
+ <source>OBJECT_COLOR</source>
+ <translation>Object color</translation>
+ </message>
<message>
<source>TRANSPARENT</source>
<translation>Transparent</translation>