From: adv Date: Wed, 11 Dec 2013 13:05:54 +0000 (+0000) Subject: Coloring of objects (Bug #219). X-Git-Tag: BR_hydro_v_0_5~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2d99821157e770385d7af917b2d22d6aa3cacb7e;p=modules%2Fhydro.git Coloring of objects (Bug #219). --- diff --git a/src/HYDROData/HYDROData_Channel.cxx b/src/HYDROData/HYDROData_Channel.cxx index e1363d79..2640d5ef 100644 --- a/src/HYDROData/HYDROData_Channel.cxx +++ b/src/HYDROData/HYDROData_Channel.cxx @@ -14,6 +14,7 @@ #include #endif +#include #include #define PYTHON_CHANNEL_ID "KIND_CHANNEL" @@ -116,6 +117,26 @@ void HYDROData_Channel::Update() } } +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(); diff --git a/src/HYDROData/HYDROData_Channel.h b/src/HYDROData/HYDROData_Channel.h index 8ffa76a7..155f9e39 100644 --- a/src/HYDROData/HYDROData_Channel.h +++ b/src/HYDROData/HYDROData_Channel.h @@ -60,6 +60,16 @@ public: */ 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 @@ -96,6 +106,18 @@ public: 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; diff --git a/src/HYDROData/HYDROData_Digue.cxx b/src/HYDROData/HYDROData_Digue.cxx index 077d7e8b..5efa4406 100644 --- a/src/HYDROData/HYDROData_Digue.cxx +++ b/src/HYDROData/HYDROData_Digue.cxx @@ -5,6 +5,7 @@ #include +#include #include #define PYTHON_DIGUE_ID "KIND_DIGUE" @@ -44,5 +45,23 @@ QStringList HYDROData_Digue::DumpToPython( MapOfTreatedObjects& theTreatedObject 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(); +} diff --git a/src/HYDROData/HYDROData_Digue.h b/src/HYDROData/HYDROData_Digue.h index c4145d22..fcd8fb77 100644 --- a/src/HYDROData/HYDROData_Digue.h +++ b/src/HYDROData/HYDROData_Digue.h @@ -34,6 +34,28 @@ public: */ 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; diff --git a/src/HYDROData/HYDROData_IPolyline.cxx b/src/HYDROData/HYDROData_IPolyline.cxx index 687318cc..73675538 100755 --- a/src/HYDROData/HYDROData_IPolyline.cxx +++ b/src/HYDROData/HYDROData_IPolyline.cxx @@ -13,6 +13,8 @@ #include #include +#include + IMPLEMENT_STANDARD_HANDLE(HYDROData_IPolyline, HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IPolyline, HYDROData_Entity) @@ -25,6 +27,21 @@ HYDROData_IPolyline::~HYDROData_IPolyline() { } +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(); diff --git a/src/HYDROData/HYDROData_IPolyline.h b/src/HYDROData/HYDROData_IPolyline.h index 0d3d7442..1a7c63ae 100644 --- a/src/HYDROData/HYDROData_IPolyline.h +++ b/src/HYDROData/HYDROData_IPolyline.h @@ -37,11 +37,31 @@ protected: 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. */ diff --git a/src/HYDROData/HYDROData_ImmersibleZone.cxx b/src/HYDROData/HYDROData_ImmersibleZone.cxx index 38b83a61..eb3ae966 100644 --- a/src/HYDROData/HYDROData_ImmersibleZone.cxx +++ b/src/HYDROData/HYDROData_ImmersibleZone.cxx @@ -172,13 +172,12 @@ TopoDS_Shape HYDROData_ImmersibleZone::generateTopShape() const 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() @@ -186,6 +185,16 @@ 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 ); diff --git a/src/HYDROData/HYDROData_ImmersibleZone.h b/src/HYDROData/HYDROData_ImmersibleZone.h index d8ea781c..e71a5017 100644 --- a/src/HYDROData/HYDROData_ImmersibleZone.h +++ b/src/HYDROData/HYDROData_ImmersibleZone.h @@ -83,6 +83,18 @@ public: */ 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; diff --git a/src/HYDROData/HYDROData_Object.cxx b/src/HYDROData/HYDROData_Object.cxx index 5349d354..524916fc 100644 --- a/src/HYDROData/HYDROData_Object.cxx +++ b/src/HYDROData/HYDROData_Object.cxx @@ -159,7 +159,7 @@ void HYDROData_Object::SetFillingColor( const QColor& theColor ) QColor HYDROData_Object::GetFillingColor() const { - return GetColor( DefaultFillingColor(), DataTag_FillingColor ); + return GetColor( getDefaultFillingColor(), DataTag_FillingColor ); } void HYDROData_Object::SetBorderColor( const QColor& theColor ) @@ -169,7 +169,7 @@ 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() @@ -180,4 +180,15 @@ 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(); +} + diff --git a/src/HYDROData/HYDROData_Object.h b/src/HYDROData/HYDROData_Object.h index 3eb38248..80746563 100644 --- a/src/HYDROData/HYDROData_Object.h +++ b/src/HYDROData/HYDROData_Object.h @@ -126,6 +126,18 @@ public: */ 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: /** diff --git a/src/HYDROData/HYDROData_Obstacle.cxx b/src/HYDROData/HYDROData_Obstacle.cxx index b83e7cb8..6c89c52d 100644 --- a/src/HYDROData/HYDROData_Obstacle.cxx +++ b/src/HYDROData/HYDROData_Obstacle.cxx @@ -7,16 +7,24 @@ #include #include + #include #include + #include + #include + #include #include + #include + #include + #include +#include #include #include #include @@ -72,6 +80,26 @@ TopoDS_Shape HYDROData_Obstacle::GetShape3D() const 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 diff --git a/src/HYDROData/HYDROData_Obstacle.h b/src/HYDROData/HYDROData_Obstacle.h index 66db4c38..bfa194e6 100644 --- a/src/HYDROData/HYDROData_Obstacle.h +++ b/src/HYDROData/HYDROData_Obstacle.h @@ -46,6 +46,19 @@ public: */ 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. @@ -81,6 +94,18 @@ public: */ 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; diff --git a/src/HYDROData/HYDROData_Polyline3D.cxx b/src/HYDROData/HYDROData_Polyline3D.cxx index cf41020e..8bff09cb 100644 --- a/src/HYDROData/HYDROData_Polyline3D.cxx +++ b/src/HYDROData/HYDROData_Polyline3D.cxx @@ -12,6 +12,7 @@ #include #include +#include #include #define PYTHON_POLYLINE_ID "KIND_POLYLINE" @@ -126,6 +127,26 @@ void HYDROData_Polyline3D::Update() 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() ) diff --git a/src/HYDROData/HYDROData_Polyline3D.h b/src/HYDROData/HYDROData_Polyline3D.h index 16c6f6e6..e05cfdb9 100644 --- a/src/HYDROData/HYDROData_Polyline3D.h +++ b/src/HYDROData/HYDROData_Polyline3D.h @@ -66,6 +66,16 @@ public: */ 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 @@ -104,6 +114,16 @@ public: 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. diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx index 18dc1e4c..776e7db0 100755 --- a/src/HYDROData/HYDROData_PolylineXY.cxx +++ b/src/HYDROData/HYDROData_PolylineXY.cxx @@ -35,6 +35,7 @@ #include +#include #include #include @@ -107,6 +108,11 @@ QVariant HYDROData_PolylineXY::GetDataVariant() return aVarData; } +QColor HYDROData_PolylineXY::DefaultWireColor() +{ + return QColor( Qt::red ); +} + TopoDS_Shape HYDROData_PolylineXY::GetShape() { return getPolylineShape(); diff --git a/src/HYDROData/HYDROData_PolylineXY.h b/src/HYDROData/HYDROData_PolylineXY.h index 5ce65a94..d14212e1 100644 --- a/src/HYDROData/HYDROData_PolylineXY.h +++ b/src/HYDROData/HYDROData_PolylineXY.h @@ -45,6 +45,11 @@ public: */ HYDRODATA_EXPORT virtual QVariant GetDataVariant(); + /** + * Returns default wire color for new polyline. + */ + HYDRODATA_EXPORT static QColor DefaultWireColor(); + public: /** diff --git a/src/HYDROData/HYDROData_Profile.cxx b/src/HYDROData/HYDROData_Profile.cxx index ea90dad9..f2f8ba46 100755 --- a/src/HYDROData/HYDROData_Profile.cxx +++ b/src/HYDROData/HYDROData_Profile.cxx @@ -21,6 +21,7 @@ #include #include +#include #include #define PYTHON_PROFILE_ID "KIND_PROFILE" @@ -37,6 +38,24 @@ HYDROData_Profile::~HYDROData_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; @@ -90,25 +109,24 @@ void HYDROData_Profile::Update() 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 @@ -381,6 +399,8 @@ bool HYDROData_Profile::ImportFromFile( const Handle(HYDROData_Document)& theDoc aProfile->SetName( aProfileName ); aProfile->SetFilePath( theFileName ); + + aProfile->SetBorderColor( HYDROData_Profile::DefaultBorderColor() ); } return !aCreatedProfiles.IsEmpty(); diff --git a/src/HYDROData/HYDROData_Profile.h b/src/HYDROData/HYDROData_Profile.h index 9f8aa531..dc62e6fe 100644 --- a/src/HYDROData/HYDROData_Profile.h +++ b/src/HYDROData/HYDROData_Profile.h @@ -43,6 +43,11 @@ public: */ 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. */ @@ -61,10 +66,17 @@ public: 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. @@ -198,6 +210,16 @@ public: 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. diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index ec2b1cb9..e49b2b79 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -5,13 +5,19 @@ #include "HYDROData_PolylineXY.h" #include "HYDROData_Profile.h" -#include -#include -#include -#include - #include +#include + +#include + +#include +#include +#include +#include +#include +#include + #include #include #include @@ -20,33 +26,36 @@ #include #include #include + +#include + +#include +#include +#include +#include + +#include #include #include +#include + +#include #include #include #include #include #include #include -#include -#include -#include -#include -#include -#include -#include -typedef NCollection_DataMap HYDROData_DataMapOfRealOfHDProfile; -#include -#include -#include -#include -#include -#include #include #include + #include -#include + +#include + +#include +#include //#define DEB_STREAM 1 #ifdef DEB_STREAM @@ -58,6 +67,8 @@ typedef NCollection_DataMap HYDROData_ #define PYTHON_STREAM_ID "KIND_STREAM" +typedef NCollection_DataMap HYDROData_DataMapOfRealOfHDProfile; + IMPLEMENT_STANDARD_HANDLE(HYDROData_Stream,HYDROData_NaturalObject) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Stream,HYDROData_NaturalObject) @@ -111,11 +122,14 @@ TopoDS_Shape HYDROData_Stream::GetTopShape() const { 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); @@ -124,6 +138,7 @@ TopoDS_Shape HYDROData_Stream::GetShape3D() const aBSpline = anInterpolator.Curve(); return aBSpline; } + void HYDROData_Stream::Update() { HYDROData_NaturalObject::Update(); @@ -270,6 +285,26 @@ void HYDROData_Stream::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(); diff --git a/src/HYDROData/HYDROData_Stream.h b/src/HYDROData/HYDROData_Stream.h index 3ebc441a..e7bec195 100644 --- a/src/HYDROData/HYDROData_Stream.h +++ b/src/HYDROData/HYDROData_Stream.h @@ -63,6 +63,16 @@ public: */ 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 @@ -135,6 +145,16 @@ protected: */ 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 ); diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx index 4ccd4df4..0149a1c8 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx @@ -129,7 +129,7 @@ HYDROGUI_InputPanel* HYDROGUI_ChannelOp::createInputPanel() const } bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg ) { HYDROGUI_ChannelDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) @@ -158,7 +158,8 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags, myEditedObject->SetName( anObjectName ); - if ( !myIsEdit ) { + if ( !myIsEdit ) + { myEditedObject->SetFillingColor( HYDROData_Channel::DefaultFillingColor() ); myEditedObject->SetBorderColor( HYDROData_Channel::DefaultBorderColor() ); } diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.h b/src/HYDROGUI/HYDROGUI_ChannelOp.h index 25f47a37..ddb294ef 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelOp.h +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.h @@ -53,6 +53,7 @@ protected slots: protected: virtual void erasePreview(); + virtual Handle(HYDROData_Channel) getObjectToEdit() const; protected: diff --git a/src/HYDROGUI/HYDROGUI_ColorDlg.cxx b/src/HYDROGUI/HYDROGUI_ColorDlg.cxx index 278fdad2..5bc7f5fe 100644 --- a/src/HYDROGUI/HYDROGUI_ColorDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ColorDlg.cxx @@ -31,36 +31,63 @@ #include #include -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 ); @@ -76,12 +103,6 @@ HYDROGUI_ColorDlg::HYDROGUI_ColorDlg( QWidget* theParent ) 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 ); @@ -91,43 +112,67 @@ HYDROGUI_ColorDlg::HYDROGUI_ColorDlg( QWidget* theParent ) 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; } diff --git a/src/HYDROGUI/HYDROGUI_ColorDlg.h b/src/HYDROGUI/HYDROGUI_ColorDlg.h index 4287e266..c2acd295 100644 --- a/src/HYDROGUI/HYDROGUI_ColorDlg.h +++ b/src/HYDROGUI/HYDROGUI_ColorDlg.h @@ -34,14 +34,14 @@ class HYDROGUI_ColorDlg : public QDialog 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: @@ -52,6 +52,10 @@ private: QGroupBox* myBorderColorGroup; HYDROGUI_ColorWidget* myBorderColorBox; + + HYDROGUI_ColorWidget* myColorBox; + + bool myIsOneColor; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_DigueOp.cxx b/src/HYDROGUI/HYDROGUI_DigueOp.cxx index d62b1630..0d8c6073 100644 --- a/src/HYDROGUI/HYDROGUI_DigueOp.cxx +++ b/src/HYDROGUI/HYDROGUI_DigueOp.cxx @@ -24,6 +24,7 @@ #include "HYDROGUI_DigueDlg.h" #include "HYDROGUI_Tool.h" +#include "HYDROGUI_Shape.h" #include #include @@ -52,6 +53,21 @@ void HYDROGUI_DigueOp::startOperation() } } +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() ); diff --git a/src/HYDROGUI/HYDROGUI_DigueOp.h b/src/HYDROGUI/HYDROGUI_DigueOp.h index 87db05f8..429baf62 100644 --- a/src/HYDROGUI/HYDROGUI_DigueOp.h +++ b/src/HYDROGUI/HYDROGUI_DigueOp.h @@ -35,10 +35,14 @@ public: 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: diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx index 3e9fd482..276d51af 100644 --- a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx @@ -71,8 +71,6 @@ void HYDROGUI_ImmersibleZoneOp::startOperation() 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; @@ -83,9 +81,6 @@ void HYDROGUI_ImmersibleZoneOp::startOperation() { anObjectName = myEditedObject->GetName(); - aFillingColor = myEditedObject->GetFillingColor(); - aBorderColor = myEditedObject->GetBorderColor(); - Handle(HYDROData_PolylineXY) aRefPolyline = myEditedObject->GetPolyline(); if ( !aRefPolyline.IsNull() ) aSelectedPolyline = aRefPolyline->GetName(); @@ -214,7 +209,8 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags, aZoneObj->SetName( anObjectName ); - if ( !myIsEdit ) { + if ( !myIsEdit ) + { aZoneObj->SetFillingColor( HYDROData_ImmersibleZone::DefaultFillingColor() ); aZoneObj->SetBorderColor( HYDROData_ImmersibleZone::DefaultBorderColor() ); } diff --git a/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx b/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx index 4ba06589..44f3476d 100644 --- a/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx @@ -167,6 +167,9 @@ bool HYDROGUI_ImportGeomObjectOp::processApply( int& theUpdateFlags, 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; } diff --git a/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.cxx b/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.cxx index 0fc2e3e5..350c6d66 100644 --- a/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.cxx @@ -154,6 +154,9 @@ bool HYDROGUI_ImportObstacleFromFileOp::processApply( int& theUpdateFlags, // 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() ) { diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 5534edf5..f85b49a5 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -39,6 +39,7 @@ #include "HYDROGUI_VTKPrsDisplayer.h" #include "HYDROGUI_AbstractDisplayer.h" #include "HYDROGUI_PolylineOp.h" +#include "HYDROGUI_SetColorOp.h" #include #include @@ -305,8 +306,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, 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() ) { @@ -396,7 +397,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, anIsDummyObject3D = true; } - anIsGeomObject = HYDROData_Tool::IsGeometryObject( anObject ); + if ( !anIsObjectCanBeColored ) + anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject ); } // Check if all selected objects are profiles @@ -546,7 +548,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, } // Add set color action for geometrical objects - if ( anIsGeomObject ) + if ( anIsObjectCanBeColored ) { theMenu->addAction( action( SetColorId ) ); theMenu->addSeparator(); diff --git a/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx b/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx index 045e655d..0b0e1dea 100644 --- a/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx +++ b/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx @@ -156,11 +156,16 @@ bool HYDROGUI_Poly3DOp::processApply( int& theUpdateFlags, 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 ); diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx index b9fd474b..835b9d04 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx @@ -250,6 +250,11 @@ bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags, } } + if ( !myIsEdit ) + { + aPolylineObj->SetWireColor( HYDROData_PolylineXY::DefaultWireColor() ); + } + // Update the wire of polyline aPolylineObj->Update(); diff --git a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx index 8266fd7a..fa0ad6d7 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx @@ -223,6 +223,11 @@ bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags, aProfileUZ->SetSectionType( 0, aSectType ); + if ( !myIsEdit ) + { + aProfileObj->SetBorderColor( HYDROData_Profile::DefaultBorderColor() ); + } + aProfileObj->Update(); theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced; diff --git a/src/HYDROGUI/HYDROGUI_SetColorOp.cxx b/src/HYDROGUI/HYDROGUI_SetColorOp.cxx index 245e11c6..511f56b8 100644 --- a/src/HYDROGUI/HYDROGUI_SetColorOp.cxx +++ b/src/HYDROGUI/HYDROGUI_SetColorOp.cxx @@ -28,6 +28,9 @@ #include "HYDROGUI_Tool.h" #include "HYDROGUI_UpdateFlags.h" +#include +#include + #include #include @@ -44,52 +47,110 @@ HYDROGUI_SetColorOp::~HYDROGUI_SetColorOp() { } +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; } diff --git a/src/HYDROGUI/HYDROGUI_SetColorOp.h b/src/HYDROGUI/HYDROGUI_SetColorOp.h index 10d02b99..9fce5bd1 100644 --- a/src/HYDROGUI/HYDROGUI_SetColorOp.h +++ b/src/HYDROGUI/HYDROGUI_SetColorOp.h @@ -25,7 +25,7 @@ #include "HYDROGUI_Operation.h" -#include +#include class HYDROGUI_ColorDlg; @@ -37,6 +37,9 @@ public: HYDROGUI_SetColorOp( HYDROGUI_Module* theModule ); virtual ~HYDROGUI_SetColorOp(); + + static bool CanObjectBeColored( const Handle(HYDROData_Entity)& theObject ); + protected: virtual void startOperation(); @@ -45,7 +48,7 @@ protected: private: HYDROGUI_ColorDlg* myColorDlg; - Handle(HYDROData_Object) myEditedObject; + Handle(HYDROData_Entity) myEditedObject; }; #endif \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index 9967bc00..06c4a6f5 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -165,6 +165,9 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer ) updateShape( false, false ); } } + + QColor aWireColor = aPolyline->GetWireColor(); + setBorderColor( aWireColor, false, false ); } else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Polyline3D) ) ) { @@ -185,6 +188,9 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer ) updateShape( false, false ); } } + + QColor aWireColor = aPolyline->GetBorderColor(); + setBorderColor( aWireColor, false, false ); } else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Zone) ) ) { @@ -307,6 +313,9 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer ) } 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) ) || diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.cxx b/src/HYDROGUI/HYDROGUI_StreamOp.cxx index 78b1f3a9..1557a794 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamOp.cxx @@ -174,6 +174,12 @@ bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags, // Set the object name myEditedObject->SetName( anObjectName ); + if ( !myIsEdit ) + { + myEditedObject->SetFillingColor( HYDROData_Stream::DefaultFillingColor() ); + myEditedObject->SetBorderColor( HYDROData_Stream::DefaultBorderColor() ); + } + // Erase preview erasePreview(); diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 9d8c7006..c4fb0ed5 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -1599,6 +1599,10 @@ file cannot be correctly imported for an Obstacle definition. FILLING_COLOR Filling color + + OBJECT_COLOR + Object color + TRANSPARENT Transparent