#include <HYDROData_VisualState.h>
#include <HYDROData_Bathymetry.h>
#include <HYDROData_Calculation.h>
+#include <HYDROData_Zone.h>
#include <TDataStd_Name.hxx>
#include <NCollection_DataMap.hxx>
case KIND_CALCULATION:
aResult = new HYDROData_Calculation();
break;
+ case KIND_ZONE:
+ aResult = new HYDROData_Zone();
+ break;
}
if ( !aResult.IsNull() )
#include <TDF_CopyLabel.hxx>
#include <TDF_ListIteratorOfLabelList.hxx>
+#include <QColor>
#include <QString>
#include <QStringList>
#include <QVariant>
const int theIndex )
{
if ( theObj.IsNull() )
+ {
+ RemoveReferenceObject( theTag, theIndex );
return;
+ }
Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
return;
}
- Handle(HYDROData_Object) aRemovedObj = GetReferenceObject( theTag, theIndex );
- if ( aRemovedObj.IsNull() )
+ int anIndex = 0;
+ TDF_ListIteratorOfLabelList anIter( aRefs->List() );
+ for ( ; anIndex != theIndex && anIter.More(); anIter.Next(), ++anIndex );
+
+ if ( anIndex != theIndex )
return;
- aRefs->Remove( aRemovedObj->Label() );
+ const TDF_Label& aRefLabel = anIter.Value();
+ aRefs->Remove( aRefLabel );
}
void HYDROData_Object::ClearReferenceObjects( const int theTag )
return aRefs;
}
+
+void HYDROData_Object::SetColor( const QColor& theColor,
+ const int theTag )
+{
+ TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
+
+ Handle(TDataStd_IntegerArray) aColorArray;
+ if ( !aLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
+ aColorArray = TDataStd_IntegerArray::Set( aLabel, 1, 4 );
+
+ aColorArray->SetValue( 1, theColor.red() );
+ aColorArray->SetValue( 2, theColor.green() );
+ aColorArray->SetValue( 3, theColor.blue() );
+ aColorArray->SetValue( 4, theColor.alpha() );
+}
+
+QColor HYDROData_Object::GetColor( const QColor& theDefColor,
+ const int theTag ) const
+{
+ QColor aResColor = theDefColor;
+
+ TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
+
+ Handle(TDataStd_IntegerArray) aColorArray;
+ if ( aLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
+ {
+ aResColor.setRed( aColorArray->Value( 1 ) );
+ aResColor.setGreen( aColorArray->Value( 2 ) );
+ aResColor.setBlue( aColorArray->Value( 3 ) );
+ aResColor.setAlpha( aColorArray->Value( 4 ) );
+ }
+
+ return aResColor;
+}
\ No newline at end of file
#include <TDF_Label.hxx>
#include <QMap>
+class QColor;
class QString;
class QVariant;
class QStringList;
*/
void ClearReferenceObjects( const int theTag = 0 );
+ /**
+ * Internal method that used to store the color attribute
+ * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
+ * \param theColor color to save
+ */
+ void SetColor( const QColor& theColor, const int theTag = 0 );
+
+ /**
+ * Internal method that used to retreive the color attribute
+ * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
+ * \param theDefColor default color to return if attribute has not been set before
+ */
+ QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
+
protected:
Handle(TDataStd_ReferenceList) getReferenceList( const int theTag,
const bool theIsCreate ) const;
+
protected:
/// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
TDF_Label myLab; ///< label of this object
return aResList;
}
-void HYDROData_Zone::SetColor( const QColor& theColor )
+QColor HYDROData_Zone::DefaultFillingColor()
{
- Handle(TDataStd_IntegerArray) aColorArray;
- if ( !myLab.FindChild( DataTag_Color ).FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
- aColorArray = TDataStd_IntegerArray::Set( myLab.FindChild( DataTag_Color ), 1, 4 );
+ return QColor( Qt::green );
+}
- aColorArray->SetValue( 1, theColor.red() );
- aColorArray->SetValue( 2, theColor.green() );
- aColorArray->SetValue( 3, theColor.blue() );
- aColorArray->SetValue( 4, theColor.alpha() );
+void HYDROData_Zone::SetFillingColor( const QColor& theColor )
+{
+ return SetColor( theColor, DataTag_FillingColor );
}
-QColor HYDROData_Zone::GetColor() const
+QColor HYDROData_Zone::GetFillingColor() const
{
- QColor aResColor( Qt::green );
+ return GetColor( DefaultFillingColor(), DataTag_FillingColor );
+}
- Handle(TDataStd_IntegerArray) aColorArray;
- if ( myLab.FindChild( DataTag_Color ).FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
- {
- aResColor.setRed( aColorArray->Value( 1 ) );
- aResColor.setGreen( aColorArray->Value( 2 ) );
- aResColor.setBlue( aColorArray->Value( 3 ) );
- aResColor.setAlpha( aColorArray->Value( 4 ) );
- }
+QColor HYDROData_Zone::DefaultBorderColor()
+{
+ return QColor( Qt::transparent );
+}
- return aResColor;
+void HYDROData_Zone::SetBorderColor( const QColor& theColor )
+{
+ return SetColor( theColor, DataTag_BorderColor );
+}
+
+QColor HYDROData_Zone::GetBorderColor() const
+{
+ return GetColor( DefaultBorderColor(), DataTag_BorderColor );
}
void HYDROData_Zone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline )
enum DataTag
{
DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
- DataTag_Bathymetry, ///< reference bathymetries
- DataTag_Polyline, ///< reference polyline
- DataTag_Color ///< color of zone
+ DataTag_Bathymetry, ///< reference bathymetries
+ DataTag_Polyline, ///< reference polyline
+ DataTag_FillingColor, ///< filling color of zone
+ DataTag_BorderColor, ///< border color of zone
};
public:
/**
- * Sets color for zone.
+ * Returns default filling color for new zone.
*/
- HYDRODATA_EXPORT virtual void SetColor( const QColor& theColor );
+ HYDRODATA_EXPORT static QColor DefaultFillingColor();
/**
- * Returns color of zone.
+ * Sets filling color for zone.
*/
- HYDRODATA_EXPORT virtual QColor GetColor() const;
+ HYDRODATA_EXPORT virtual void SetFillingColor( const QColor& theColor );
+
+ /**
+ * Returns filling color of zone.
+ */
+ HYDRODATA_EXPORT virtual QColor GetFillingColor() const;
+
+
+ /**
+ * Returns default border color for new zone.
+ */
+ HYDRODATA_EXPORT static QColor DefaultBorderColor();
+
+ /**
+ * Sets border color for zone.
+ */
+ HYDRODATA_EXPORT virtual void SetBorderColor( const QColor& theColor );
+
+ /**
+ * Returns border color of zone.
+ */
+ HYDRODATA_EXPORT virtual QColor GetBorderColor() const;
/**
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9,00"
+ Version="9.00"
Name="HYDROGUI"
ProjectGUID="{D11F0AD0-D002-4A22-A8E6-3F906379206F}"
RootNamespace="HYDROGUI"
RelativePath=".\HYDROGUI_PrsPolylineDriver.cxx"
>
</File>
+ <File
+ RelativePath=".\HYDROGUI_PrsZone.cxx"
+ >
+ </File>
+ <File
+ RelativePath=".\HYDROGUI_PrsZoneDriver.cxx"
+ >
+ </File>
<File
RelativePath=".\HYDROGUI_ShowHideOp.cxx"
>
RelativePath=".\HYDROGUI_VisualStateOp.cxx"
>
</File>
+ <File
+ RelativePath=".\HYDROGUI_ZoneDlg.cxx"
+ >
+ </File>
+ <File
+ RelativePath=".\HYDROGUI_ZoneOp.cxx"
+ >
+ </File>
<Filter
Name="Link"
>
<Tool
Name="VCCustomBuildTool"
Description="Generating moc_$(InputName).cxx"
- CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx"
+ CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx
"
Outputs="moc/moc_$(InputName).cxx"
/>
</FileConfiguration>
RelativePath=".\HYDROGUI_PrsPolylineDriver.h"
>
</File>
+ <File
+ RelativePath=".\HYDROGUI_PrsZone.h"
+ >
+ </File>
+ <File
+ RelativePath=".\HYDROGUI_PrsZoneDriver.h"
+ >
+ </File>
<File
RelativePath=".\HYDROGUI_ShowHideOp.h"
>
/>
</FileConfiguration>
</File>
+ <File
+ RelativePath=".\HYDROGUI_ZoneDlg.h"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating moc_$(InputName).cxx"
+ CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx"
+ Outputs="moc/moc_$(InputName).cxx"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\HYDROGUI_ZoneOp.h"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating moc_$(InputName).cxx"
+ CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx"
+ Outputs="moc/moc_$(InputName).cxx"
+ />
+ </FileConfiguration>
+ </File>
</Filter>
<Filter
Name="Resource Files"
RelativePath=".\moc\moc_HYDROGUI_VisualStateOp.cxx"
>
</File>
+ <File
+ RelativePath=".\moc\moc_HYDROGUI_ZoneDlg.cxx"
+ >
+ </File>
+ <File
+ RelativePath=".\moc\moc_HYDROGUI_ZoneOp.cxx"
+ >
+ </File>
</Filter>
</Files>
<Globals>
#include <HYDROData_Iterator.h>
#include <HYDROData_Polyline.h>
#include <HYDROData_VisualState.h>
+#include <HYDROData_Zone.h>
#include <CAM_Application.h>
#include <CAM_DataObject.h>
Handle(HYDROData_Image) anImageObj =
Handle(HYDROData_Image)::DownCast( anIterator.Current() );
if( !anImageObj.IsNull() )
- {
- if( LightApp_DataObject* anImageDataObj = createObject( anImageRootObj, anImageObj ) )
- {
- for( int anIndex = 0, aNbRef = anImageObj->NbReferences(); anIndex < aNbRef; anIndex++ )
- {
- Handle(HYDROData_Object) aRefObj = anImageObj->Reference( anIndex );
- if( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
- createObject( anImageDataObj, aRefObj, anImageDataObj->entry() );
- }
- }
- }
+ createObject( anImageRootObj, anImageObj );
}
LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, partitionName( KIND_BATHYMETRY ) );
createObject( aPolylineRootObj, aPolylineObj );
}
+ LightApp_DataObject* aZonesRootObj = createObject( aRootObj, partitionName( KIND_ZONE ) );
+
+ anIterator = HYDROData_Iterator( aDocument, KIND_ZONE );
+ for( ; anIterator.More(); anIterator.Next() )
+ {
+ Handle(HYDROData_Zone) aZoneObj =
+ Handle(HYDROData_Zone)::DownCast( anIterator.Current() );
+ if( !aZoneObj.IsNull() )
+ createObject( aZonesRootObj, aZoneObj );
+ }
+
LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, partitionName( KIND_VISUAL_STATE ) );
anIterator = HYDROData_Iterator( aDocument, KIND_VISUAL_STATE );
case KIND_VISUAL_STATE: return "VISUAL_STATES";
case KIND_BATHYMETRY: return "BATHYMETRIES";
case KIND_CALCULATION: return "CALCULATION_CASES";
+ case KIND_ZONE: return "ZONES";
default: break;
}
return QString();
return HYDROData_Document::Document( aStudyId );
}
-LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
+LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
Handle(HYDROData_Object) theModelObject,
- const QString& theParentEntry )
+ const QString& theParentEntry )
{
- return new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
+ HYDROGUI_DataObject* aResObj =
+ new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
+ buildObjectTree( theParent, aResObj, theParentEntry );
+ return aResObj;
}
LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
- const QString& theName )
+ const QString& theName,
+ const QString& theParentEntry )
+{
+ return new HYDROGUI_NamedObject( theParent, theName, theParentEntry );
+}
+
+void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
+ SUIT_DataObject* theObject,
+ const QString& theParentEntry )
{
- return new HYDROGUI_NamedObject( theParent, theName );
+ HYDROGUI_DataObject* aGuiObj = dynamic_cast<HYDROGUI_DataObject*>( theObject );
+ if ( !aGuiObj )
+ return;
+
+ Handle(HYDROData_Object) aDataObj = aGuiObj->modelObject();
+ if ( aDataObj.IsNull() )
+ return;
+
+ ObjectKind anObjectKind = aDataObj->GetKind();
+
+ if ( anObjectKind == KIND_IMAGE )
+ {
+ Handle(HYDROData_Image) anImageObj =
+ Handle(HYDROData_Image)::DownCast( aDataObj );
+ for ( int anIndex = 0, aNbRef = anImageObj->NbReferences(); anIndex < aNbRef; anIndex++ )
+ {
+ Handle(HYDROData_Object) aRefObj = anImageObj->Reference( anIndex );
+ if ( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
+ createObject( aGuiObj, aRefObj, aGuiObj->entry() );
+ }
+ }
+ else if ( anObjectKind == KIND_ZONE )
+ {
+ Handle(HYDROData_Zone) aZoneObj =
+ Handle(HYDROData_Zone)::DownCast( aDataObj );
+
+ LightApp_DataObject* aPolylineSect = createObject( aGuiObj, tr( "ZONE_POLYLINE" ), aGuiObj->entry() );
+
+ Handle(HYDROData_Polyline) aPolyline = aZoneObj->GetPolyline();
+ if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() )
+ createObject( aPolylineSect, aPolyline, aGuiObj->entry() );
+
+ LightApp_DataObject* aBathsSect = createObject( aGuiObj, tr( "ZONE_BATHYMETRIES" ), aGuiObj->entry() );
+
+ HYDROData_SequenceOfObjects aZoneBaths = aZoneObj->GetBathymetries();
+ HYDROData_SequenceOfObjects::Iterator aBathsIter( aZoneBaths );
+ for ( ; aBathsIter.More(); aBathsIter.Next() )
+ {
+ Handle(HYDROData_Bathymetry) aRefBath =
+ Handle(HYDROData_Bathymetry)::DownCast( aBathsIter.Value() );
+ if( !aRefBath.IsNull() && !aRefBath->IsRemoved() )
+ createObject( aBathsSect, aRefBath, aGuiObj->entry() );
+ }
+ }
}
void HYDROGUI_DataModel::removeChild( SUIT_DataObject* theParent,
/**
* Creates the GUI data object according to the model object.
* \param theParent a created object will be appended as a child of this object
- * \param theObject model object
+ * \param theModelObject model object
+ * \param theParentEntry entry of parent object
*/
- LightApp_DataObject* createObject( SUIT_DataObject* theParent,
+ LightApp_DataObject* createObject( SUIT_DataObject* theParent,
Handle(HYDROData_Object) theModelObject,
- const QString& theParentEntry = QString() );
+ const QString& theParentEntry = QString() );
/**
* Creates the GUI data object without corresponding model object: just by name
* \param theParent a created object will be appended as a child of this object
* \param theName name of this object
+ * \param theParentEntry entry of parent object
*/
LightApp_DataObject* createObject( SUIT_DataObject* theParent,
- const QString& theName );
+ const QString& theName,
+ const QString& theParentEntry = QString() );
+
+ /**
+ * Build tree of model object.
+ * \param theParent a created object will be appended as a child of this object
+ * \param theObject gui object for which the tree will be build
+ * \param theParentEntry entry of parent object
+ */
+ void buildObjectTree( SUIT_DataObject* theParent,
+ SUIT_DataObject* theObject,
+ const QString& theParentEntry = QString() );
/**
* Removes data object from the tree.
}
HYDROGUI_NamedObject::HYDROGUI_NamedObject( SUIT_DataObject* theParent,
- const QString& theName )
+ const QString& theName,
+ const QString& theParentEntry )
: CAM_DataObject( theParent ),
LightApp_DataObject( theParent ),
- myName( theName )
+ myName( theName ),
+ myParentEntry( theParentEntry )
{
}
QString HYDROGUI_NamedObject::entry() const
{
- //return LightApp_DataObject::entry();
- return HYDROGUI_DataObject::entryPrefix() + name();
+ QString anEntry = HYDROGUI_DataObject::entryPrefix() + name();
+ if( !myParentEntry.isEmpty() )
+ anEntry.prepend( myParentEntry + "_" );
+ return anEntry;
}
QString HYDROGUI_NamedObject::name() const
* \param theName displayed name
*/
HYDROGUI_NamedObject( SUIT_DataObject* theParent,
- const QString& theName );
+ const QString& theName,
+ const QString& theParentEntry );
/**
* Returns the unique object identifier string.
private:
QString myName; ///< name in the OB
+ QString myParentEntry;
};
#endif
#include "HYDROGUI_Prs.h"
#include "HYDROGUI_PrsImageDriver.h"
#include "HYDROGUI_PrsPolylineDriver.h"
+#include "HYDROGUI_PrsZoneDriver.h"
#include "HYDROGUI_Tool.h"
#include <GraphicsView_Viewer.h>
{
case KIND_IMAGE:
aDriver = new HYDROGUI_PrsImageDriver();
- myPrsDriversMap[ aKind ] = aDriver;
break;
case KIND_POLYLINE:
aDriver = new HYDROGUI_PrsPolylineDriver();
- myPrsDriversMap[ aKind ] = aDriver;
+ break;
+ case KIND_ZONE:
+ aDriver = new HYDROGUI_PrsZoneDriver();
break;
default:
break;
}
+
+ if ( aDriver )
+ myPrsDriversMap[ aKind ] = aDriver;
}
+
return aDriver;
}
bool anIsMustBeUpdatedImage = false;
bool anIsPolyline = false;
bool anIsCalculation = false;
+ bool anIsZone = false;
bool anIsVisualState = false;
// check the selected data model objects
anIsPolyline = true;
else if( anObject->GetKind() == KIND_CALCULATION )
anIsCalculation = true;
+ else if( anObject->GetKind() == KIND_ZONE )
+ anIsZone = true;
else if( anObject->GetKind() == KIND_VISUAL_STATE )
anIsVisualState = true;
}
case KIND_CALCULATION:
theMenu->addAction( action( CreateCalculationId ) );
break;
+ case KIND_ZONE:
+ theMenu->addAction( action( CreateZoneId ) );
+ break;
}
theMenu->addSeparator();
}
theMenu->addAction( action( EditCalculationId ) );
theMenu->addSeparator();
}
+ else if( anIsZone )
+ {
+ theMenu->addAction( action( EditZoneId ) );
+ theMenu->addSeparator();
+ }
else if( anIsVisualState && anIsObjectBrowser )
{
theMenu->addAction( action( SaveVisualStateId ) );
theMenu->addSeparator();
}
- if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline ) )
+ if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline || anIsZone ) )
{
if( anIsHiddenInSelection )
theMenu->addAction( action( ShowId ) );
enum CustomEvent { NewViewEvent = QEvent::User + 100 };
public:
- enum ViewManagerRole { VMR_Unknown = 0, VMR_General, VMR_TransformImage, VMR_ObserveImage };
+
+ enum ViewManagerRole { VMR_Unknown = 0, VMR_General,
+ VMR_TransformImage, VMR_ObserveImage,
+ VMR_PreviewZone };
typedef QPair< SUIT_ViewManager*, ViewManagerRole > ViewManagerInfo;
typedef QMap < int, ViewManagerInfo > ViewManagerMap;
#include "HYDROGUI_UpdateFlags.h"
#include "HYDROGUI_UpdateImageOp.h"
#include "HYDROGUI_VisualStateOp.h"
+#include "HYDROGUI_ZoneOp.h"
#include <CAM_Application.h>
createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "", Qt::CTRL + Qt::Key_B );
+ createAction( CreateZoneId, "CREATE_ZONE" );
+ createAction( EditZoneId, "EDIT_ZONE" );
+
createAction( CreateCalculationId, "CREATE_CALCULATION" );
createAction( EditCalculationId, "EDIT_CALCULATION" );
createMenu( ImportImageId, aHydroId, -1, -1 );
createMenu( ImportBathymetryId, aHydroId, -1, -1 );
createMenu( CreatePolylineId, aHydroId, -1, -1 );
+ createMenu( CreateZoneId, aHydroId, -1, -1 );
createMenu( CreateCalculationId, aHydroId, -1, -1 );
createMenu( separator(), aHydroId );
createMenu( FuseImagesId, aHydroId, -1, -1 );
case ImportBathymetryId:
anOp = new HYDROGUI_ImportBathymetryOp( aModule );
break;
+ case CreateZoneId:
+ case EditZoneId:
+ anOp = new HYDROGUI_ZoneOp( aModule, theId == EditZoneId );
+ break;
case CreateCalculationId:
case EditCalculationId:
anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId );
ImportBathymetryId,
EditImportedBathymetryId,
+ CreateZoneId,
+ EditZoneId,
+
CreateCalculationId,
EditCalculationId,
--- /dev/null
+// 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
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_PrsZone.h"
+
+#include <QBrush>
+#include <QPen>
+
+//=======================================================================
+// name : HYDROGUI_PrsZone
+// Purpose : Constructor
+//=======================================================================
+HYDROGUI_PrsZone::HYDROGUI_PrsZone( const Handle(HYDROData_Object)& theObject )
+: HYDROGUI_Prs( theObject ),
+ myZoneItem( 0 ),
+ myFillingColor( Qt::transparent ),
+ myBorderColor( Qt::transparent )
+{
+}
+
+//=======================================================================
+// name : HYDROGUI_PrsZone
+// Purpose : Destructor
+//=======================================================================
+HYDROGUI_PrsZone::~HYDROGUI_PrsZone()
+{
+}
+
+//================================================================
+// Function : setPath
+// Purpose :
+//================================================================
+void HYDROGUI_PrsZone::setPath( const QPainterPath& thePath )
+{
+ myPath = thePath;
+}
+
+//================================================================
+// Function : getPath
+// Purpose :
+//================================================================
+QPainterPath HYDROGUI_PrsZone::getPath() const
+{
+ return myPath;
+}
+
+//================================================================
+// Function : setFillingColor
+// Purpose :
+//================================================================
+void HYDROGUI_PrsZone::setFillingColor( const QColor& theColor )
+{
+ myFillingColor = theColor;
+}
+
+//================================================================
+// Function : getFillingColor
+// Purpose :
+//================================================================
+QColor HYDROGUI_PrsZone::getFillingColor() const
+{
+ return myFillingColor;
+}
+
+//================================================================
+// Function : setBorderColor
+// Purpose :
+//================================================================
+void HYDROGUI_PrsZone::setBorderColor( const QColor& theColor )
+{
+ myBorderColor = theColor;
+}
+
+//================================================================
+// Function : getBorderColor
+// Purpose :
+//================================================================
+QColor HYDROGUI_PrsZone::getBorderColor() const
+{
+ return myBorderColor;
+}
+
+//================================================================
+// Function : boundingRect
+// Purpose :
+//================================================================
+QRectF HYDROGUI_PrsZone::boundingRect() const
+{
+ return myZoneItem->boundingRect();
+}
+
+//================================================================
+// Function : compute
+// Purpose :
+//================================================================
+void HYDROGUI_PrsZone::compute()
+{
+ if( !myZoneItem )
+ {
+ myZoneItem = new QGraphicsPathItem( this );
+ addToGroup( myZoneItem );
+ }
+
+ QPainterPath aPath( myPath );
+ aPath.setFillRule( Qt::WindingFill );
+
+ myZoneItem->setPath( aPath );
+ myZoneItem->setBrush( QBrush( myFillingColor ) );
+ myZoneItem->setPen( QPen( myBorderColor ) );
+}
+
+//================================================================
+// Function : checkHighlight
+// Purpose :
+//================================================================
+bool HYDROGUI_PrsZone::checkHighlight( double theX, double theY, QCursor& theCursor ) const
+{
+ // to do
+ return false;
+}
+
+//================================================================
+// Function : select
+// Purpose :
+//================================================================
+bool HYDROGUI_PrsZone::select( double theX, double theY, const QRectF& theRect )
+{
+ return GraphicsView_Object::select( theX, theY, theRect );
+}
+
+//================================================================
+// Function : unselect
+// Purpose :
+//================================================================
+void HYDROGUI_PrsZone::unselect()
+{
+ GraphicsView_Object::unselect();
+}
+
+//================================================================
+// Function : setSelected
+// Purpose :
+//================================================================
+void HYDROGUI_PrsZone::setSelected( bool theState )
+{
+ GraphicsView_Object::setSelected( theState );
+}
--- /dev/null
+// 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
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_PRSZONE_H
+#define HYDROGUI_PRSZONE_H
+
+#include "HYDROGUI_Prs.h"
+
+/*
+ Class : HYDROGUI_PrsZone
+ Description : Presentation for zone object
+*/
+class HYDROGUI_PrsZone : public HYDROGUI_Prs
+{
+public:
+ HYDROGUI_PrsZone( const Handle(HYDROData_Object)& theObject );
+ virtual ~HYDROGUI_PrsZone();
+
+public:
+ void setPath( const QPainterPath& thePath );
+ QPainterPath getPath() const;
+
+ void setFillingColor( const QColor& theColor );
+ QColor getFillingColor() const;
+
+ void setBorderColor( const QColor& theColor );
+ QColor getBorderColor() const;
+
+public:
+ // from QGraphicsItem
+ virtual QRectF boundingRect() const;
+
+ // from GraphicsView_Object
+ virtual void compute();
+
+ virtual bool isMovable() const { return false; }
+
+ virtual bool checkHighlight( double theX, double theY, QCursor& theCursor ) const;
+
+ virtual bool select( double theX, double theY, const QRectF& theRect );
+ virtual void unselect();
+ virtual void setSelected( bool theState );
+
+protected:
+ QGraphicsPathItem* myZoneItem;
+
+ QPainterPath myPath;
+ QColor myFillingColor;
+ QColor myBorderColor;
+};
+
+#endif
--- /dev/null
+// 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
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_PrsZoneDriver.h"
+
+#include "HYDROGUI_PrsZone.h"
+
+#include <HYDROData_Zone.h>
+
+HYDROGUI_PrsZoneDriver::HYDROGUI_PrsZoneDriver()
+:HYDROGUI_PrsDriver()
+{
+}
+
+HYDROGUI_PrsZoneDriver::~HYDROGUI_PrsZoneDriver()
+{
+}
+
+bool HYDROGUI_PrsZoneDriver::Update( const Handle(HYDROData_Object)& theObj,
+ HYDROGUI_Prs*& thePrs )
+{
+ HYDROGUI_PrsDriver::Update( theObj, thePrs );
+
+ if ( theObj.IsNull() )
+ return false;
+
+ Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( theObj );
+ if ( aZone.IsNull() )
+ return false;
+
+ if ( !thePrs )
+ thePrs = new HYDROGUI_PrsZone( theObj );
+
+ HYDROGUI_PrsZone* aPrsZone = (HYDROGUI_PrsZone*)thePrs;
+
+ aPrsZone->setName( aZone->GetName() );
+
+ aPrsZone->setFillingColor( aZone->GetFillingColor() );
+ aPrsZone->setBorderColor( aZone->GetBorderColor() );
+
+ aPrsZone->setPath( aZone->GetPainterPath() );
+
+ aPrsZone->compute();
+
+ return true;
+}
--- /dev/null
+// 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
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_PRSZONEDRIVER_H
+#define HYDROGUI_PRSZONEDRIVER_H
+
+#include <HYDROGUI_PrsDriver.h>
+
+/**
+ * \class HYDROGUI_PrsZoneDriver
+ * \brief Presentation driver for zone objects.
+ */
+class HYDROGUI_PrsZoneDriver : public HYDROGUI_PrsDriver
+{
+public:
+ /**
+ * \brief Constructor.
+ */
+ HYDROGUI_PrsZoneDriver();
+
+ /**
+ * \brief Destructor.
+ */
+ virtual ~HYDROGUI_PrsZoneDriver();
+
+public:
+ /**
+ * \brief Update or create the polyline presentation on a basis of data object.
+ * \param theObj data object
+ * \param thePrs presentation
+ * \return status of the operation
+ */
+ virtual bool Update( const Handle(HYDROData_Object)& theObj,
+ HYDROGUI_Prs*& thePrs );
+};
+
+#endif
if( !anObject.IsNull() )
theSeq.Append( anObject );
}
+
+ anIterator = HYDROData_Iterator( aDocument, KIND_ZONE );
+ for( ; anIterator.More(); anIterator.Next() )
+ {
+ Handle(HYDROData_Object) anObject = anIterator.Current();
+ if( !anObject.IsNull() )
+ theSeq.Append( anObject );
+ }
}
HYDROGUI_Prs* HYDROGUI_Tool::GetPresentation( const Handle(HYDROData_Object)& theObj,
--- /dev/null
+// 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
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_ZoneDlg.h"
+
+#include "HYDROGUI_ColorWidget.h"
+#include "HYDROGUI_Tool.h"
+
+#include <QComboBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLayout>
+#include <QLineEdit>
+#include <QListWidget>
+#include <QRadioButton>
+
+HYDROGUI_ZoneDlg::HYDROGUI_ZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle )
+{
+ // 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->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ QBoxLayout* aPolyLayout = new QHBoxLayout( aPolylineFrame );
+ aPolyLayout->setMargin( 0 );
+ aPolyLayout->setSpacing( 5 );
+ aPolyLayout->addWidget( new QLabel( tr( "ZONE_POLYLINE" ), aPolylineFrame ) );
+ 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 );
+ aParamLayout->setMargin( 5 );
+ aParamLayout->setSpacing( 5 );
+ aParamLayout->addWidget( aPolylineFrame );
+ aParamLayout->addWidget( aFillingFrame );
+ aParamLayout->addWidget( myBorderColorGroup );
+
+
+ QGroupBox* aBathGroup = new QGroupBox( tr( "ZONE_BATHYMETRIES" ), mainFrame() );
+
+ myBathymetries = new QListWidget( aBathGroup );
+ myBathymetries->setSelectionMode( QListWidget::SingleSelection );
+ myBathymetries->setEditTriggers( QListWidget::NoEditTriggers );
+ myBathymetries->setViewMode( QListWidget::ListMode );
+
+ QBoxLayout* aBathLayout = new QHBoxLayout( aBathGroup );
+ aBathLayout->setMargin( 5 );
+ aBathLayout->setSpacing( 5 );
+ aBathLayout->addWidget( myBathymetries );
+
+
+ // Common
+ addWidget( myObjectNameGroup );
+ addWidget( aParamGroup );
+ addWidget( aBathGroup );
+
+ addStretch();
+
+
+ // Connect signals and slots
+ connect( myPolylines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onZoneDefChanged() ) );
+ connect( myFillingTransparent, SIGNAL( toggled( bool ) ), this, SLOT( onZoneDefChanged() ) );
+ connect( myFillingColor, SIGNAL( toggled( bool ) ), this, SLOT( onZoneDefChanged() ) );
+ 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_ZoneDlg::~HYDROGUI_ZoneDlg()
+{
+}
+
+void HYDROGUI_ZoneDlg::reset()
+{
+ bool isBlocked = blockSignals( true );
+
+ myObjectName->clear();
+
+ myPolylines->clear();
+ myBathymetries->clear();
+
+ myFillingTransparent->setChecked( true );
+ myFillingColorBox->resetColor();
+
+ myBorderColorGroup->setChecked( false );
+ myBorderColorBox->resetColor();
+
+ blockSignals( isBlocked );
+
+ onZoneDefChanged();
+}
+
+void HYDROGUI_ZoneDlg::setObjectName( const QString& theName )
+{
+ myObjectName->setText( theName );
+}
+
+QString HYDROGUI_ZoneDlg::getObjectName() const
+{
+ return myObjectName->text();
+}
+
+void HYDROGUI_ZoneDlg::setPolylineNames( const QStringList& thePolylines )
+{
+ bool isBlocked = blockSignals( true );
+
+ myPolylines->clear();
+ myPolylines->addItems( thePolylines );
+
+ blockSignals( isBlocked );
+}
+
+void HYDROGUI_ZoneDlg::setPolylineName( const QString& theName )
+{
+ myPolylines->setCurrentIndex( myPolylines->findText( theName ) );
+}
+
+QString HYDROGUI_ZoneDlg::getPolylineName() const
+{
+ return myPolylines->currentText();
+}
+
+void HYDROGUI_ZoneDlg::setBathymetries( const QStringList& theBathymetries )
+{
+ myBathymetries->clear();
+
+ for ( int i = 0, n = theBathymetries.length(); i < n; ++i )
+ {
+ QString aBathymetryName = theBathymetries.at( i );
+
+ QListWidgetItem* aListItem = new QListWidgetItem( aBathymetryName, myBathymetries );
+ aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable );
+ aListItem->setCheckState( Qt::Unchecked );
+ }
+}
+
+void HYDROGUI_ZoneDlg::setSelectedBathymetries( const QStringList& theBathymetries )
+{
+ for ( int i = 0, n = theBathymetries.length(); i < n; ++i )
+ {
+ QString aBathymetryName = theBathymetries.at( i );
+
+ QList<QListWidgetItem *> anItems =
+ myBathymetries->findItems( aBathymetryName, Qt::MatchFixedString | Qt::MatchCaseSensitive );
+ if ( anItems.isEmpty() )
+ continue;
+
+ QListWidgetItem* aListItem = anItems.first();
+ if ( !aListItem )
+ continue;
+
+ aListItem->setCheckState( Qt::Checked );
+ }
+}
+
+QStringList HYDROGUI_ZoneDlg::getSelectedBathymetries() const
+{
+ QStringList aResList;
+
+ for ( int i = 0, n = myBathymetries->count(); i < n; ++i )
+ {
+ QListWidgetItem* aListItem = myBathymetries->item( i );
+ if ( !aListItem || aListItem->checkState() != Qt::Checked )
+ continue;
+
+ QString aSelBathName = aListItem->text();
+ aResList.append( aSelBathName );
+ }
+
+ return aResList;
+}
+
+void HYDROGUI_ZoneDlg::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_ZoneDlg::getFillingColor() const
+{
+ QColor aColor( 255, 255, 255, 0 ); // transparent
+ if( myFillingColor->isChecked() )
+ aColor = myFillingColorBox->color();
+ return aColor;
+}
+
+void HYDROGUI_ZoneDlg::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_ZoneDlg::getBorderColor() const
+{
+ QColor aColor( Qt::transparent ); // transparent
+ if( myBorderColorGroup->isChecked() )
+ aColor = myBorderColorBox->color();
+ return aColor;
+}
+
+void HYDROGUI_ZoneDlg::onFillingColorChanged()
+{
+ if ( !myFillingColor->isChecked() )
+ return;
+
+ onZoneDefChanged();
+}
+
+void HYDROGUI_ZoneDlg::onZoneDefChanged()
+{
+ if ( signalsBlocked() )
+ return;
+
+ QString aPolylineName = getPolylineName();
+ emit CreatePreview( aPolylineName );
+}
+
+
--- /dev/null
+// 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
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_ZONEDLG_H
+#define HYDROGUI_ZONEDLG_H
+
+#include "HYDROGUI_InputPanel.h"
+
+class HYDROGUI_ColorWidget;
+class QComboBox;
+class QGroupBox;
+class QLineEdit;
+class QListWidget;
+class QRadioButton;
+
+class HYDROGUI_ZoneDlg : public HYDROGUI_InputPanel
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_ZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle );
+ virtual ~HYDROGUI_ZoneDlg();
+
+ void reset();
+
+ void setObjectName( const QString& theName );
+ QString getObjectName() const;
+
+ void setPolylineNames( const QStringList& thePolylines );
+ void setPolylineName( const QString& thePolyline );
+ QString getPolylineName() const;
+
+ void setBathymetries( const QStringList& theBathymetries );
+ void setSelectedBathymetries( const QStringList& theBathymetries );
+ QStringList getSelectedBathymetries() const;
+
+ void setFillingColor( const QColor& theColor );
+ QColor getFillingColor() const;
+
+ void setBorderColor( const QColor& theColor );
+ QColor getBorderColor() const;
+
+signals:
+ void CreatePreview( const QString& thePolylineName );
+
+private slots:
+ void onZoneDefChanged();
+ void onFillingColorChanged();
+
+private:
+
+ QGroupBox* myObjectNameGroup;
+ QLineEdit* myObjectName;
+
+ QComboBox* myPolylines;
+ QListWidget* myBathymetries;
+
+ QRadioButton* myFillingTransparent;
+ QRadioButton* myFillingColor;
+ HYDROGUI_ColorWidget* myFillingColorBox;
+
+ QGroupBox* myBorderColorGroup;
+ HYDROGUI_ColorWidget* myBorderColorBox;
+};
+
+#endif
--- /dev/null
+// 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
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_ZoneOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_ZoneDlg.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_PrsZone.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_UpdateFlags.h"
+
+#include <HYDROData_Bathymetry.h>
+#include <HYDROData_Iterator.h>
+#include <HYDROData_Polyline.h>
+
+#include <GraphicsView_ViewManager.h>
+#include <GraphicsView_ViewPort.h>
+#include <GraphicsView_Viewer.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_UpdateFlags.h>
+
+HYDROGUI_ZoneOp::HYDROGUI_ZoneOp( HYDROGUI_Module* theModule,
+ const bool theIsEdit )
+: HYDROGUI_Operation( theModule ),
+ myIsEdit( theIsEdit ),
+ myActiveViewManager( 0 ),
+ myPreviewViewManager( 0 ),
+ myPreviewPrs( 0 )
+{
+ setName( theIsEdit ? tr( "EDIT_ZONE" ) : tr( "CREATE_ZONE" ) );
+}
+
+HYDROGUI_ZoneOp::~HYDROGUI_ZoneOp()
+{
+ closePreview();
+}
+
+void HYDROGUI_ZoneOp::startOperation()
+{
+ HYDROGUI_Operation::startOperation();
+
+ HYDROGUI_ZoneDlg* aPanel = ::qobject_cast<HYDROGUI_ZoneDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ aPanel->reset();
+
+ QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Zone" );
+
+ QColor aFillingColor( HYDROData_Zone::DefaultFillingColor() );
+ QColor aBorderColor( HYDROData_Zone::DefaultBorderColor() );
+ QString aSelectedPolyline;
+ QStringList aSelectedBathymetries;
+
+ if ( myIsEdit )
+ {
+ myEditedObject = Handle(HYDROData_Zone)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if( !myEditedObject.IsNull() )
+ {
+ anObjectName = myEditedObject->GetName();
+
+ aFillingColor = myEditedObject->GetFillingColor();
+ aBorderColor = myEditedObject->GetBorderColor();
+
+ Handle(HYDROData_Polyline) aRefPolyline = myEditedObject->GetPolyline();
+ if ( !aRefPolyline.IsNull() )
+ aSelectedPolyline = aRefPolyline->GetName();
+
+ HYDROData_SequenceOfObjects aRefBathymetries = myEditedObject->GetBathymetries();
+ HYDROData_SequenceOfObjects::Iterator anIter( aRefBathymetries );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(HYDROData_Bathymetry) aRefBathymetry =
+ Handle(HYDROData_Bathymetry)::DownCast( anIter.Value() );
+ if ( aRefBathymetry.IsNull() )
+ continue;
+
+ QString aRefBathymetryName = aRefBathymetry->GetName();
+ if ( aRefBathymetryName.isEmpty() )
+ continue;
+
+ aSelectedBathymetries.append( aRefBathymetryName );
+ }
+ }
+ }
+
+ // collect information about existing closed polylines
+ QStringList aPolylines;
+
+ HYDROData_Iterator anIter( doc(), KIND_POLYLINE );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(HYDROData_Polyline) aPolylineObj =
+ Handle(HYDROData_Polyline)::DownCast( anIter.Current() );
+ if ( aPolylineObj.IsNull() || !aPolylineObj->isClosed() )
+ continue;
+
+ QString aPolylineName = aPolylineObj->GetName();
+ if ( aPolylineName.isEmpty() )
+ continue;
+
+ aPolylines.append( aPolylineName );
+ }
+
+ // collect information about existing bathymetries
+ QStringList aBathymetries;
+
+ anIter = HYDROData_Iterator( doc(), KIND_BATHYMETRY );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(HYDROData_Bathymetry) aBathymetryObj =
+ Handle(HYDROData_Bathymetry)::DownCast( anIter.Current() );
+ if ( aBathymetryObj.IsNull() )
+ continue;
+
+ QString aBathymetryName = aBathymetryObj->GetName();
+ if ( aBathymetryName.isEmpty() )
+ continue;
+
+ aBathymetries.append( aBathymetryName );
+ }
+
+ aPanel->setObjectName( anObjectName );
+
+ aPanel->setFillingColor( aFillingColor );
+ aPanel->setBorderColor( aBorderColor );
+
+ aPanel->setPolylineNames( aPolylines );
+ aPanel->setPolylineName( aSelectedPolyline );
+
+ aPanel->setBathymetries( aBathymetries );
+ aPanel->setSelectedBathymetries( aSelectedBathymetries );
+
+}
+
+void HYDROGUI_ZoneOp::abortOperation()
+{
+ closePreview();
+
+ HYDROGUI_Operation::abortOperation();
+}
+
+void HYDROGUI_ZoneOp::commitOperation()
+{
+ closePreview();
+
+ HYDROGUI_Operation::commitOperation();
+}
+
+HYDROGUI_InputPanel* HYDROGUI_ZoneOp::createInputPanel() const
+{
+ HYDROGUI_ZoneDlg* aPanel = new HYDROGUI_ZoneDlg( module(), getName() );
+ connect( aPanel, SIGNAL( CreatePreview( const QString& ) ),
+ this, SLOT( onCreatePreview( const QString& ) ) );
+ return aPanel;
+}
+
+bool HYDROGUI_ZoneOp::processApply( int& theUpdateFlags,
+ QString& theErrorMsg )
+{
+ HYDROGUI_ZoneDlg* aPanel = ::qobject_cast<HYDROGUI_ZoneDlg*>( inputPanel() );
+ if ( !aPanel )
+ return false;
+
+ QString anObjectName = aPanel->getObjectName().simplified();
+ if ( anObjectName.isEmpty() )
+ {
+ theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
+ return false;
+ }
+
+ if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) )
+ {
+ // check that there are no other objects with the same name in the document
+ Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
+ if( !anObject.IsNull() )
+ {
+ theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName );
+ return false;
+ }
+ }
+
+ Handle(HYDROData_Zone) aZoneObj = myIsEdit ? myEditedObject :
+ Handle(HYDROData_Zone)::DownCast( doc()->CreateObject( KIND_ZONE ) );
+ if ( aZoneObj.IsNull() )
+ return false;
+
+ aZoneObj->SetName( anObjectName );
+
+ aZoneObj->SetFillingColor( aPanel->getFillingColor() );
+ aZoneObj->SetBorderColor( aPanel->getBorderColor() );
+
+ Handle(HYDROData_Polyline) aZonePolyline;
+
+ QString aPolylineName = aPanel->getPolylineName();
+ if ( !aPolylineName.isEmpty() )
+ {
+ aZonePolyline = Handle(HYDROData_Polyline)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINE ) );
+ }
+
+ aZoneObj->SetPolyline( aZonePolyline );
+
+
+ aZoneObj->RemoveBathymetries();
+
+ QStringList aBathymetries = aPanel->getSelectedBathymetries();
+ for ( int i = 0; i < aBathymetries.length(); ++i )
+ {
+ const QString& aBathymetryName = aBathymetries.at( i );
+ if ( aBathymetryName.isEmpty() )
+ continue;
+
+ Handle(HYDROData_Bathymetry) aBathymetry = Handle(HYDROData_Bathymetry)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aBathymetryName, KIND_BATHYMETRY ) );
+ if ( aBathymetry.IsNull() )
+ continue;
+
+ aZoneObj->AddBathymetry( aBathymetry );
+ }
+
+
+ theUpdateFlags = UF_Model;
+
+ return true;
+}
+
+void HYDROGUI_ZoneOp::onCreatePreview( const QString& thePolylineName )
+{
+ HYDROGUI_ZoneDlg* aPanel = ::qobject_cast<HYDROGUI_ZoneDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ QPainterPath aPath;
+
+ Handle(HYDROData_Polyline) aPolyline = Handle(HYDROData_Polyline)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), thePolylineName, KIND_POLYLINE ) );
+ if ( !aPolyline.IsNull() )
+ {
+ aPath = aPolyline->painterPath();
+ }
+
+ LightApp_Application* anApp = module()->getApp();
+
+ if ( !myActiveViewManager )
+ {
+ myActiveViewManager = anApp->activeViewManager();
+ }
+
+ if ( !myPreviewPrs )
+ {
+ myPreviewPrs = new HYDROGUI_PrsZone( myIsEdit ? myEditedObject : 0 );
+ }
+
+ myPreviewPrs->setPath( aPath );
+ myPreviewPrs->setFillingColor( aPanel->getFillingColor() );
+ myPreviewPrs->setBorderColor( aPanel->getBorderColor() );
+ myPreviewPrs->compute();
+
+ if ( !myPreviewViewManager )
+ {
+ myPreviewViewManager = ::qobject_cast<GraphicsView_ViewManager*>(
+ anApp->createViewManager( GraphicsView_Viewer::Type() ) );
+ if ( myPreviewViewManager )
+ {
+ connect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+ this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+
+ module()->setViewManagerRole( myPreviewViewManager, HYDROGUI_Module::VMR_PreviewZone );
+ myPreviewViewManager->setTitle( tr( "PREVIEW_ZONE" ) );
+ if ( GraphicsView_Viewer* aViewer = myPreviewViewManager->getViewer() )
+ {
+ if ( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
+ {
+ aViewPort->addItem( myPreviewPrs );
+ }
+ }
+ }
+ }
+
+ if ( myPreviewViewManager )
+ {
+ if ( GraphicsView_Viewer* aViewer = myPreviewViewManager->getViewer() )
+ {
+ if ( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
+ {
+ aViewPort->update();
+ aViewPort->fitAll();
+ }
+ }
+ }
+}
+
+void HYDROGUI_ZoneOp::onLastViewClosed( SUIT_ViewManager* theViewManager )
+{
+ closePreview();
+}
+
+void HYDROGUI_ZoneOp::closePreview()
+{
+ // It's very strange, but without calling this method (it's quite safe) a crash is stably reproduced.
+ // Scenario: create any non-Graphics view, activate import op, click apply.
+ // Result: a few SIGSEGVs coming from processEvents(), then crash.
+ if( myPreviewViewManager )
+ if( GraphicsView_Viewer* aViewer = myPreviewViewManager->getViewer() )
+ if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
+ aViewPort->onBoundingRectChanged();
+
+ if( myPreviewPrs )
+ {
+ delete myPreviewPrs;
+ myPreviewPrs = 0;
+ }
+
+ if( myPreviewViewManager )
+ {
+ disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+ this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+
+ module()->getApp()->removeViewManager( myPreviewViewManager ); // myPreviewViewManager is deleted here
+ myPreviewViewManager = 0;
+ }
+
+ if( myActiveViewManager )
+ {
+ HYDROGUI_Tool::SetActiveViewManager( module(), myActiveViewManager );
+ myActiveViewManager = 0;
+ }
+}
--- /dev/null
+// 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
+//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_ZONEOP_H
+#define HYDROGUI_ZONEOP_H
+
+#include "HYDROGUI_Operation.h"
+
+#include <HYDROData_Zone.h>
+
+#include <QPainterPath>
+
+class GraphicsView_ViewManager;
+
+class SUIT_ViewManager;
+
+class HYDROGUI_PrsZone;
+
+class HYDROGUI_ZoneOp : public HYDROGUI_Operation
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_ZoneOp( HYDROGUI_Module* theModule, const bool theIsEdit );
+ virtual ~HYDROGUI_ZoneOp();
+
+protected:
+ virtual void startOperation();
+ virtual void abortOperation();
+ virtual void commitOperation();
+
+ virtual HYDROGUI_InputPanel* createInputPanel() const;
+
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+
+protected slots:
+ void onCreatePreview( const QString& thePolylineName );
+
+ void onLastViewClosed( SUIT_ViewManager* );
+
+private:
+ void closePreview();
+
+private:
+ bool myIsEdit;
+ Handle(HYDROData_Zone) myEditedObject;
+
+ SUIT_ViewManager* myActiveViewManager;
+
+ GraphicsView_ViewManager* myPreviewViewManager;
+ HYDROGUI_PrsZone* myPreviewPrs;
+
+ QPainterPath myZonePath;
+};
+
+#endif
<source>SAVE_ERROR</source>
<translation>Study could not be saved</translation>
</message>
+ <message>
+ <source>ZONE_POLYLINE</source>
+ <translation>Polyline</translation>
+ </message>
+ <message>
+ <source>ZONE_BATHYMETRIES</source>
+ <translation>Bathymetries</translation>
+ </message>
</context>
<context>
<source>DSK_CREATE_POLYLINE</source>
<translation>Create polyline</translation>
</message>
+ <message>
+ <source>DSK_CREATE_ZONE</source>
+ <translation>Create zone</translation>
+ </message>
+ <message>
+ <source>DSK_EDIT_ZONE</source>
+ <translation>Edit zone</translation>
+ </message>
<message>
<source>DSK_COPY</source>
<translation>Copy</translation>
<source>MEN_CREATE_POLYLINE</source>
<translation>Create polyline</translation>
</message>
+ <message>
+ <source>MEN_CREATE_ZONE</source>
+ <translation>Create zone</translation>
+ </message>
+ <message>
+ <source>MEN_EDIT_ZONE</source>
+ <translation>Edit zone</translation>
+ </message>
<message>
<source>MEN_COPY</source>
<translation>Copy</translation>
<source>STB_CREATE_POLYLINE</source>
<translation>Create polyline</translation>
</message>
+ <message>
+ <source>STB_CREATE_ZONE</source>
+ <translation>Create zone</translation>
+ </message>
+ <message>
+ <source>STB_EDIT_ZONE</source>
+ <translation>Edit zone</translation>
+ </message>
<message>
<source>STB_COPY</source>
<translation>Copy</translation>
<translation>Save visual state</translation>
</message>
</context>
-
+
+ <context>
+ <name>HYDROGUI_ZoneDlg</name>
+ <message>
+ <source>BORDER_COLOR</source>
+ <translation>Border</translation>
+ </message>
+ <message>
+ <source>COLOR</source>
+ <translation>Color</translation>
+ </message>
+ <message>
+ <source>FILLING_COLOR</source>
+ <translation>Filling color</translation>
+ </message>
+ <message>
+ <source>NAME</source>
+ <translation>Name</translation>
+ </message>
+ <message>
+ <source>TRANSPARENT</source>
+ <translation>Transparent</translation>
+ </message>
+ <message>
+ <source>ZONE_BATHYMETRIES</source>
+ <translation>Bathymetries</translation>
+ </message>
+ <message>
+ <source>ZONE_NAME</source>
+ <translation>Zone name</translation>
+ </message>
+ <message>
+ <source>ZONE_PARAMETERS</source>
+ <translation>Parameters</translation>
+ </message>
+ <message>
+ <source>ZONE_POLYLINE</source>
+ <translation>Polyline</translation>
+ </message>
+ </context>
+
+ <context>
+ <name>HYDROGUI_ZoneOp</name>
+ <message>
+ <source>CREATE_ZONE</source>
+ <translation>Create zone</translation>
+ </message>
+ <message>
+ <source>EDIT_ZONE</source>
+ <translation>Edit zone</translation>
+ </message>
+ <message>
+ <source>PREVIEW_ZONE</source>
+ <translation>Preview zone</translation>
+ </message>
+ </context>
+
</TS>