From 60c1b803621af637e863bf91a54f59251a28552c Mon Sep 17 00:00:00 2001 From: isn Date: Fri, 21 Dec 2018 22:07:13 +0300 Subject: [PATCH] LOT 15 Signed-off-by: isn --- src/HYDROData/CMakeLists.txt | 2 + src/HYDROData/HYDROData_CalculationCase.h | 4 +- src/HYDROData/HYDROData_CompleteCalcCase.cxx | 435 +++++++++++++++++++ src/HYDROData/HYDROData_CompleteCalcCase.h | 44 ++ src/HYDROData/HYDROData_Region.cxx | 13 +- src/HYDROData/HYDROData_Region.h | 4 +- src/HYDROData/HYDROData_SplitToZonesTool.cxx | 2 +- src/HYDROData/HYDROData_SplitToZonesTool.h | 5 + src/HYDROGUI/HYDROGUI_CalculationDlg.cxx | 19 +- src/HYDROGUI/HYDROGUI_CalculationDlg.h | 4 +- src/HYDROGUI/HYDROGUI_CalculationOp.cxx | 64 ++- src/HYDROGUI/HYDROGUI_CalculationOp.h | 5 +- src/HYDROGUI/HYDROGUI_Module.cxx | 1 + src/HYDROGUI/HYDROGUI_Operations.cxx | 9 +- src/HYDROGUI/HYDROGUI_Operations.h | 1 + 15 files changed, 588 insertions(+), 24 deletions(-) create mode 100644 src/HYDROData/HYDROData_CompleteCalcCase.cxx create mode 100644 src/HYDROData/HYDROData_CompleteCalcCase.h diff --git a/src/HYDROData/CMakeLists.txt b/src/HYDROData/CMakeLists.txt index 94a55cc6..9c412e81 100644 --- a/src/HYDROData/CMakeLists.txt +++ b/src/HYDROData/CMakeLists.txt @@ -66,6 +66,7 @@ set(PROJECT_HEADERS HYDROData_DTM.h HYDROData_BCPolygon.h HYDROData_BoundaryPolygonTools.h + HYDROData_CompleteCalcCase.h ) set(PROJECT_SOURCES @@ -130,6 +131,7 @@ set(PROJECT_SOURCES HYDROData_DTM.cxx HYDROData_BCPolygon.cxx HYDROData_BoundaryPolygonTools.cxx + HYDROData_CompleteCalcCase.cxx ) SET( ECW_INCLUDES $ENV{ECWLIB_ROOT_DIR}/include ) diff --git a/src/HYDROData/HYDROData_CalculationCase.h b/src/HYDROData/HYDROData_CalculationCase.h index 74a128e0..953be5ce 100644 --- a/src/HYDROData/HYDROData_CalculationCase.h +++ b/src/HYDROData/HYDROData_CalculationCase.h @@ -426,7 +426,9 @@ private: * Add new one region for calculation case. * The new region is added into the list of reference regions. */ - Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc, + + public: //TEMP TODO + HYDRODATA_EXPORT Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc, const QString& thePrefixOrName, bool isPrefix = true ); diff --git a/src/HYDROData/HYDROData_CompleteCalcCase.cxx b/src/HYDROData/HYDROData_CompleteCalcCase.cxx new file mode 100644 index 00000000..2aa627b0 --- /dev/null +++ b/src/HYDROData/HYDROData_CompleteCalcCase.cxx @@ -0,0 +1,435 @@ +// Copyright (C) 2014-2018 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 +// + +// File: HYDROData_CompleteCalcCase.cxx +// Author: Ilya SHCHEKIN + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void GetModifToOrigHistory(BOPAlgo_Builder& theAlgo, TopTools_IndexedDataMapOfShapeListOfShape& theModifToOrigMap) +{ + const TopTools_ListOfShape& args = theAlgo.Arguments(); + TopTools_IndexedMapOfShape argsAllSh; + TopTools_ListOfShape::Iterator it(args); + for (;it.More();it.Next()) + TopExp::MapShapes(it.Value(), argsAllSh); + for (int i=1;i<=argsAllSh.Extent();i++) + { + const TopoDS_Shape& arg_sh = argsAllSh(i); + const TopTools_ListOfShape& modif_ls = theAlgo.Modified(arg_sh); + for (TopTools_ListIteratorOfListOfShape itLS(modif_ls); itLS.More(); itLS.Next()) + { + const TopoDS_Shape& val = itLS.Value(); + TopTools_ListOfShape* LS = theModifToOrigMap.ChangeSeek(val); + if (LS) + LS->Append(arg_sh); + else + { + TopTools_ListOfShape newLS; + newLS.Append(arg_sh); + theModifToOrigMap.Add(val, newLS); + } + } + } +} + + +static bool CheckIntersection(BOPAlgo_Builder& theAlgo, const std::vector& SHM, + const TopTools_MapOfShape& ShapesToAvoid) +{ + TopTools_MapOfShape gmodif_m; + int calc_ext = 0; + for (int i=0; i theNewObjects, + bool& IsIntersectionOfNewObj) +{ + Handle(HYDROData_PolylineXY) aBndPolyline = theCalcCase->GetBoundaryPolyline(); + TopoDS_Wire aBndWire; + TopoDS_Face aLimFace; + bool UseBndPolyline = false; + QString CaseName = theCalcCase->GetName(); + if (!aBndPolyline.IsNull()) + { + Handle(TopTools_HSequenceOfShape) aConnectedWires = new TopTools_HSequenceOfShape; + int nbWires = aBndPolyline->GetNbConnectedWires(aConnectedWires); + if (nbWires > 0) + { + aBndWire = TopoDS::Wire(aConnectedWires->Value(1)); + if(!aBndWire.IsNull()) + { + if(HYDROData_SplitToZonesTool::buildLimFace(aBndWire, aLimFace)) + { + theNewObjects.Append(theCalcCase->GetBoundaryPolyline()); + UseBndPolyline = true; + } + } + } + } + + BOPAlgo_Builder anAlgo; + std::vector newShapes; + std::vector newshapesGroups; + NCollection_DataMap aShToRefObjects; + for (int i=1; i<= theNewObjects.Size();i++) + { + Handle(HYDROData_PolylineXY) aPolyXY = Handle(HYDROData_PolylineXY)::DownCast( theNewObjects(i) ); + if (!aPolyXY.IsNull()) + { + TopoDS_Shape aSh = aPolyXY->GetShape(); + newShapes.push_back(aSh); + anAlgo.AddArgument(aSh); + QStringList aLS(aPolyXY->GetName()); + aShToRefObjects.Bind(aSh, aLS); + } + else + { + Handle(HYDROData_Object ) anObj = Handle(HYDROData_Object)::DownCast( theNewObjects(i) ); + if (!anObj.IsNull()) + { + TopoDS_Shape aSh = anObj->GetTopShape(); + // + HYDROData_SequenceOfObjects groups = anObj->GetGroups(); + for ( int k=1; k<=groups.Size(); k++ ) + { + Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast(groups(k)); + if ( aGroup.IsNull() ) + continue; + newshapesGroups.push_back(aGroup); + } + // + newShapes.push_back(aSh); + anAlgo.AddArgument(aSh); + QStringList aLS(anObj->GetName()); + aShToRefObjects.Bind(aSh, aLS); + } + } + } + + HYDROData_SequenceOfObjects aRegions = theCalcCase->GetRegions(); + for ( int i = 1; i <= aRegions.Size(); i++ ) + { + Handle(HYDROData_Region) aRegion = Handle(HYDROData_Region)::DownCast( aRegions(i) ); + if ( !aRegion.IsNull() ) + { + HYDROData_SequenceOfObjects aZones = aRegion->GetZones(); + for ( int j = 1; j <= aZones.Size(); j++ ) + { + Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( aZones(j) ); + TopoDS_Shape aSh = aZone->GetShape(); + anAlgo.AddArgument(aSh); + HYDROData_SequenceOfObjects aRefObjects = aZone->GetObjects(); + QStringList aRefObjList; + for (int k=1;k<=aRefObjects.Size();k++) + aRefObjList << aRefObjects(k)->GetName(); + aShToRefObjects.Bind(aSh, aRefObjList); + } + } + } + + anAlgo.Perform(); +#if OCC_VERSION_LARGE > 0x07020000 + if (anAlgo.HasErrors()) + return false; +#endif + TopoDS_Shape aRes = anAlgo.Shape(); + TopTools_MapOfShape UsedFaces; + /// + TopTools_IndexedDataMapOfShapeListOfShape theModifToOrigMap; + GetModifToOrigHistory(anAlgo, theModifToOrigMap); + + // + if (UseBndPolyline) + { + TopTools_IndexedMapOfShape aResFaces; + TopExp::MapShapes(aRes, TopAbs_FACE, aResFaces); + Handle(IntTools_Context) aContext = new IntTools_Context(); + for (int i=1; i<= aResFaces.Extent();i++) + { + gp_Pnt aP3D; + gp_Pnt2d aP2D; + TopoDS_Face aF = TopoDS::Face(aResFaces(i)); + int err = BOPTools_AlgoTools3D::PointInFace(aF, aP3D, aP2D, aContext); + if (err) + continue; + + TopAbs_State aState = HYDROData_Tool::ComputePointState(gp_XY(aP3D.X(), aP3D.Y()), aLimFace); + if (aState == TopAbs_OUT) + { + UsedFaces.Add(aF); //filter out the faces which is out of boundary polyline + } + } + } + + /// + //check intersection between new objects => if it's present, the combining of zones into region will be depend on ordering + IsIntersectionOfNewObj = CheckIntersection(anAlgo, newShapes, UsedFaces); + // + std::vector> NREGV; //new regions vector (each vector is a region, subvector == zones) + for (int i=0;i vect; + vect.push_back(aSh); + NREGV.push_back(vect); + UsedFaces.Add(aSh); + } + } + else //was modified + { + std::vector vect; + for (TopTools_ListIteratorOfListOfShape it(newShL); it.More(); it.Next()) + { + TopoDS_Face nF = TopoDS::Face(it.Value()); + if (!nF.IsNull() && !UsedFaces.Contains(nF)) + { + vect.push_back(nF); + UsedFaces.Add(nF); + } + } + NREGV.push_back(vect); + } + } + + //iter through already existing zone + //substract new zones (NREGV) from old zones + for ( int i = 1; i <= aRegions.Size(); i++ ) + { + Handle(HYDROData_Region) aRegion = Handle(HYDROData_Region)::DownCast( aRegions(i) ); + if ( !aRegion.IsNull() ) + { + HYDROData_SequenceOfObjects aZones = aRegion->GetZones(); + for ( int j = 1; j <= aZones.Size(); j++ ) + { + Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast(aZones(j)); + TopoDS_Shape aSh = aZone->GetShape(); + TopTools_ListOfShape newShL = anAlgo.Modified(aSh); + if (newShL.IsEmpty() ) + newShL.Append(aSh); + TopTools_MapOfShape newShM; + for (TopTools_ListIteratorOfListOfShape it(newShL); it.More(); it.Next()) + newShM.Add(it.Value()); + // + newShM.Subtract(UsedFaces); ///substract UsedFaces from newShM (since they have been taken by regions/object with higher priority) + // + + if (newShM.Size() == 0) + { + //remove zone + aRegion->RemoveZone(aZone, true); + } + else if (newShM.Size() == 1) + { + TopoDS_Shape newS = *newShM.cbegin(); + if (!newS.IsEqual(aSh)) + aZone->SetShape(newS); + } + else ///newShM > 1 + { + QString anOldZoneName = aZone->GetName(); + HYDROData_SequenceOfObjects aRefObjects = aZone->GetObjects(); + aRegion->RemoveZone(aZone, false); + QStringList aRefObjList; + for (int k=1;k<=aRefObjects.Size();k++) + aRefObjList << aRefObjects(k)->GetName(); + for (TopTools_MapIteratorOfMapOfShape it(newShM); it.More(); it.Next()) + { + if (it.Value().ShapeType() == TopAbs_FACE) + { + TopoDS_Face F = TopoDS::Face(it.Value()); + aRegion->addNewZone( doc, anOldZoneName, F, aRefObjList ); + } + } + } + } + } + } + + //create new regions/zones based on NREGV + QString aRegsPref = CaseName + "_Reg_"; + QString aZonesPref = CaseName + "_Zone"; + for ( int k=0;k& sh_vec = NREGV[k]; + Handle(HYDROData_Region) aRegion = theCalcCase->addNewRegion( doc, aRegsPref ); + for (int i=0;iaddNewZone( doc, aZonesPref, nF, refObjList); + } + } + + //GROUPS + HYDROData_SequenceOfObjects aSplitGroups = theCalcCase->GetSplitGroups(); + + ///process boundary polyline group (if present) + Handle(HYDROData_ShapesGroup) aBndWireGroup; + QString BndWireGroupName; + TopTools_ListOfShape aNewGroupForBndWireLS; + if (UseBndPolyline) + { + TopTools_IndexedMapOfShape aBndWireEdges; + TopTools_IndexedDataMapOfShapeListOfShape aResEdgesToFaces; + TopExp::MapShapes(aBndWire, TopAbs_EDGE, aBndWireEdges); + TopExp::MapShapesAndAncestors(aRes, TopAbs_EDGE, TopAbs_FACE, aResEdgesToFaces); + TopTools_IndexedMapOfShape aNewGroupForBndWire; + for (int i=1;i<=aBndWireEdges.Extent();i++) + { + TopoDS_Shape E = aBndWireEdges(i); + TopTools_ListOfShape aMLS = anAlgo.Modified(E); + if (aMLS.IsEmpty()) + aMLS.Append(E); + TopTools_ListIteratorOfListOfShape itLS(aMLS); + for (;itLS.More();itLS.Next()) + { + TopoDS_Edge E1 = TopoDS::Edge(itLS.Value()); + if (E1.IsNull()) + continue; + if (!aResEdgesToFaces.Contains(E1)) //should contains E since it's a part of aRes + continue; + //skip free edges + if (aResEdgesToFaces.FindFromKey(E1).Extent() > 0) + aNewGroupForBndWire.Add(E1); + } + } + // + BndWireGroupName = CaseName + "_" + aBndPolyline->GetName(); + for (int i=1;i<=aNewGroupForBndWire.Extent();i++) + aNewGroupForBndWireLS.Append(aNewGroupForBndWire(i)); + } + + // UPDATE SPLIT GROUPS + for ( int k=1; k<=aSplitGroups.Size(); k++ ) + { + Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast(aSplitGroups(k)); + if ( aGroup.IsNull() ) + continue; + + TopTools_SequenceOfShape GDefSeq, ModifedGDefSeq; + + if (UseBndPolyline && aGroup->GetName() == BndWireGroupName) + { + aBndWireGroup = aGroup; + continue; + } + + aGroup->GetShapes( GDefSeq ); + for (int i=1;i<=GDefSeq.Length();i++) + { + const TopoDS_Shape& CSH = GDefSeq(i); + TopTools_ListOfShape aMLS = anAlgo.Modified(CSH); + if (aMLS.IsEmpty()) + aMLS.Append(CSH); + TopTools_ListIteratorOfListOfShape itLS(aMLS); + for (;itLS.More();itLS.Next()) + ModifedGDefSeq.Append(itLS.Value()); + } + aGroup->SetShapes(ModifedGDefSeq); + } + + if (UseBndPolyline) + { + if (!aBndWireGroup.IsNull()) //modify group + { + aBndWireGroup->SetShapes(aNewGroupForBndWireLS); + } + else //add new group + { + Handle(HYDROData_SplitShapesGroup) aSplitGroup = theCalcCase->addNewSplitGroup( BndWireGroupName ); + aSplitGroup->SetShapes(aNewGroupForBndWireLS); + } + } + + ///Add new groups from newly added objects + for ( int k=0; kGetName(); + TopTools_SequenceOfShape aSeqSh, ModifedGDefSeq; + aGroup->GetShapes(aSeqSh); + Handle(HYDROData_SplitShapesGroup) aSplitGroup = theCalcCase->addNewSplitGroup( aName ); + + for (int i=1;i<=aSeqSh.Length();i++) + { + const TopoDS_Shape& CSH = aSeqSh(i); + TopTools_ListOfShape aMLS = anAlgo.Modified(CSH); + if (aMLS.IsEmpty()) + aMLS.Append(CSH); + TopTools_ListIteratorOfListOfShape itLS(aMLS); + for (;itLS.More();itLS.Next()) + ModifedGDefSeq.Append(itLS.Value()); + } + aSplitGroup->SetShapes(ModifedGDefSeq); + } + return true; +} diff --git a/src/HYDROData/HYDROData_CompleteCalcCase.h b/src/HYDROData/HYDROData_CompleteCalcCase.h new file mode 100644 index 00000000..9f170c85 --- /dev/null +++ b/src/HYDROData/HYDROData_CompleteCalcCase.h @@ -0,0 +1,44 @@ +// 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 +// + +#ifndef HYDROData_CompleteCalcCase_HeaderFile +#define HYDROData_CompleteCalcCase_HeaderFile + + +/**\class HYDROData_CompleteCalcCase + * + * \brief Allows to add new objects (natural/artificial objects, polylines) to already existing calc.case without full recomputation + * +*/ + +#include +#include +#include + +class HYDRODATA_EXPORT HYDROData_CompleteCalcCase +{ +public: + + static bool AddObjects( const Handle(HYDROData_Document)& doc, + Handle(HYDROData_CalculationCase)& theCalcCase, + NCollection_Sequence theNewObjects, + bool& IsIntersectionOfNewObj); + +}; + +#endif diff --git a/src/HYDROData/HYDROData_Region.cxx b/src/HYDROData/HYDROData_Region.cxx index 0a32ca18..4e2a6be6 100644 --- a/src/HYDROData/HYDROData_Region.cxx +++ b/src/HYDROData/HYDROData_Region.cxx @@ -137,7 +137,7 @@ HYDROData_SequenceOfObjects HYDROData_Region::GetZones() const return GetReferenceObjects( DataTag_Zone ); } -void HYDROData_Region::RemoveZone( const Handle(HYDROData_Zone)& theZone ) +void HYDROData_Region::RemoveZone( const Handle(HYDROData_Zone)& theZone, bool removeRegion ) { if ( theZone.IsNull() ) return; @@ -150,10 +150,13 @@ void HYDROData_Region::RemoveZone( const Handle(HYDROData_Zone)& theZone ) if ( !aFatherRegion.IsNull() && aFatherRegion->Label() == myLab ) theZone->Remove(); - // If the last zone has been removed from region we remove this region - HYDROData_SequenceOfObjects aRefZones = GetZones(); - if ( aRefZones.IsEmpty() ) - Remove(); + if (removeRegion) + { + // If the last zone has been removed from region we remove this region + HYDROData_SequenceOfObjects aRefZones = GetZones(); + if ( aRefZones.IsEmpty() ) + Remove(); + } } void HYDROData_Region::RemoveZones() diff --git a/src/HYDROData/HYDROData_Region.h b/src/HYDROData/HYDROData_Region.h index 205e546e..b9a5314c 100644 --- a/src/HYDROData/HYDROData_Region.h +++ b/src/HYDROData/HYDROData_Region.h @@ -96,7 +96,7 @@ public: /** * Removes reference zone from region. */ - HYDRODATA_EXPORT virtual void RemoveZone( const Handle(HYDROData_Zone)& theZone ); + HYDRODATA_EXPORT virtual void RemoveZone( const Handle(HYDROData_Zone)& theZone, bool removeRegion = true ); /** * Removes all reference zones from region. @@ -115,8 +115,6 @@ public: HYDRODATA_EXPORT bool IsSubmersible() const; -protected: - /** * Create new one reference zone for region on child label. * The new zone is added into the list of reference zones. diff --git a/src/HYDROData/HYDROData_SplitToZonesTool.cxx b/src/HYDROData/HYDROData_SplitToZonesTool.cxx index 25302c15..cea2e55c 100644 --- a/src/HYDROData/HYDROData_SplitToZonesTool.cxx +++ b/src/HYDROData/HYDROData_SplitToZonesTool.cxx @@ -78,7 +78,7 @@ TopoDS_Face HYDROData_SplitToZonesTool::SplitData::Face() const return aResFace; } -Standard_Boolean buildLimFace(const TopoDS_Wire& theBndWire, TopoDS_Face& outFace) +Standard_Boolean HYDROData_SplitToZonesTool::buildLimFace(const TopoDS_Wire& theBndWire, TopoDS_Face& outFace) { GProp_GProps G; BRepGProp::LinearProperties(theBndWire,G); diff --git a/src/HYDROData/HYDROData_SplitToZonesTool.h b/src/HYDROData/HYDROData_SplitToZonesTool.h index b4e092eb..e3d9af03 100644 --- a/src/HYDROData/HYDROData_SplitToZonesTool.h +++ b/src/HYDROData/HYDROData_SplitToZonesTool.h @@ -28,6 +28,8 @@ #include #include #include +#include + #include #include #include @@ -113,6 +115,9 @@ public: static void SetFileNames(const QString& theNameBefore, const QString& theNameAfter); + static Standard_Boolean buildLimFace(const TopoDS_Wire& theBndWire, TopoDS_Face& outFace); + + private: /** diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index b5c783d8..c4fd3ac7 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -917,18 +917,23 @@ void HYDROGUI_CalculationDlg::setEditZonesEnabled( const bool theIsEnabled ) Get included geometry objects. @return the list of geometry objects */ -QList HYDROGUI_CalculationDlg::getGeometryObjects() +QList HYDROGUI_CalculationDlg::getGeometryObjects(bool GeomObjOnly) { QList anEntities = myGeomObjects->getObjects(); QList anObjects; - foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) { - Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( anEntity ); - if ( anObj.IsNull() ) { - continue; + foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) + { + if (GeomObjOnly) + { + Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( anEntity ); + if ( anObj.IsNull() ) { + continue; + } + anObjects << anObj; } - - anObjects << anObj; + else + anObjects << anEntity; } return anObjects; diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.h b/src/HYDROGUI/HYDROGUI_CalculationDlg.h index 2866b623..07307c74 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.h +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.h @@ -83,6 +83,8 @@ public: HYDROData_ListOfRules getRules() const; void setRules( const HYDROData_ListOfRules& theRules ) const; + QList getGeometryObjects(bool GeomObjOnly = true); + public slots: void setMode( int theMode ); void setBoundary( const QString& theObjName ); @@ -158,7 +160,7 @@ protected slots: void OnNewRegion(); private: - QList getGeometryObjects(); + QWizardPage* createObjectsPage(); QWizardPage* createGroupsPage(); diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 739df20f..fca5ae8d 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -51,15 +51,21 @@ #include #include #include +#include +#include +#include +#include +#include -HYDROGUI_CalculationOp::HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit ) +HYDROGUI_CalculationOp::HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit, bool IsComplete ) : HYDROGUI_Operation( theModule ), myIsEdit( theIsEdit ), myActiveViewManager( NULL ), myPreviewViewManager( NULL ), myShowGeomObjects( true ), myShowLandCoverMap( false ), - myShowZones( false ) + myShowZones( false ), + myDenyIncExcl (IsComplete) { setName( myIsEdit ? tr( "EDIT_CALCULATION" ) : tr( "CREATE_CALCULATION" ) ); } @@ -177,6 +183,9 @@ void HYDROGUI_CalculationOp::startOperation() aPanel->setObjectName( anObjectName ); aPanel->setEditedObject( myEditedObject ); + myIncObjAtStart.clear(); + myIncObjAtStart = aPanel->getGeometryObjects(false); + setGeomObjectsVisible( true ); createPreview( false ); @@ -571,6 +580,20 @@ void HYDROGUI_CalculationOp::onRemoveObjects() return; QStringList aSelectedList = aPanel->getSelectedGeomObjects(); + + if (myDenyIncExcl) + { + QSet selMap = aSelectedList.toSet(); + myIncObjAtStart.toVector(); + for (int i=0;iGetName(); + if (selMap.contains(str)) + return; + } + } + + if ( aSelectedList.isEmpty() || !confirmRegionsChange() ) return; @@ -602,10 +625,21 @@ void HYDROGUI_CalculationOp::onRemoveObjects() bool HYDROGUI_CalculationOp::confirmRegionsChange() const { + // Check if the case is already modified or not bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ); + if ( !isConfirmed ) { + + if (myDenyIncExcl) + { + SUIT_MessageBox::information(module()->getApp()->desktop(), + tr( "REGIONS_CHANGED" ), + tr( "COMPLETE_OP_WILL_BE_PERFORMED" )); + return true; + } + // If not modified check if the case has already defined regions with zones HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions(); if ( aSeq.Length() > 0 ) @@ -812,7 +846,7 @@ void HYDROGUI_CalculationOp::onApply() aMsg ); } } - +#include void HYDROGUI_CalculationOp::onNext( const int theIndex ) { if( theIndex==1 ) @@ -986,7 +1020,29 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) ) { myShowZones = true; - myEditedObject->Update(); + + if (myDenyIncExcl) + { + QList ibcludedGeomObj = aPanel->getGeometryObjects(false); + //QSet includedObjAtStartSet = myIncObjAtStart.toSet(); + NCollection_Sequence theNewObjects; + foreach (Handle(HYDROData_Entity) obj, ibcludedGeomObj) + { + if (!myIncObjAtStart.contains(obj)) + theNewObjects.Append(obj); + } + + bool is_int = false; + HYDROData_CompleteCalcCase::AddObjects(doc(), myEditedObject, theNewObjects, is_int); + if (is_int) + SUIT_MessageBox::information(module()->getApp()->desktop(), + tr( "COMPLETE_CASE" ), + tr( "There is an intersection(s) between new objects. result will be depend on order" )); + + myEditedObject->ClearChanged(); + } + else + myEditedObject->Update(); AssignDefaultZonesColors(); diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index 8eb18c14..e2ba6d4c 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -38,7 +38,7 @@ class HYDROGUI_CalculationOp : public HYDROGUI_Operation Q_OBJECT public: - HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit ); + HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit, bool IsComplete ); virtual ~HYDROGUI_CalculationOp(); protected: @@ -170,6 +170,9 @@ private: SUIT_ViewManager* myActiveViewManager; OCCViewer_ViewManager* myPreviewViewManager; + QList myIncObjAtStart; + + bool myDenyIncExcl; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index cca1a2ae..4b0e8863 100755 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -693,6 +693,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, { theMenu->addAction( action( EditCalculationId ) ); theMenu->addAction( action( ExportCalculationId ) ); + theMenu->addAction( action( CompleteCalculationId ) ); theMenu->addSeparator(); } else if( anIsImmersibleZone ) diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 8c459d9a..f4cec87b 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -214,6 +214,8 @@ void HYDROGUI_Module::createActions() createAction( EditCalculationId, "EDIT_CALCULATION", "EDIT_CALCULATION_ICO" ); createAction( ExportCalculationId, "EXPORT_CALCULATION", "EXPORT_CALCULATION_ICO" ); + createAction( CompleteCalculationId, "COMPLETE_CALCULATION", "COMPLETE_CALCULATION_ICO" ); + createAction( FuseImagesId, "FUSE_IMAGES", "FUSE_IMAGES_ICO" ); createAction( EditFusedImageId, "EDIT_FUSED_IMAGE", "EDIT_FUSED_IMAGE_ICO" ); @@ -736,8 +738,13 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const break; case CreateCalculationId: case EditCalculationId: - anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId ); + anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId, false ); + break; + + case CompleteCalculationId: + anOp = new HYDROGUI_CalculationOp( aModule, true, true); break; + case ExportCalculationId: anOp = new HYDROGUI_ExportCalculationOp( aModule ); break; diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index c1aac72b..4ebcef91 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -72,6 +72,7 @@ enum OperationId CreateCalculationId, EditCalculationId, ExportCalculationId, + CompleteCalculationId, FuseImagesId, EditFusedImageId, -- 2.39.2