return aResSeq;
}
+double HYDROData_CalculationCase::GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const
+{
+ double aCoeff = 0;
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+ if ( !aDocument.IsNull() )
+ aCoeff = aDocument->GetDefaultStricklerCoefficient();
+
+ Handle(HYDROData_LandCover) aLandCover;
+ Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint, Standard_True );
+ if ( !aZone.IsNull() )
+ {
+ HYDROData_SequenceOfObjects anObjList = aZone->GetObjects();
+ if ( anObjList.Length() == 1 )
+ aLandCover = Handle(HYDROData_LandCover)::DownCast( anObjList.First() );
+ else
+ aLandCover = Handle(HYDROData_LandCover)::DownCast( aZone->GetMergeObject() );
+ }
+
+ if ( !aLandCover.IsNull() )
+ {
+ QString aType = aLandCover->GetStricklerType();
+ Handle(HYDROData_StricklerTable) aTable = GetStricklerTable();
+ if ( !aTable.IsNull() )
+ {
+ if ( aTable->GetTypes().contains( aType ) )
+ aCoeff = aTable->Get( aType, aCoeff );
+ }
+ }
+
+ return aCoeff;
+}
+
Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint,
const bool theLandCover ) const
{
HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
const Handle(HYDROData_Zone)& theZone ) const;
+ /**
+ * Returns strickler coefficient for given point.
+ * \param thePoint the point to examine
+ * \return result strickler coefficient
+ */
+ HYDRODATA_EXPORT double GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const;
+
/**
* Returns altitudes for given points on given region.
* \param thePoints the points to examine
#include <HYDROData_Tool.h>
#include <HYDROData_InterpolatorsFactory.h>
+#include <TDataStd_Real.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataXtd_Position.hxx>
static const int TAG_OBJECTS = 2; // tag of the objects sub-tree
static const int TAG_HISTORY = 3; // tag of the history sub-tree (Root for History)
static const int TAG_LOCAL_CS = 4; // tag of local coordinate system information
+static const int TAG_DEF_STRICKLER_COEFF = 5; // tag of default strickler coefficient
static const gp_Pnt2d DEFAULT_LOCAL_CS( 0, 0 );
using namespace std;
HYDROData_Application::GetApplication()->RemoveDocument(this);
}
+double HYDROData_Document::GetDefaultStricklerCoefficient() const
+{
+ double aRes = 0;
+ TDF_Label aLabel = myDoc->Main().FindChild(TAG_DEF_STRICKLER_COEFF, Standard_False);
+ if ( !aLabel.IsNull() )
+ {
+ Handle(TDataStd_Real) anAttr;
+ if ( aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) )
+ aRes = anAttr->Get();
+ }
+
+ return aRes;
+}
+
+void HYDROData_Document::SetDefaultStricklerCoefficient( double theCoeff ) const
+{
+ TDF_Label aLabel = myDoc->Main().FindChild(TAG_DEF_STRICKLER_COEFF);
+ if ( !aLabel.IsNull() )
+ {
+ Handle(TDataStd_Real) anAttr;
+ if ( !aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) )
+ aLabel.AddAttribute( anAttr = new TDataStd_Real() );
+ anAttr->Set( theCoeff );
+ }
+}
+
bool HYDROData_Document::DumpToPython( const QString& theFileName,
const bool theIsMultiFile ) const
{
//! Get list of registered interpolator names.
HYDRODATA_EXPORT NCollection_Sequence<TCollection_AsciiString> GetInterpolatorNames() const;
-protected:
+public:
+ //! Returns default strickler coefficient
+ HYDRODATA_EXPORT double GetDefaultStricklerCoefficient() const;
+ //! Sets default strickler coefficient
+ HYDRODATA_EXPORT void SetDefaultStricklerCoefficient( double ) const;
+
+protected:
friend class HYDROData_Iterator;
friend class test_HYDROData_Document;
else
{
Standard_Real aValue = TCollection_AsciiString( aValueStr ).RealValue();
- Set( aStr, aValue );
+ Set( QString( (QChar*)aStr.ToExtString(), aStr.Length() ), aValue );
}
}
}
return aRes;
}
-double HYDROData_StricklerTable::Get( const TCollection_ExtendedString& theType, double theDefault ) const
+double HYDROData_StricklerTable::Get( const QString& theType, double theDefault ) const
{
Handle( TDataStd_NamedData ) aMap = Map();
- if( aMap->HasReal( theType ) )
- return aMap->GetReal( theType );
+ TCollection_ExtendedString aType = toExtString( theType );
+ if( aMap->HasReal( aType ) )
+ return aMap->GetReal( aType );
else
return theDefault;
}
-void HYDROData_StricklerTable::Set( const TCollection_ExtendedString& theType, double theCoefficient )
+void HYDROData_StricklerTable::Set( const QString& theType, double theCoefficient )
{
Handle(TDataStd_NamedData) aMap = Map();
- aMap->SetReal( theType, theCoefficient );
+ aMap->SetReal( toExtString( theType ), theCoefficient );
}
-TColStd_SequenceOfExtendedString HYDROData_StricklerTable::GetTypes() const
+QStringList HYDROData_StricklerTable::GetTypes() const
{
- TColStd_SequenceOfExtendedString aSeq;
+ QStringList aSeq;
Handle(TDataStd_NamedData) aMap = Map();
if ( !aMap.IsNull() )
{
for ( TDataStd_DataMapIteratorOfDataMapOfStringReal it( aMap->GetRealsContainer() ); it.More(); it.Next() )
- aSeq.Append( it.Key() );
+ aSeq.append( toQString( it.Key() ) );
}
return aSeq;
}
aMap = TDataStd_NamedData::Set( aLabel );
return aMap;
}
+
+TCollection_ExtendedString HYDROData_StricklerTable::toExtString( const QString& theStr ) const
+{
+ TCollection_ExtendedString aRes;
+ if( !theStr.isEmpty() )
+ {
+ Standard_ExtString extStr = new Standard_ExtCharacter[ ( theStr.length() + 1 ) * 2 ];
+ memcpy( (void*)extStr, theStr.unicode(), theStr.length() * 2 );
+ ((short*)extStr)[theStr.length()] = '\0';
+
+ aRes = TCollection_ExtendedString( extStr );
+ delete [] extStr;
+ }
+ return aRes;
+}
+
+QString HYDROData_StricklerTable::toQString( const TCollection_ExtendedString& theStr ) const
+{
+ return QString( (QChar*)theStr.ToExtString(), theStr.Length() );
+}
HYDRODATA_EXPORT bool Import( const TCollection_AsciiString& theFileName );
HYDRODATA_EXPORT bool Export( const TCollection_AsciiString& theFileName );
- HYDRODATA_EXPORT double Get( const TCollection_ExtendedString& theType, double theDefault ) const;
- HYDRODATA_EXPORT void Set( const TCollection_ExtendedString& theType, double theCoefficient );
+ HYDRODATA_EXPORT double Get( const QString& theType, double theDefault ) const;
+ HYDRODATA_EXPORT void Set( const QString& theType, double theCoefficient );
- HYDRODATA_EXPORT TColStd_SequenceOfExtendedString GetTypes() const;
+ HYDRODATA_EXPORT QStringList GetTypes() const;
HYDRODATA_EXPORT void Clear();
HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+private:
+ TCollection_ExtendedString toExtString( const QString& ) const;
+ QString toQString( const TCollection_ExtendedString& ) const;
+
private:
Handle(TDataStd_NamedData) Map() const;
};
HYDROGUI_ExportFileOp.h
HYDROGUI_GVSelector.h
HYDROGUI_ImagePrs.h
- HYDROGUI_BasicZoneDlg.h
+ HYDROGUI_BasicZoneDlg.h
HYDROGUI_ImmersibleZoneDlg.h
HYDROGUI_ImmersibleZoneOp.h
HYDROGUI_ImportBathymetryDlg.h
HYDROGUI_LineEditDoubleValidator.h
HYDROGUI_StricklerTableDlg.h
HYDROGUI_StricklerTableOp.h
- HYDROGUI_LandCoverDlg.h
- HYDROGUI_LandCoverOp.h
+ HYDROGUI_LandCoverDlg.h
+ HYDROGUI_LandCoverOp.h
HYDROGUI_SubmersibleOp.h
HYDROGUI_Tool.h
HYDROGUI_TwoImagesDlg.h
HYDROGUI_RiverBottomOp.h
HYDROGUI_ViewerDlg.h
HYDROGUI_ObjComboBox.h
+ HYDROGUI_PolylineExtractionOp.h
)
QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
HYDROGUI_ExportFileOp.cxx
HYDROGUI_GVSelector.cxx
HYDROGUI_ImagePrs.cxx
- HYDROGUI_BasicZoneDlg.cxx
+ HYDROGUI_BasicZoneDlg.cxx
HYDROGUI_ImmersibleZoneDlg.cxx
HYDROGUI_ImmersibleZoneOp.cxx
HYDROGUI_ImportBathymetryDlg.cxx
HYDROGUI_LineEditDoubleValidator.cxx
HYDROGUI_StricklerTableDlg.cxx
HYDROGUI_StricklerTableOp.cxx
- HYDROGUI_LandCoverDlg.cxx
- HYDROGUI_LandCoverOp.cxx
+ HYDROGUI_LandCoverDlg.cxx
+ HYDROGUI_LandCoverOp.cxx
HYDROGUI_SubmersibleOp.cxx
HYDROGUI_Tool.cxx
HYDROGUI_TwoImagesDlg.cxx
HYDROGUI_RiverBottomOp.cxx
HYDROGUI_ViewerDlg.cxx
HYDROGUI_ObjComboBox.cxx
+ HYDROGUI_PolylineExtractionOp.cxx
)
add_definitions(
{
}
+bool HYDROGUI_DataModel::create( CAM_Study* theStudy )
+{
+ bool status = LightApp_DataModel::create( theStudy );
+ if ( status )
+ updateDocument();
+ return status;
+}
+
bool HYDROGUI_DataModel::open( const QString& theURL,
CAM_Study* theStudy,
QStringList theFileList )
{
res = DocError_UnknownProblem;
}
- if( res != DocError_OK )
+
+ if ( res != DocError_OK )
{
module()->application()->putInfo( tr( "LOAD_ERROR" ) );
return false;
}
- if( !aStatesFullPath.isEmpty() )
+ if ( !aStatesFullPath.isEmpty() )
{
QFile aFile( aStatesFullPath );
if( aFile.open( QFile::ReadOnly ) )
aFile.close();
}
}
+
+ updateDocument();
}
// if the document open was successful, the data model update happens
// in the set mode of the module
- if( res == DocError_OK )
+ if ( res == DocError_OK )
update( aStudyId );
return true;
QString aTmpDir;
SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr();
bool isMultiFile = false;
- if( resMgr )
+ if ( resMgr )
isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
// save module data to temporary files
bool HYDROGUI_DataModel::close()
{
+ HYDROGUI_Module* aModule = dynamic_cast<HYDROGUI_Module*>( module() );
+ if ( aModule )
+ aModule->clearCache();
return true;
}
}
return true;
}
+
+void HYDROGUI_DataModel::updateDocument()
+{
+ // Sets the default strickler coefficient from preferences to document.
+ Handle(HYDROData_Document) aDoc = getDocument();
+ SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr();
+ if ( resMgr && !aDoc.IsNull() )
+ aDoc->SetDefaultStricklerCoefficient( resMgr->doubleValue( "preferences", "default_strickler_coefficient", 0 ) );
+}
HYDROGUI_DataModel( CAM_Module* theModule );
virtual ~HYDROGUI_DataModel();
+ /**
+ * Creates the document into the data model. Reimplemented.
+ */
+ virtual bool create( CAM_Study* );
+
/**
* Open the document into the data model. Reimplemented.
* \param theURL opened study path
static SUIT_DataObject* findChildByName( const SUIT_DataObject* theFather,
const QString& theName );
+ void updateDocument();
+
protected:
QString myStudyURL; ///< the saved/opened document URL
QByteArray myStates;
if ( !aStricklerTableObj.IsNull() )
{
// Get Strickler table data from the data model
- TColStd_SequenceOfExtendedString aTypes = aStricklerTableObj->GetTypes();
- for ( int i = 1; i <= aTypes.Length(); i++ )
+ QStringList aTypes = aStricklerTableObj->GetTypes();
+ for ( QStringList::iterator it = aTypes.begin(); it != aTypes.end(); ++it )
{
- QString aType = HYDROGUI_Tool::ToQString( aTypes.Value( i ) );
- if ( !aType.isEmpty() && !aStricklerTypes.contains( aType ))
+ QString aType = *it;
+ if ( !aType.isEmpty() && !aStricklerTypes.contains( aType ) )
aStricklerTypes.append( aType );
}
}
}
+
aStricklerTypes.sort();
aPanel->setAdditionalParams( aStricklerTypes );
theMenu->addSeparator();
}
+ if ( anIsStream || anIsChannel || anIsDigue || anIsObstacle )
+ {
+ theMenu->addAction( action( PolylineExtraction ) );
+ theMenu->addSeparator();
+ }
+
// Add set color action for geometrical objects
if ( anIsObjectCanBeColored )
{
setPreferenceProperty( defaultStricklerCoef, "step", 0.01 );
}
+void HYDROGUI_Module::preferencesChanged( const QString& theSection, const QString& thePref )
+{
+ if ( theSection == "preferences" && thePref == "default_strickler_coefficient" )
+ {
+ SUIT_ResourceMgr* resMgr = application()->resourceMgr();
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( application()->activeStudy()->id() );
+ if ( resMgr && !aDoc.IsNull() )
+ aDoc->SetDefaultStricklerCoefficient( resMgr->doubleValue( theSection, thePref, 0 ) );
+ }
+ else
+ LightApp_Module::preferencesChanged( theSection, thePref );
+}
+
QCursor HYDROGUI_Module::getPrefEditCursor() const
{
int aCursorType = SUIT_Session::session()->resourceMgr()->integerValue("preferences", "type_of_cursor", (int)CT_CrossCursor );
}
/////////////////// END OF VTKPrs PROCESSING
+void HYDROGUI_Module::clearCache()
+{
+ myObjectStateMap.clear();
+}
+
CAM_DataModel* HYDROGUI_Module::createDataModel()
{
return new HYDROGUI_DataModel( this );
void setObjectVisible( const int theViewId,
const Handle(HYDROData_Entity)& theObject,
const bool theState );
+
+ virtual void preferencesChanged( const QString&, const QString& );
+
/**
* Set IsToUpdate flag for all presentations of the given object to recompute them during
* the next viewer(s) updating.
*/
QCursor getPrefEditCursor() const;
+ void clearCache();
+
protected:
CAM_DataModel* createDataModel();
#include "HYDROGUI_StricklerTableOp.h"
#include "HYDROGUI_DuplicateOp.h"
#include "HYDROGUI_LandCoverOp.h"
+#include "HYDROGUI_PolylineExtractionOp.h"
#include <HYDROData_Document.h>
#include <HYDROData_Obstacle.h>
createAction( SubmersibleId, "SUBMERSIBLE", "SUBMERSIBLE_ICO" );
createAction( ExportPolylineId, "EXPORT_POLYLINE", "EXPORT_POLYLINE_ICO" );
+ createAction( PolylineExtraction, "POLYLINE_EXTRACTION" );
}
void HYDROGUI_Module::createMenus()
case SubmersibleId:
anOp = new HYDROGUI_SubmersibleOp( aModule );
break;
+ case PolylineExtraction:
+ anOp = new HYDROGUI_PolylineExtractionOp( aModule );
+ break;
}
if( !anOp )
DuplicateStricklerTableId,
CreateLandCoverId,
- EditLandCoverId
+ EditLandCoverId,
+
+ PolylineExtraction
};
#endif
// Get Strickler table data from the data model
HYDROGUI_StricklerTableDlg::StricklerCoefficientList aData;
- TColStd_SequenceOfExtendedString aTypes = myObject->GetTypes();
- for ( int i = 1; i <= aTypes.Length(); i++ )
- aData.append( HYDROGUI_StricklerTableDlg::StricklerCoefficient( HYDROGUI_Tool::ToQString( aTypes.Value( i ) ),
- myObject->Get( aTypes.Value( i ), 0 ) ) );
+ QStringList aTypes = myObject->GetTypes();
+ for ( QStringList::iterator it = aTypes.begin(); it != aTypes.end(); ++it )
+ aData.append( HYDROGUI_StricklerTableDlg::StricklerCoefficient( *it, myObject->Get( *it, 0 ) ) );
aPanel->setData( aData );
}
for ( HYDROGUI_StricklerTableDlg::StricklerCoefficientList::iterator it = aData.begin(); it != aData.end(); ++it )
{
const HYDROGUI_StricklerTableDlg::StricklerCoefficient& anInfo = *it;
- aStricklerTableObj->Set( HYDROGUI_Tool::ToExtString( anInfo.myType ), anInfo.myCoefficient );
+ aStricklerTableObj->Set( anInfo.myType, anInfo.myCoefficient );
}
}
else
<source>DSK_EXPORT_POLYLINE</source>
<translation>Export Polyline</translation>
</message>
+ <message>
+ <source>DSK_POLYLINE_EXTRACTION</source>
+ <translation>Extracts the polyline from selected object</translation>
+ </message>
+
<message>
<source>MEN_CREATE_CALCULATION</source>
<translation>Create calculation case</translation>
<source>MEN_EXPORT_POLYLINE</source>
<translation>Export Polyline</translation>
</message>
+ <message>
+ <source>MEN_POLYLINE_EXTRACTION</source>
+ <translation>Polyline extraction</translation>
+ </message>
<message>
<source>STB_CREATE_CALCULATION</source>
<source>STB_EDIT_LOCAL_CS</source>
<translation>Change local CS</translation>
</message>
+ <message>
+ <source>STB_POLYLINE_EXTRACTION</source>
+ <translation>Polyline extractions</translation>
+ </message>
<message>
<source>MEN_CREATE_STREAM_BOTTOM</source>
</message>
</context>
+ <context>
+ <name>HYDROGUI_PolylineExtractionOp</name>
+ <message>
+ <source>POLYLINE_EXTRACTION</source>
+ <translation>Polyline extraction</translation>
+ </message>
+ </context>
+
</TS>
# HYDROData_ImmersibleZone.sip
# HYDROData_Zone.sip
# HYDROData_Region.sip
+# HYDROData_StricklerTable.sip
# HYDROData_CalculationCase.sip
# HYDROData_Document.sip
# )
SET(_sip_files2
CAS/gp_XY.sip
CAS/gp_XYZ.sip
- CAS/TCollection_AsciiString.sip
CAS/NCollection_Sequence.sip
+ CAS/TCollection_AsciiString.sip
HYDROData_SequenceOfObjects.sip
HYDROData_IInterpolator.sip
HYDROData_Entity.sip
HYDROData_ImmersibleZone.sip
HYDROData_Zone.sip
HYDROData_Region.sip
+ HYDROData_StricklerTable.sip
HYDROData_CalculationCase.sip
HYDROData_Document.sip
HYDROData_Application.sip
%Include CAS/gp_XY.sip
%Include CAS/gp_XYZ.sip
-%Include CAS/TCollection_AsciiString.sip
%Include CAS/NCollection_Sequence.sip
+%Include CAS/TCollection_AsciiString.sip
%Include HYDROData_SequenceOfObjects.sip
%Include HYDROData_IInterpolator.sip
%Include HYDROData_Entity.sip
%Include HYDROData_Region.sip
%Include HYDROData_CalculationCase.sip
%Include HYDROData_IProfilesInterpolator.sip
+%Include HYDROData_StricklerTable.sip
%Include HYDROData_Document.sip
%Include HYDROData_Application.sip
public:
// Public methods to work with Calculation services
+ /**
+ * Returns strickler coefficient for given point.
+ * \param thePoint the point to examine
+ * \return result strickler coefficient
+ */
+ double GetStricklerCoefficientForPoint( const double theCoordX,
+ const double theCoordY ) const [double ( const gp_XY& ) ];
+ %MethodCode
+ gp_XY aPnt( a0, a1 );
+
+ Py_BEGIN_ALLOW_THREADS
+ sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetStricklerCoefficientForPoint( aPnt ) :
+ sipCpp->GetStricklerCoefficientForPoint( aPnt );
+ Py_END_ALLOW_THREADS
+ %End
+
/**
* Returns altitude for given point.
* \param thePoint the point to examine
aRes = new HYDROData_StreamAltitude( *dynamic_cast<HYDROData_StreamAltitude*>( theObject ) );
break;
}
+ case KIND_STRICKLER_TABLE:
+ {
+ aRes = new HYDROData_StricklerTable( *dynamic_cast<HYDROData_StricklerTable*>( theObject ) );
+ break;
+ }
}
return aRes;
const ObjectKind KIND_SHAPES_GROUP;
const ObjectKind KIND_SPLITTED_GROUP;
const ObjectKind KIND_OBSTACLE_ALTITUDE;
+const ObjectKind KIND_STRICKLER_TABLE;
class HYDROData_Entity
{
sipClass = sipClass_HYDROData_ObstacleAltitude;
break;
+ case KIND_STRICKLER_TABLE:
+ sipClass = sipClass_HYDROData_StricklerTable;
+ break;
+
case KIND_UNKNOWN:
sipClass = sipClass_HYDROData_Entity;
break;
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// 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
+//
+
+%ExportedHeaderCode
+#include <HYDROData_StricklerTable.h>
+#include <TColStd_SequenceOfExtendedString.hxx>
+%End
+
+class HYDROData_StricklerTable : public HYDROData_Entity
+{
+
+%ConvertToSubClassCode
+ switch ( sipCpp->GetKind() )
+ {
+ case KIND_STRICKLER_TABLE:
+ sipClass = sipClass_HYDROData_StricklerTable;
+ break;
+
+ default:
+ // We don't recognise the type.
+ sipClass = NULL;
+ }
+%End
+
+%TypeHeaderCode
+#include <HYDROData_StricklerTable.h>
+%End
+
+public:
+
+ bool Import( const TCollection_AsciiString& theFileName );
+ bool Export( const TCollection_AsciiString& theFileName );
+
+ double Get( const QString& theType, double theDefault ) const;
+ void Set( const QString& theType, double theCoefficient );
+
+ QStringList GetTypes() const;
+
+ void Clear();
+
+protected:
+ /**
+ * Creates new object in the internal data structure. Use higher level objects
+ * to create objects with real content.
+ */
+ HYDROData_StricklerTable();
+
+ /**
+ * Destructs properties of the object and object itself, removes it from the document.
+ */
+ ~HYDROData_StricklerTable();
+};
+
+