X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_IPolyline.cxx;h=df150b0a83c8525ce4fadbd6f13cec4a6ffc7c5f;hb=23a6f7b3e29e74735d71d7e1448465a9920f91dd;hp=00f7a04a0479222525be537c568cbc55d8a59b94;hpb=7e825ec456c9331ef0df1cb59865cc55f0d8516a;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_IPolyline.cxx b/src/HYDROData/HYDROData_IPolyline.cxx index 00f7a04a..df150b0a 100755 --- a/src/HYDROData/HYDROData_IPolyline.cxx +++ b/src/HYDROData/HYDROData_IPolyline.cxx @@ -1,20 +1,42 @@ +// 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 +// #include "HYDROData_IPolyline.h" -#include "HYDROData_Document.h" +#include #include #include -#include #include #include +#include + +#include +#include + +#include + IMPLEMENT_STANDARD_HANDLE(HYDROData_IPolyline, HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IPolyline, HYDROData_Entity) HYDROData_IPolyline::HYDROData_IPolyline() -: HYDROData_Entity(), - myIsOperation( false ) +: HYDROData_Entity() { } @@ -22,169 +44,49 @@ HYDROData_IPolyline::~HYDROData_IPolyline() { } -int HYDROData_IPolyline::getNbUndo() const -{ - return getNbOperations(); -} - -bool HYDROData_IPolyline::undo() -{ - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); - if ( aDocument.IsNull() ) - return false; - - if ( getNbUndo() < 1 ) - return false; - - aDocument->Undo(); - - int aNbUndoedOperations = getNbUndoedOperations(); - setNbUndoedOperations( aNbUndoedOperations + 1 ); - - return true; -} - -int HYDROData_IPolyline::getNbRedo() const -{ - return getNbUndoedOperations(); -} - -bool HYDROData_IPolyline::redo() +void HYDROData_IPolyline::SetWireColor( const QColor& theColor ) { - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); - if ( aDocument.IsNull() ) - return false; - - if ( getNbRedo() < 1 ) - return false; - - aDocument->Redo(); - - int aNbUndoedOperations = getNbUndoedOperations(); - setNbUndoedOperations( aNbUndoedOperations - 1 ); - - return true; + SetColor( theColor, DataTag_WireColor ); } -CurveCreator::Dimension HYDROData_IPolyline::getDimension() const +QColor HYDROData_IPolyline::GetWireColor() const { - return CurveCreator::Dim2d; -} - -CurveCreator::Coordinates HYDROData_IPolyline::getPoint( const int theISection, - const int theIPnt ) const -{ - CurveCreator::Coordinates aResPoint; - if ( theISection < 0 || theIPnt < 0 ) - return aResPoint; - - CurveCreator::Coordinates aSectPoints = getPoints( theISection ); - if ( theIPnt >= aSectPoints.size() ) - return aResPoint; - - CurveCreator::Coordinates::reverse_iterator anIt = aSectPoints.rbegin(); - - aResPoint.push_back( *anIt++ ); - aResPoint.push_back( *anIt ); - - return aResPoint; + return GetColor( DefaultWireColor(), DataTag_WireColor ); } - -int HYDROData_IPolyline::getNbPoints( const int theSectionIndex ) const +QColor HYDROData_IPolyline::DefaultWireColor() { - return getPoints( theSectionIndex ).size(); + return QColor( Qt::black ); } -void HYDROData_IPolyline::startOperation() +int HYDROData_IPolyline::NbPoints( const int theSectionIndex ) const { - if ( myIsOperation ) - return; - - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); - if ( aDocument.IsNull() ) - return; - - aDocument->StartOperation(); - - myIsOperation = true; + return GetPoints( theSectionIndex ).Length(); } -void HYDROData_IPolyline::commitOperation() +TopoDS_Shape HYDROData_IPolyline::getPolylineShape() const { - if ( !myIsOperation ) - return; - - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); - if ( aDocument.IsNull() ) - return; - - int aNbOperations = getNbOperations(); - setNbOperations( aNbOperations + 1 ); - - aDocument->CommitOperation(); - - myIsOperation = false; -} - -void HYDROData_IPolyline::abortOperation() -{ - if ( !myIsOperation ) - return; - - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); - if ( aDocument.IsNull() ) - return; - - aDocument->AbortOperation(); - - myIsOperation = false; -} - -void HYDROData_IPolyline::setNbOperations( const int theNb ) -{ - TDF_Label anOpLabel = myLab.FindChild( DataTag_Operations ).FindChild( OperationsTag_Commited ); - TDataStd_Integer::Set( anOpLabel, theNb ); -} - -int HYDROData_IPolyline::getNbOperations() const -{ - TDF_Label aLabel = myLab.FindChild( DataTag_Operations, false ); - if ( aLabel.IsNull() ) - return 0; - - TDF_Label anOpLabel = aLabel.FindChild( OperationsTag_Commited, false ); - if ( anOpLabel.IsNull() ) - return 0; - - Handle(TDataStd_Integer) anOpCount; - if ( !anOpLabel.FindAttribute( TDataStd_Integer::GetID(), anOpCount ) ) - return 0; - - return anOpCount->Get(); + TDF_Label aShapeLabel = myLab.FindChild( DataTag_PolylineShape, false ); + if ( !aShapeLabel.IsNull() ) + { + Handle(TNaming_NamedShape) aNamedShape; + if ( aShapeLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) ) + return aNamedShape->Get(); + } + return TopoDS_Shape(); } -void HYDROData_IPolyline::setNbUndoedOperations( const int theNb ) +void HYDROData_IPolyline::setPolylineShape( const TopoDS_Shape& theShape ) { - TDF_Label anUndoedLabel = myLab.FindChild( DataTag_Operations ).FindChild( OperationsTag_Undoed ); - TDataStd_Integer::Set( anUndoedLabel, theNb ); + TNaming_Builder aBuilder( myLab.FindChild( DataTag_PolylineShape ) ); + aBuilder.Generated( theShape ); } -int HYDROData_IPolyline::getNbUndoedOperations() const +void HYDROData_IPolyline::removePolylineShape() { - TDF_Label aLabel = myLab.FindChild( DataTag_Operations, false ); - if ( aLabel.IsNull() ) - return 0; - - TDF_Label anUndoedLabel = aLabel.FindChild( OperationsTag_Undoed, false ); - if ( anUndoedLabel.IsNull() ) - return 0; - - Handle(TDataStd_Integer) anUndoedCount; - if ( !anUndoedLabel.FindAttribute( TDataStd_Integer::GetID(), anUndoedCount ) ) - return 0; - - return anUndoedCount->Get(); + TDF_Label aShapeLabel = myLab.FindChild( DataTag_PolylineShape, false ); + if ( !aShapeLabel.IsNull() ) + aShapeLabel.ForgetAllAttributes(); } void HYDROData_IPolyline::getSectionsLists( Handle(TDataStd_ExtStringList)& theNamesList, @@ -192,21 +94,22 @@ void HYDROData_IPolyline::getSectionsLists( Handle(TDataStd_ExtStringList)& theN Handle(TDataStd_BooleanList)& theClosuresList, const bool theIsCreate ) const { - TDF_Label aSectsLabel = myLab.FindChild( DataTag_Sections, theIsCreate ); - if ( aSectsLabel.IsNull() ) + theNamesList.Nullify(); + theTypesList.Nullify(); + theClosuresList.Nullify(); + + TDF_Label aSectLabel = myLab.FindChild( DataTag_Sections, theIsCreate ); + if ( aSectLabel.IsNull() ) return; - Handle(TDataStd_ExtStringList) aNamesList; - if ( !aSectsLabel.FindAttribute( TDataStd_ExtStringList::GetID(), aNamesList ) && theIsCreate ) - aNamesList = TDataStd_ExtStringList::Set( aSectsLabel ); + if ( !aSectLabel.FindAttribute( TDataStd_ExtStringList::GetID(), theNamesList ) && theIsCreate ) + theNamesList = TDataStd_ExtStringList::Set( aSectLabel ); - Handle(TDataStd_IntegerList) aTypesList; - if ( !aSectsLabel.FindAttribute( TDataStd_IntegerList::GetID(), aTypesList ) && theIsCreate ) - aTypesList = TDataStd_IntegerList::Set( aSectsLabel ); + if ( !aSectLabel.FindAttribute( TDataStd_IntegerList::GetID(), theTypesList ) && theIsCreate ) + theTypesList = TDataStd_IntegerList::Set( aSectLabel ); - Handle(TDataStd_BooleanList) aClosuresList; - if ( !aSectsLabel.FindAttribute( TDataStd_BooleanList::GetID(), aClosuresList ) && theIsCreate ) - aClosuresList = TDataStd_BooleanList::Set( aSectsLabel ); + if ( !aSectLabel.FindAttribute( TDataStd_BooleanList::GetID(), theClosuresList ) && theIsCreate ) + theClosuresList = TDataStd_BooleanList::Set( aSectLabel ); } void HYDROData_IPolyline::removeSectionsLists() @@ -247,13 +150,13 @@ void HYDROData_IPolyline::getPointsLists( const int theSectionI } } -void HYDROData_IPolyline::removePointsLists( const int theSectionIndex ) +void HYDROData_IPolyline::removePointsLists( const int theSectionIndex ) const { TDF_Label aLabel = myLab.FindChild( DataTag_Points, false ); if ( aLabel.IsNull() ) return; - if ( theSectionIndex == -1 ) + if ( theSectionIndex < 0 ) { aLabel.ForgetAllAttributes(); }