From: Yoann AUDOUIN Date: Tue, 3 Mar 2020 08:29:19 +0000 (+0100) Subject: Merge branch 'BR_PY3' X-Git-Tag: SH_V2_2_0~99 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e2416eca5bf95eb9a8b84d3159ef37a6c4eff230;p=modules%2Fhydro.git Merge branch 'BR_PY3' --- e2416eca5bf95eb9a8b84d3159ef37a6c4eff230 diff --cc src/HYDROData/HYDROData_Entity.cxx index 9aaa587e,16d303da..da1e1e2e --- a/src/HYDROData/HYDROData_Entity.cxx +++ b/src/HYDROData/HYDROData_Entity.cxx @@@ -223,7 -342,7 +342,7 @@@ void HYDROData_Entity::CopyTo( const Ha TDF_CopyLabel aCopy(myLab, theDestination->Label()); aCopy.Perform(); -- ++ if( isGenerateNewName ) { // generate a new unique name for the clone object: @@@ -287,9 -406,10 +406,10 @@@ bool HYDROData_Entity::GetZLevel( Stand return false; } -void HYDROData_Entity::SetZLevel( const Standard_Integer& theLevel ) +void HYDROData_Entity::SetZLevel( int theLevel ) { - TDataStd_Integer::Set( myLab.FindChild( DataTag_ZLevel ), theLevel ); + Handle(TDataStd_Integer) A = TDataStd_Integer::Set( myLab.FindChild( DataTag_ZLevel ), theLevel ); + A->SetID(TDataStd_Integer::GetID()); } void HYDROData_Entity::RemoveZLevel() @@@ -301,10 -421,10 +421,10 @@@ void HYDROData_Entity::SetLabel( const TDF_Label& theLabel ) { - myLab = theLabel; + myLab = theLabel; } --void HYDROData_Entity::SaveByteArray( const int theTag, ++void HYDROData_Entity::SaveByteArray( const int theTag, const char* theData, const int theLen ) { @@@ -325,9 -448,11 +448,11 @@@ for(int a = 0; a < theLen; a++) aNewData->SetValue(a + 1, theData[a]); aData->ChangeArray(aNewData); - } else { - for(int a = 0; a < theLen; a++) - aData->SetValue(a + 1, theData[a]); - } ++ } + else + { + // for(int a = 0; a < theLen; a++) + // aData->SetValue(a + 1, theData[a]); } } @@@ -409,7 -535,7 +535,7 @@@ void HYDROData_Entity::SetReferenceObje aRefs = getReferenceList( theTag, true ); // because reference list can be removed if ( !aBeforeObj.IsNull() ) aRefs->InsertBefore( theObj->Label(), aBeforeObj->Label() ); -- else ++ else aRefs->Append( theObj->Label() ); } } @@@ -436,7 -562,7 +562,7 @@@ void HYDROData_Entity::InsertReferenceO Handle(HYDROData_Entity) aBeforeObj = GetReferenceObject( theTag, theBeforeIndex ); if ( !aBeforeObj.IsNull() ) aRefs->InsertBefore( theObj->Label(), aBeforeObj->Label() ); -- else ++ else aRefs->Append( theObj->Label() ); } } @@@ -502,7 -629,7 +629,7 @@@ void HYDROData_Entity::RemoveReferenceO return; if ( aRefs->Extent() == 1 ) -- { ++ { // remove all if only one ClearReferenceObjects( theTag ); return; @@@ -519,7 -646,7 +646,7 @@@ void HYDROData_Entity::RemoveReferenceO return; if ( aRefs->Extent() == 1 && theIndex == 0 ) -- { ++ { // remove all if only one ClearReferenceObjects( theTag ); return; @@@ -766,3 -946,34 +946,34 @@@ double HYDROData_Entity::GetDouble( in return anAttr->Get(); } + + void HYDROData_Entity::SetInteger( int theTag, int theValue ) + { + Handle(TDataStd_Integer) anAttr; + TDF_Label aLabel = myLab.FindChild( theTag ); + if( !aLabel.FindAttribute( TDataStd_Integer::GetID(), anAttr ) ) + { + anAttr = new TDataStd_Integer(); + anAttr->SetID(TDataStd_Integer::GetID()); + aLabel.AddAttribute(anAttr); + } + anAttr->Set( theValue ); + } + + int HYDROData_Entity::GetInteger( int theTag, int theDefValue ) const + { + Handle(TDataStd_Integer) anAttr; + TDF_Label aLabel = myLab.FindChild( theTag ); + if( !aLabel.FindAttribute( TDataStd_Integer::GetID(), anAttr ) ) + return theDefValue; + + return anAttr->Get(); + } + -bool HYDROData_Entity::CompareLabels(const Handle(HYDROData_Entity)& theOtherObj) ++bool HYDROData_Entity::CompareLabels(const Handle(HYDROData_Entity)& theOtherObj) + { + if ( !theOtherObj.IsNull() ) + return this->Label() == theOtherObj->Label(); + return false; -} ++} + diff --cc src/HYDROData/HYDROData_Entity.h index 91f74803,a4bcbd36..78c0d9e3 --- a/src/HYDROData/HYDROData_Entity.h +++ b/src/HYDROData/HYDROData_Entity.h @@@ -87,7 -99,7 +99,7 @@@ HYDRODATA_EXPORT bool IsEqual(const Han * \brief Generic class of any object in the data model. * * Interface for getting access to the object that belong to the data model. -- * Managed by Document. Provides access to the common properties: ++ * Managed by Document. Provides access to the common properties: * kind of an object, name. */ class HYDROData_Entity : public MMgt_TShared @@@ -198,7 -219,7 +219,7 @@@ public /** * Returns flag indicating that object can be removed or not. -- * Reimplement this method in class which can't be removed ++ * Reimplement this method in class which can't be removed * separately with it parent object. * Base implementaiton returns always TRUE. */ @@@ -268,13 -297,21 +297,21 @@@ * \param theDefColor default color to return if attribute has not been set before */ HYDRODATA_EXPORT QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const; - + + /* 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 theOutColor color to return if attribute has been set before + * \return true if attribute is present + */ + HYDRODATA_EXPORT bool GetColor( QColor& theOutColor, + const int theTag ) const; - ++ protected: friend class HYDROData_Iterator; /** -- * Creates new object in the internal data structure. Use higher level objects ++ * Creates new object in the internal data structure. Use higher level objects * to create objects with real content. */ HYDRODATA_EXPORT HYDROData_Entity( Geometry ); @@@ -302,7 -339,7 +339,7 @@@ * Internal method that used to retreive the content of byte array attribute * \param theTag tag of a label that keeps the attribute (for 0 this is myLab) * \param theLen number of bytes in byte array -- * \returns pointer to the internal data structure wit harray content, ++ * \returns pointer to the internal data structure wit harray content, * or NULL if array size is zero */ const char* ByteArray(const int theTag, int& theLen) const; @@@ -334,7 -371,7 +371,7 @@@ * Internal method that used to store the reference object label attribute * \param theObj pointer to reference object * \param theTag tag of a label to store attribute (for 0 this is myLab) -- * \param theIndex index in the list of references ++ * \param theIndex index in the list of references - if more that len then just append it to the end of list - if less than zero then prepend to the list - indexing starts from 0 @@@ -347,7 -384,7 +384,7 @@@ * Internal method that used to store the reference object label attribute * \param theObj pointer to reference object * \param theTag tag of a label to store attribute (for 0 this is myLab) -- * \param theBeforeIndex index in the list of references ++ * \param theBeforeIndex index in the list of references - if more that len then just append it to the end of list - if less than zero then prepend to the list - indexing starts from 0 @@@ -367,7 -404,7 +404,7 @@@ /** * Internal method that used to retreive the reference object(s) attribute * \param theTag tag of a label that keeps the attribute (for 0 this is myLab) -- * \param theIndex index in the list of references ++ * \param theIndex index in the list of references * - indexing starts from 0 * \returns pointer to reference object or NULL if label is not set */ @@@ -386,7 -423,7 +423,7 @@@ /** * Internal method that used to remove the reference object attribute * \param theTag tag of a label that keeps the attribute (for 0 this is myLab) -- * \param theIndex index in the list of references ++ * \param theIndex index in the list of references * - indexing starts from 0 */ void RemoveReferenceObject( const int theTag = 0, const int theIndex = 0 ); @@@ -396,12 -433,16 +433,16 @@@ * \param theTag tag of a label that keeps the attribute (for 0 this is myLab) */ void ClearReferenceObjects( const int theTag = 0 ); - + + public: + + HYDRODATA_EXPORT virtual bool CompareLabels(const Handle(HYDROData_Entity)& theOtherObj); - ++ protected: /** * Dump the initial object creation to a Python script. -- * You should call it from DumpToPython implementation before ++ * You should call it from DumpToPython implementation before * dumping fields of the object. */ HYDRODATA_EXPORT virtual QStringList dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const; @@@ -430,7 -471,7 +471,7 @@@ protected Handle(TDataStd_ReferenceList) getReferenceList( const int theTag, const bool theIsCreate ) const; -- ++ void SetShape( int theTag, const TopoDS_Shape& theShape ); TopoDS_Shape GetShape( int theTag ) const; diff --cc src/HYDROData/HYDROData_LandCoverMap.h index ebaeb1e7,1d310ef3..5f82cd21 --- a/src/HYDROData/HYDROData_LandCoverMap.h +++ b/src/HYDROData/HYDROData_LandCoverMap.h @@@ -114,9 -114,9 +114,10 @@@ public HYDRODATA_EXPORT bool Add( const Handle( HYDROData_Object )&, const QString& theType ); HYDRODATA_EXPORT bool Add( const Handle( HYDROData_PolylineXY )&, const QString& theType ); + using HYDROData_Entity::Remove; HYDRODATA_EXPORT bool Remove( const TopoDS_Face& ); HYDRODATA_EXPORT bool Remove( const TopTools_ListOfShape& ); + using HYDROData_Entity::Remove; HYDRODATA_EXPORT bool Split( const Handle( HYDROData_PolylineXY )& ); HYDRODATA_EXPORT bool Split( const TopoDS_Shape& ); diff --cc src/HYDROData/HYDROData_ShapeFile.cxx index 30a39620,fc093146..d372e18e --- a/src/HYDROData/HYDROData_ShapeFile.cxx +++ b/src/HYDROData/HYDROData_ShapeFile.cxx @@@ -66,11 -66,11 +66,11 @@@ #pragma warning( disable: 4996 ) #endif --//SHP->TFaces (Import) ++//SHP->TFaces (Import) #define OSD_TIMER HYDROData_ShapeFile::HYDROData_ShapeFile() : myHSHP(NULL) --{ ++{ } HYDROData_ShapeFile::~HYDROData_ShapeFile() @@@ -86,9 -87,9 +87,9 @@@ void HYDROData_ShapeFile::Export(Handle SHPHandle hSHPHandle; if (!aPolyXYSeq.IsEmpty() && aPoly3DSeq.IsEmpty()) { -- hSHPHandle = SHPCreate( aFileName.toLatin1().data(), SHPT_ARC ); ++ hSHPHandle = SHPCreate( aFileName.toLatin1().data(), SHPT_ARC ); for (int i = 1; i <= aPolyXYSeq.Size(); i++) - if (WriteObjectPolyXY(hSHPHandle, aPolyXYSeq(i)) != 1) + if (WriteObjectPolyXY(theDocument, hSHPHandle, aPolyXYSeq(i)) != 1) aNonExpList.append(aPolyXYSeq(i)->GetName()); } else if (aPolyXYSeq.IsEmpty() && !aPoly3DSeq.IsEmpty()) @@@ -144,8 -150,8 +150,8 @@@ int HYDROData_ShapeFile::WriteObjectPol SHPObject *aSHPObj; std::vector x, y; std::vector anPartStart; -- -- for (int i = 0; i < thePoly->NbSections(); i++) ++ ++ for (int i = 0; i < thePoly->NbSections(); i++) if (thePoly->GetSectionType(i) == HYDROData_IPolyline::SECTION_SPLINE) return -1; @@@ -160,47 -168,50 +168,50 @@@ } if (thePoly->IsClosedSection(i)) { - x.push_back( aPointList(1).X()); - y.push_back( aPointList(1).Y()); + gp_XY P = aPointList(1); + //theDocument->Transform(P, false); + x.push_back( P.X()); + y.push_back( P.Y()); } } -- - aSHPObj = SHPCreateObject( SHPT_ARC, -1, thePoly->NbSections(), &anPartStart[0], NULL, x.size(), &x[0], &y[0], NULL, NULL ); ++ + aSHPObj = SHPCreateObject (SHPT_ARC, -1, thePoly->NbSections(), &anPartStart[0], NULL, x.size(), &x[0], &y[0], NULL, NULL ); SHPWriteObject( theShpHandle, -1, aSHPObj ); SHPDestroyObject( aSHPObj ); return 1; } - int HYDROData_ShapeFile::WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROData_Polyline3D thePoly ) + int HYDROData_ShapeFile::WriteObjectPoly3D(Handle(HYDROData_Document) theDocument, + SHPHandle theShpHandle, + Handle(HYDROData_Polyline3D) thePoly ) { - SHPObject *aSHPObj; + SHPObject *aSHPObj; std::vector x, y, z; std::vector anPartStart; + anPartStart.push_back(0); //one section only - for (int i = 0; i < thePoly->GetPolylineXY()->NbSections(); i++) - if (thePoly->GetPolylineXY()->GetSectionType(i) == HYDROData_IPolyline::SECTION_SPLINE) - return -1; - - for (int i = 0; i < thePoly->GetPolylineXY()->NbSections(); i++) - { - anPartStart.push_back(x.size()); - HYDROData_PolylineXY::PointsList aPointList = thePoly->GetPolylineXY()->GetPoints(i); - for (int j = 1; j <= aPointList.Size(); j++) - { - x.push_back( aPointList(j).X()); - y.push_back( aPointList(j).Y()); - z.push_back(thePoly->GetAltitudeObject()->GetAltitudeForPoint(gp_XY (aPointList(j).X(), aPointList(j).Y()))); - } - if ( thePoly->GetPolylineXY()->IsClosedSection(i)) - { - x.push_back( aPointList(1).X()); - y.push_back( aPointList(1).Y()); - z.push_back(thePoly->GetAltitudeObject()->GetAltitudeForPoint(gp_XY (aPointList(1).X(), aPointList(1).Y()))); + if (thePoly->GetPolylineXY()->GetSectionType(0) == HYDROData_IPolyline::SECTION_SPLINE) - return -1; ++ return -1; - } + HYDROData_Polyline3D::Polyline3DPoints aPointList3D = thePoly->GetProfilePoints3D(true); + for (int j = 1; j <= aPointList3D.Size(); j++) + { + const gp_XYZ& P = aPointList3D(j); + //theDocument->Transform(P, false); + x.push_back(P.X()); + y.push_back(P.Y()); + z.push_back(P.Z()); } - - aSHPObj = SHPCreateObject( SHPT_ARCZ, -1, thePoly->GetPolylineXY()->NbSections(), &anPartStart[0], NULL, x.size(), &x[0], &y[0], &z[0], NULL ); + if ( thePoly->GetPolylineXY()->IsClosedSection(0)) + { + const gp_XYZ& P = aPointList3D(1); + //theDocument->Transform(P, false); + x.push_back(P.X()); + y.push_back(P.Y()); + z.push_back(P.Z()); + } + + aSHPObj = SHPCreateObject( SHPT_ARCZ, -1, 1, &anPartStart[0], NULL, x.size(), &x[0], &y[0], &z[0], NULL ); SHPWriteObject( theShpHandle, -1, aSHPObj ); SHPDestroyObject( aSHPObj ); return 1; @@@ -219,22 -232,24 +232,24 @@@ int HYDROData_ShapeFile::WriteObjectPol else if (theInputShape.ShapeType() == TopAbs_COMPOUND) { TopExp_Explorer Ex(theInputShape, TopAbs_FACE); -- for (; Ex.More(); Ex.Next()) ++ for (; Ex.More(); Ex.Next()) { -- TopoDS_Face aF = TopoDS::Face(Ex.Current()); ++ TopoDS_Face aF = TopoDS::Face(Ex.Current()); if (aF.IsNull()) continue; - ProcessFace(aF, theShpHandle, bUseDiscr, theDefl); + ProcessFace(theDocument, aF, theShpHandle, bUseDiscr, theDefl); } } else return 0; return 1; -- ++ } - void HYDROData_ShapeFile::ProcessFace(const TopoDS_Face& theFace, SHPHandle theShpHandle, + void HYDROData_ShapeFile::ProcessFace(Handle(HYDROData_Document) theDocument, + const TopoDS_Face& theFace, + SHPHandle theShpHandle, bool bUseDiscr, double theDefl ) { if (theFace.ShapeType() != TopAbs_FACE) @@@ -246,26 -261,26 +261,26 @@@ NCollection_Sequence aWires; //write an outer wire first -- aWires.Append(OuterW); -- TopExp_Explorer Ex(theFace, TopAbs_WIRE); -- for (; Ex.More(); Ex.Next()) ++ aWires.Append(OuterW); ++ TopExp_Explorer Ex(theFace, TopAbs_WIRE); ++ for (; Ex.More(); Ex.Next()) { TopoDS_Wire aW = TopoDS::Wire(Ex.Current()); if (aW.IsEqual(OuterW)) continue; -- aWires.Append(aW); ++ aWires.Append(aW); } int NbWires = 0; -- for (int k = 1; k <= aWires.Length(); k++) ++ for (int k = 1; k <= aWires.Length(); k++) { -- TopoDS_Wire aW = aWires(k); ++ TopoDS_Wire aW = aWires(k); if (aW.IsNull()) continue; NbWires++; if (aW.Orientation() == TopAbs_INTERNAL) //cant write internal wires/edges -- continue; ++ continue; // Try to reorder edges Handle(ShapeFix_Wire) aSFW = new ShapeFix_Wire( aW, theFace, Precision::Confusion() ); aSFW->ModifyTopologyMode() = Standard_False; @@@ -324,7 -339,7 +339,7 @@@ aNPnts.Append(aPnts.First()); for (int j = 1; j <= aPnts.Size() - 1; j++) { -- if (!aPnts(j).IsEqual(aPnts(j + 1), Precision::Confusion())) ++ if (!aPnts(j).IsEqual(aPnts(j + 1), Precision::Confusion())) aNPnts.Append(aPnts(j + 1)); } @@@ -333,16 -348,20 +348,20 @@@ //External wire will be written in clockwise direction //any other wires (holes) - in anticlockwise direction for (int j = aNPnts.Size(); j >= 1; j--) -- { - x.push_back( aNPnts(j).X()); - y.push_back( aNPnts(j).Y()); ++ { + gp_XY P = gp_XY(aNPnts(j).X(), aNPnts(j).Y()); + theDocument->Transform(P, false); + x.push_back( P.X()); + y.push_back( P.Y()); } //first point is same as the last one => closed polygon - x.push_back( aNPnts.Last().X()); - y.push_back( aNPnts.Last().Y()); + gp_XY P = gp_XY(aNPnts.Last().X(), aNPnts.Last().Y()); + theDocument->Transform(P, false); + x.push_back( P.X()); + y.push_back( P.Y()); } -- ++ aSHPObj = SHPCreateObject( SHPT_POLYGON, -1, NbWires, &anPartStart[0], NULL, x.size(), &x[0], &y[0], NULL, NULL ); SHPWriteObject( theShpHandle, -1, aSHPObj ); SHPDestroyObject( aSHPObj ); @@@ -354,12 -373,13 +373,13 @@@ bool HYDROData_ShapeFile::Parse(SHPHand int aShapeType; mySHPObjects.clear(); SHPGetInfo( theHandle, NULL, &aShapeType, NULL, NULL ); - theShapeTypeOfFile = aShapeType; - bool ToRead = (theType == ShapeType_Polyline && (aShapeType == 3 || aShapeType == 13 || aShapeType == 23)) || + //theShapeTypeOfFile = aShapeType; - bool ToRead = (theType == ShapeType_Polyline && ++ bool ToRead = (theType == ShapeType_Polyline && + (aShapeType == 3 || aShapeType == 13 || aShapeType == 23 || aShapeType == 5)) || (theType == ShapeType_Polygon && aShapeType == 5); -- if (ToRead) ++ if (ToRead) { -- for (int i = 0; i < theHandle->nRecords; i++) ++ for (int i = 0; i < theHandle->nRecords; i++) mySHPObjects.push_back(SHPReadObject(theHandle, i)); return true; } @@@ -371,9 -391,9 +391,9 @@@ void HYDROData_ShapeFile::ReadSHPPolygo { if (!anObj) return; -- TopoDS_Edge E; ++ TopoDS_Edge E; int nParts = anObj->nParts; - Handle_Geom_Plane aPlaneSur = new Geom_Plane(gp_Pnt(0,0,0), gp_Dir(0,0,1)); + Handle(Geom_Plane) aPlaneSur = new Geom_Plane(gp_Pnt(0,0,0), gp_Dir(0,0,1)); BRep_Builder BB; BB.MakeFace(F); @@@ -382,7 -402,7 +402,7 @@@ TopTools_SequenceOfShape aWires; for ( int i = 0 ; i < nParts ; i++ ) -- { ++ { BRepBuilderAPI_MakeWire aBuilder; int StartIndex = anObj->panPartStart[i]; int EndIndex; @@@ -394,7 -414,7 +414,7 @@@ TopoDS_Wire W; BB.MakeWire(W); -- //First point is same as the last point ++ //First point is same as the last point int NbPnts = EndIndex - StartIndex - 1; NCollection_Array1 VPoints(0, NbPnts); int j = NbPnts; @@@ -404,7 -425,7 +425,7 @@@ VPoints.ChangeValue(j) = BRepLib_MakeVertex(P).Vertex(); j--; } -- ++ for ( int k = 0; k < VPoints.Size() - 1; k++ ) { gp_Pnt P1 = BRep_Tool::Pnt(VPoints(k)); @@@ -450,7 -471,7 +471,7 @@@ Standard_Real jXmax, jXmin, jYmax, jYmin; BBs(i).Get(iXmin, iYmin, z0, iXmax, iYmax, z1); BBs(j).Get(jXmin, jYmin, z0, jXmax, jYmax, z1); -- if (!(iXmin > jXmin && ++ if (!(iXmin > jXmin && iYmin > jYmin && iXmax < jXmax && iYmax < jYmax)) @@@ -475,20 -496,21 +496,21 @@@ BB.UpdateFace(DF, aPlaneSur, TopLoc_Location(), Precision::Confusion()); // BRepTopAdaptor_FClass2d FClass(DF, Precision::PConfusion()); -- if ( i == OutWIndex && FClass.PerformInfinitePoint() == TopAbs_IN) ++ if ( i == OutWIndex && FClass.PerformInfinitePoint() == TopAbs_IN) W.Reverse(); -- if ( i != OutWIndex && FClass.PerformInfinitePoint() == TopAbs_OUT) ++ if ( i != OutWIndex && FClass.PerformInfinitePoint() == TopAbs_OUT) W.Reverse(); // BB.Add(F, W); } -- ++ //Add surface to the face BB.UpdateFace(F, aPlaneSur, TopLoc_Location(), Precision::Confusion()); F.Closed(Standard_True); } - int HYDROData_ShapeFile::ImportPolygons(const QString theFileName, QStringList& thePolygonsList, TopTools_SequenceOfShape& theFaces, int& theShapeTypeOfFile) -int HYDROData_ShapeFile::ImportPolygons(Handle(HYDROData_Document) theDocument, const QString theFileName, ++int HYDROData_ShapeFile::ImportPolygons(Handle(HYDROData_Document) theDocument, const QString theFileName, + QStringList& thePolygonsList, TopTools_SequenceOfShape& theFaces) { Free(); int Stat = TryOpenShapeFile(theFileName); @@@ -499,7 -521,7 +521,7 @@@ return 0; for (size_t i = 0; i < mySHPObjects.size(); i++) thePolygonsList.append("polygon_" + QString::number(i + 1)); -- ++ TopoDS_Face aF; if (myHSHP->nShapeType == 5) { @@@ -507,9 -529,9 +529,9 @@@ OSD_Timer timer; timer.Start(); #endif -- for (size_t i = 0; i < mySHPObjects.size(); i++) ++ for (size_t i = 0; i < mySHPObjects.size(); i++) { - ReadSHPPolygon(mySHPObjects[i], i, aF); + ReadSHPPolygon(theDocument, mySHPObjects[i], i, aF); theFaces.Append(aF); } #ifdef OSD_TIMER @@@ -523,7 -545,7 +545,7 @@@ } void HYDROData_ShapeFile::Free() --{ ++{ for (size_t i = 0; i < mySHPObjects.size(); i++ ) free (mySHPObjects[i]); @@@ -531,17 -553,16 +553,16 @@@ if (myHSHP != NULL) { SHPClose(myHSHP); -- myHSHP = NULL; ++ myHSHP = NULL; } } --void HYDROData_ShapeFile::ReadSHPPolyXY(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName, - int theInd, NCollection_Sequence& theEntities) ++void HYDROData_ShapeFile::ReadSHPPolyXY(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName, + int theInd, NCollection_Sequence& theEntities, bool bReadAsPolyline) { - Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( theDocument->CreateObject( KIND_POLYLINEXY ) ); -- ++ int nParts = anObj->nParts; for ( int i = 0 ; i < nParts ; i++ ) { @@@ -552,39 -573,104 +573,104 @@@ else EndIndex = anObj->nVertices; - bool IsClosed = false; -- HYDROData_PolylineXY::SectionType aSectType = HYDROData_PolylineXY::SECTION_POLYLINE; - if (anObj->padfX[StartIndex] == anObj->padfX[EndIndex - 1] && - anObj->padfY[StartIndex] == anObj->padfY[EndIndex - 1] ) ++ HYDROData_PolylineXY::SectionType aSectType = HYDROData_PolylineXY::SECTION_POLYLINE; + if (!bReadAsPolyline) { - IsClosed = true; - aPolylineXY->AddSection( TCollection_AsciiString( ("poly_section_" + QString::number(i)).data()->toLatin1()), aSectType, true); + bool IsClosed = false; + if (anObj->padfX[StartIndex] == anObj->padfX[EndIndex - 1] && + anObj->padfY[StartIndex] == anObj->padfY[EndIndex - 1] ) + { + IsClosed = true; + aPolylineXY->AddSection( TCollection_AsciiString( ("poly_section_" + QString::number(i)).data()->toLatin1()), aSectType, true); + } + else + aPolylineXY->AddSection( TCollection_AsciiString( ("poly_section_" + QString::number(i)).data()->toLatin1()), aSectType, false); + + if (IsClosed) + EndIndex--; } else - aPolylineXY->AddSection( TCollection_AsciiString( ("poly_section_" + QString::number(i)).data()->toLatin1()), aSectType, false); - - if (IsClosed) + { + //polygon; contours always closed + aPolylineXY->AddSection( TCollection_AsciiString( ("poly_section_" + QString::number(i)).data()->toLatin1()), aSectType, true); EndIndex--; + } for ( int k = StartIndex; k < EndIndex ; k++ ) { - HYDROData_PolylineXY::Point aSectPoint; - aSectPoint.SetX( anObj->padfX[k] ); - aSectPoint.SetY( anObj->padfY[k] ); + HYDROData_PolylineXY::Point aSectPoint = gp_XY(anObj->padfX[k], anObj->padfY[k]); + theDocument->Transform(aSectPoint, true); aPolylineXY->AddPoint( i, aSectPoint ); } } -- ++ aPolylineXY->SetWireColor( HYDROData_PolylineXY::DefaultWireColor() ); aPolylineXY->SetName( theFileName + "_PolyXY_" + QString::number(theInd) ); -- ++ aPolylineXY->Update(); theEntities.Append(aPolylineXY); + } + + -void HYDROData_ShapeFile::ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj, - const Handle(HYDROData_PolylineXY)& aPolylineXY, ++void HYDROData_ShapeFile::ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj, ++ const Handle(HYDROData_PolylineXY)& aPolylineXY, + NCollection_Sequence& theEntities) + { + Handle(HYDROData_Polyline3D) aPolylineObj = Handle(HYDROData_Polyline3D)::DownCast( theDocument->CreateObject( KIND_POLYLINE ) ); + Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( theDocument->CreateObject( KIND_BATHYMETRY ) ); + + HYDROData_Bathymetry::AltitudePoints aAPoints; + + int nParts = anObj->nParts; + for ( int i = 0 ; i < nParts ; i++ ) + { + //bool aSectClosure = true; + int StartIndex = anObj->panPartStart[i]; + int EndIndex; + if (i != nParts - 1) + EndIndex = anObj->panPartStart[i + 1]; + else + EndIndex = anObj->nVertices; + - HYDROData_PolylineXY::SectionType aSectType = HYDROData_PolylineXY::SECTION_POLYLINE; ++ HYDROData_PolylineXY::SectionType aSectType = HYDROData_PolylineXY::SECTION_POLYLINE; + if (anObj->padfX[StartIndex] == anObj->padfX[EndIndex - 1] && + anObj->padfY[StartIndex] == anObj->padfY[EndIndex - 1] && - anObj->padfZ[StartIndex] == anObj->padfZ[EndIndex - 1]) ++ anObj->padfZ[StartIndex] == anObj->padfZ[EndIndex - 1]) + EndIndex--; + for ( int k = StartIndex ; k < EndIndex ; k++ ) + { + gp_XYZ xyz(anObj->padfX[k], anObj->padfY[k], anObj->padfZ[k]); + theDocument->Transform(xyz, true); + HYDROData_Bathymetry::AltitudePoint p; + p.X = xyz.X(); + p.Y = xyz.Y(); + p.Z = xyz.Z(); - aAPoints.push_back(p); ++ aAPoints.push_back(p); + } + } + + QString PolyXYName = aPolylineXY->GetName(); + QString aPoly3DName = PolyXYName, aBathyName = PolyXYName; + aPoly3DName.replace(PolyXYName.lastIndexOf("_PolyXY_"), 8, "_Poly3D_"); + aBathyName.replace(PolyXYName.lastIndexOf("_Bath_"), 6, "_Poly3D_"); - ++ + aBath->SetAltitudePoints(aAPoints); + aBath->SetName( aBathyName ); + + aPolylineObj->SetPolylineXY (aPolylineXY, false); + aPolylineObj->SetAltitudeObject(aBath); + + aPolylineObj->SetBorderColor( aPolylineObj->DefaultBorderColor() ); + aPolylineObj->SetName( aPoly3DName ); + + aPolylineObj->Update(); + theEntities.Append(aPolylineObj); } - void HYDROData_ShapeFile::ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName, - int theInd, NCollection_Sequence& theEntities) + /* -void HYDROData_ShapeFile::ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName, ++void HYDROData_ShapeFile::ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName, + int theInd, bool XYOnly, NCollection_Sequence& theEntities) { Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( theDocument->CreateObject( KIND_POLYLINEXY ) ); @@@ -605,7 -696,7 +696,7 @@@ EndIndex = anObj->nVertices; bool IsClosed = false; -- HYDROData_PolylineXY::SectionType aSectType = HYDROData_PolylineXY::SECTION_POLYLINE; ++ HYDROData_PolylineXY::SectionType aSectType = HYDROData_PolylineXY::SECTION_POLYLINE; if (anObj->padfX[StartIndex] == anObj->padfX[EndIndex - 1] && anObj->padfY[StartIndex] == anObj->padfY[EndIndex - 1] && anObj->padfZ[StartIndex] == anObj->padfZ[EndIndex - 1]) @@@ -615,7 -706,7 +706,7 @@@ } else aPolylineXY->AddSection( TCollection_AsciiString( ("poly_section_" + QString::number(i)).data()->toLatin1()), aSectType, false ); -- ++ if (IsClosed) EndIndex--; for ( int k = StartIndex ; k < EndIndex ; k++ ) @@@ -662,6 -778,27 +778,27 @@@ int HYDROData_ShapeFile::OpenAndParse(c if (aStat != 0) return aStat; + //SHPHandle aHSHP; + myHSHP = SHPOpen( theFileName.toLatin1().data(), "rb" ); + if (myHSHP == NULL) + return -1; + + if (!Parse(myHSHP, HYDROData_ShapeFile::ShapeType_Polyline)) + return -1; - ++ + return 1; + //sh_type = aHSHP->nShapeType; + } + -int HYDROData_ShapeFile::ImportPolylines(Handle(HYDROData_Document) theDocument, - const QString& theFileName, - NCollection_IndexedDataMap& theEntitiesToSHPObj, ++int HYDROData_ShapeFile::ImportPolylines(Handle(HYDROData_Document) theDocument, ++ const QString& theFileName, ++ NCollection_IndexedDataMap& theEntitiesToSHPObj, + ImportShapeType theShapeTypesToImport) + { + int aStat = -1; + int sh_type = myHSHP->nShapeType; + QFileInfo aFileInfo(theFileName); + QString aBaseFileName = aFileInfo.baseName(); HYDROData_Iterator anIter( theDocument ); int anInd = 0; QStringList anExistingNames; @@@ -669,35 -806,24 +806,24 @@@ for( ; anIter.More(); anIter.Next() ) anExistingNames.push_back(anIter.Current()->GetName()); - SHPHandle aHSHP; - aHSHP = SHPOpen( theFileName.toLatin1().data(), "rb" ); - - QFileInfo aFileInfo(theFileName); - QString aBaseFileName = aFileInfo.baseName(); - - if (!Parse(aHSHP, HYDROData_ShapeFile::ShapeType_Polyline, theShapeTypeOfFile)) - return 0; - if (aHSHP->nShapeType == 3 || aHSHP->nShapeType == 23) + NCollection_Sequence Ents; - if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All || - theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_Polyline) ++ if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All || ++ theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_Polyline) + && (sh_type == 3 || sh_type == 23)) { - anInd = 0; - for (;anAllowedIndexes.size() < mySHPObjects.size();) - { - if (!anExistingNames.contains(aBaseFileName + "_PolyXY_" + QString::number(anInd))) - { - anAllowedIndexes.push_back(anInd); - anInd++; - } - else - anInd++; - } - + size_t anObjsSize = mySHPObjects.size(); + GetFreeIndices(anAllowedIndexes, "_PolyXY_", anObjsSize, anExistingNames, aBaseFileName); - ++ for (size_t i = 0; i < mySHPObjects.size(); i++ ) { - ReadSHPPolyXY(theDocument, mySHPObjects[i], aBaseFileName, anAllowedIndexes[i], theEntities); + ReadSHPPolyXY(theDocument, mySHPObjects[i], aBaseFileName, anAllowedIndexes[i], Ents, false); + for (int k=1;k<=Ents.Size();k++) + theEntitiesToSHPObj.Add(Ents(k), mySHPObjects[i]); } aStat = 1; } - else if (aHSHP->nShapeType == 13) - else if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All || ++ else if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All || + theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_Polyline3D) && sh_type == 13) { anInd = 0; for (;anAllowedIndexes.size() < mySHPObjects.size();) @@@ -713,22 -839,70 +839,70 @@@ anInd++; } for (size_t i = 0; i < mySHPObjects.size(); i++ ) - ReadSHPPoly3D(theDocument, mySHPObjects[i], aBaseFileName, anAllowedIndexes[i], theEntities); + { - //ReadSHPPoly3D(theDocument, mySHPObjects[i], aBaseFileName, anAllowedIndexes[i], false, theEntities); - ReadSHPPolyXY(theDocument, mySHPObjects[i], aBaseFileName, anAllowedIndexes[i], Ents, false); //TODO check Z coord on closeness ++ //ReadSHPPoly3D(theDocument, mySHPObjects[i], aBaseFileName, anAllowedIndexes[i], false, theEntities); ++ ReadSHPPolyXY(theDocument, mySHPObjects[i], aBaseFileName, anAllowedIndexes[i], Ents, false); //TODO check Z coord on closeness + for (int k=1;k<=Ents.Size();k++) + theEntitiesToSHPObj.Add(Ents(k), mySHPObjects[i]); + } aStat = 1; } - else - else if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All || ++ else if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All || + theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_Polygon) && sh_type == 5) + { + //import polygon's contours as polylines + size_t anObjsSize = mySHPObjects.size(); + GetFreeIndices(anAllowedIndexes, "_PolyXY_", anObjsSize, anExistingNames, aBaseFileName); - ++ + for (size_t i = 0; i < mySHPObjects.size(); i++ ) + { + ReadSHPPolyXY(theDocument, mySHPObjects[i], aBaseFileName, anAllowedIndexes[i], Ents, true); + for (int k=1;k<=Ents.Size();k++) + theEntitiesToSHPObj.Add(Ents(k), mySHPObjects[i]); + } + aStat = 2; + } - else ++ else { aStat = 0; } -- - for (size_t i = 0; i < mySHPObjects.size(); i++ ) - free (mySHPObjects[i]); + - mySHPObjects.clear(); - SHPClose(aHSHP); return aStat; } + int HYDROData_ShapeFile::GetShapeType() const + { + if (myHSHP != NULL) + return myHSHP->nShapeType; - else ++ else + return -1; + } + -int HYDROData_ShapeFile::ImportPolylines3D(Handle(HYDROData_Document) theDocument, - NCollection_IndexedDataMap thePolyXYToObj, ++int HYDROData_ShapeFile::ImportPolylines3D(Handle(HYDROData_Document) theDocument, ++ NCollection_IndexedDataMap thePolyXYToObj, + NCollection_Sequence& theEntities, + ImportShapeType theShapeTypesToImport) + { + int aStat = -1; + int sh_type = myHSHP->nShapeType; - if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All || ++ if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All || + theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_Polyline3D) && sh_type == 13) + { + //for (size_t i = 0; i < mySHPObjects.size(); i++ ) + for (int i = 1; i <= thePolyXYToObj.Extent(); i++ ) + { + Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( thePolyXYToObj.FindKey(i) ); - ReadSHPPoly3D(theDocument, thePolyXYToObj(i), aPolylineXY, theEntities); ++ ReadSHPPoly3D(theDocument, thePolyXYToObj(i), aPolylineXY, theEntities); + } + aStat = 1; + } - else ++ else + aStat = 0; - ++ + return aStat; + } + + QString HYDROData_ShapeFile::GetShapeTypeName(int theType) { switch (theType) @@@ -787,7 -961,7 +961,7 @@@ int HYDROData_ShapeFile::TryOpenShapeFi if (pFileSHX == NULL) return -2; } -- ++ fclose (pFileSHP); fclose (pFileSHX); return 0; @@@ -805,7 -979,7 +979,7 @@@ bool HYDROData_ShapeFile::CheckDBFFileE { return false; } -- ++ fclose (pFileDBF); thePathToDBFFile = aDBFfile; return true; @@@ -884,9 -1058,9 +1058,9 @@@ void HYDROData_ShapeFile::DBF_GetAttrib { int nWidth, nDecimals; char chField[12]; -- ++ for( int i = 0; i < DBFGetRecordCount(myHDBF); i++ ) -- { ++ { DBFFieldType eType; DBF_AttrValue anAttr; eType = DBFGetFieldInfo( myHDBF, theIndexOfField, chField, &nWidth, &nDecimals ); @@@ -918,7 -1092,7 +1092,7 @@@ anAttr.myStrVal = QString(chAttr); break; } -- ++ case FTInteger: { int iAttr = DBFReadIntegerAttribute( myHDBF, i, theIndexOfField ); @@@ -928,7 -1102,7 +1102,7 @@@ anAttr.myIntVal = iAttr; break; } -- ++ case FTDouble: { double dAttr = DBFReadDoubleAttribute( myHDBF, i, theIndexOfField ); @@@ -960,8 -1134,8 +1134,8 @@@ bool HYDROData_ShapeFile::DBF_WriteFiel hDBF = DBFCreate( theFileName.toStdString().c_str() ); if( hDBF == NULL ) return false; -- -- if (theType != DBF_FieldType_String && theType != DBF_FieldType_Integer && theType != DBF_FieldType_Double) ++ ++ if (theType != DBF_FieldType_String && theType != DBF_FieldType_Integer && theType != DBF_FieldType_Double) { DBFClose( hDBF ); return false; //cant handle any other cases @@@ -975,13 -1149,13 +1149,13 @@@ DBFAddField (hDBF, theFieldName.toStdString().c_str(), FTString, nWidth, 0); break; } -- ++ case DBF_FieldType_Integer: { DBFAddField (hDBF, theFieldName.toStdString().c_str(), FTInteger, nWidth, 0); break; } -- ++ case DBF_FieldType_Double: { DBFAddField (hDBF, theFieldName.toStdString().c_str(), FTDouble, nWidth, 0); @@@ -991,7 -1165,7 +1165,7 @@@ break; } -- if (DBFGetFieldCount( hDBF ) != 1) ++ if (DBFGetFieldCount( hDBF ) != 1) { DBFClose( hDBF ); return false; @@@ -1031,13 -1205,13 +1205,13 @@@ stat = DBFWriteStringAttribute(hDBF, (int)i, 0, theAttrV[i].myStrVal.toStdString().c_str()); break; } -- ++ case DBF_FieldType_Integer: { stat = DBFWriteIntegerAttribute(hDBF, (int)i, 0, theAttrV[i].myIntVal); break; } -- ++ case DBF_FieldType_Double: { stat = DBFWriteDoubleAttribute(hDBF, (int)i, 0, theAttrV[i].myDoubleVal); diff --cc src/HYDROGUI/CMakeLists.txt index 5a04636a,ba89018f..d767ede7 mode 100644,100755..100755 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@@ -1,12 -1,8 +1,8 @@@ include(../../CMake/Common.cmake) + include(../../CMake/UseQT4EXT.cmake) + INCLUDE(UseQtExt) - IF (SalomeGUI_VERSION VERSION_LESS "8.0.0") - INCLUDE(UseQt4Ext) - ELSE() - INCLUDE(UseQtExt) - ENDIF() - --set(PROJECT_HEADERS ++set(PROJECT_HEADERS HYDROGUI.h HYDROGUI_AbstractDisplayer.h HYDROGUI_AISShape.h @@@ -148,15 -147,27 +147,27 @@@ HYDROGUI_LandCoverColoringOp.h HYDROGUI_SetTransparencyOp.h HYDROGUI_TransparencyDlg.h + HYDROGUI_Overview.h + HYDROGUI_PolylineStyleOp.h + HYDROGUI_PolylineStyleDlg.h + HYDROGUI_ZoneTool.h + HYDROGUI_RegenerateRegionColorsOp.h + HYDROGUI_ZoneSetColorOp.h + HYDROGUI_PolyAttrDlg.h + HYDROGUI_ShowAttrPolyOp.h + HYDROGUI_SetBoundaryTypePolygonOp.h + HYDROGUI_SetBoundaryTypePolygonDlg.h + HYDROGUI_MeasurementToolOp.h + HYDROGUI_MeasurementToolDlg.h + HYDROGUI_SIProgressIndicator.h + HYDROGUI_ZIProgressIndicator.h + HYDROGUI_ImportPolylineDlg.h + HYDROGUI_ImportSinusXDlg.h ) - IF(NOT SALOME_GUI_BUILD_WITH_QT5) - QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) - ELSE() - QT_WRAP_MOC(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) - ENDIF() + QT_WRAP_MOC(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) --set(PROJECT_SOURCES ++set(PROJECT_SOURCES HYDROGUI_AbstractDisplayer.cxx HYDROGUI_AISShape.cxx HYDROGUI_AISTrihedron.cxx @@@ -325,7 -355,7 +355,7 @@@ include_directories add_library(HYDROGUI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${PROJECT_HEADERS_MOC}) target_link_libraries(HYDROGUI HYDROData shapelib ${CAS_TKV3d} ${CAS_TKTopAlgo} ${CAS_TKBrep} ${CAS_TKBO} -- ${GUI_LightApp} ${GUI_CAM} ${GUI_suit} ${GUI_qtx} ${GUI_ObjBrowser} ${GUI_GraphicsView} ${GUI_std} ++ ${GUI_LightApp} ${GUI_CAM} ${GUI_suit} ${GUI_qtx} ${GUI_ObjBrowser} ${GUI_GraphicsView} ${GUI_std} ${GUI_Event} ${GUI_OCCViewer} ${GEOM_GEOM} ${GEOM_GEOMBase} ${GEOM_CurveCreator} ${VTK_LIBRARIES} ${SVTK} ${SalomeObject} ${SalomePrs} ) diff --cc src/HYDROGUI/HYDROGUI_DataBrowser.cxx index bfb178a4,66eec4f6..b5c0f630 --- a/src/HYDROGUI/HYDROGUI_DataBrowser.cxx +++ b/src/HYDROGUI/HYDROGUI_DataBrowser.cxx @@@ -31,7 -30,7 +31,7 @@@ #include #include #include -- ++ #define VISIBILITY_COLUMN_WIDTH 25 @@@ -153,7 -152,7 +153,7 @@@ void HYDROGUI_OBSelector::setSelection } DataObjectList objList; -- for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); ++ for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it ) { const LightApp_DataOwner* owner = dynamic_cast( (*it).operator->() ); @@@ -234,7 -233,7 +234,7 @@@ HYDROGUI_DataBrowser::HYDROGUI_DataBrow // Mantis issue 0020136: Drag&Drop in OB SUIT_ProxyModel* proxyModel = dynamic_cast(treeModel); if ( proxyModel ) { -- connect( proxyModel, ++ connect( proxyModel, SIGNAL( dropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ), SIGNAL( dropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ) ); @@@ -242,7 -241,7 +242,7 @@@ SUIT_TreeModel* aMiniModel = dynamic_cast( proxyModel->sourceModel() ); if ( aMiniModel ) { -- connect( aMiniModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ), ++ connect( aMiniModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ), SIGNAL( dataChanged() ) ); } @@@ -256,9 -255,9 +256,9 @@@ if ( aPModel ) { SUIT_TreeModel* aModel = dynamic_cast(aPModel->sourceModel()); -- //connect( proxyModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ), ++ //connect( proxyModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ), // aPModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ) ); -- //connect( proxyModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ), ++ //connect( proxyModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ), // aModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ) ); connect( proxyModel, SIGNAL( modelUpdated() ), aModel, SIGNAL( modelUpdated() ) ); } diff --cc src/HYDROGUI/HYDROGUI_DataModel.cxx index d2acbf88,fe650d28..38c283fc --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@@ -122,7 -131,7 +131,7 @@@ bool HYDROGUI_DataModel::open( const QS { res = DocError_UnknownProblem; } -- ++ if ( res != DocError_OK ) { module()->application()->putInfo( tr( "LOAD_ERROR" ) ); @@@ -152,9 -161,10 +161,10 @@@ bool HYDROGUI_DataModel::save( QStringList& theFileList ) { + DEBTRACE("save"); if( !module()->application()->activeStudy() ) return false; -- ++ LightApp_DataModel::save( theFileList ); QString aTmpDir; @@@ -166,7 -176,7 +176,7 @@@ // save module data to temporary files LightApp_Study* aStudy = dynamic_cast( module()->application()->activeStudy() ); aTmpDir = aStudy->GetTmpDir( myStudyURL.toLatin1().constData(), isMultiFile ).c_str(); -- ++ // save OCAF data to a temporary file QString aDataFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO.cbf"; QString aDataFullPath = aTmpDir + aDataFileName; @@@ -479,8 -514,79 +514,79 @@@ void HYDROGUI_DataModel::update( const // anObjectBrowser->openLevels(); //} - HYDROGUI_DataModelSync aSync( aNewRootObj ); SUIT_DataObject* aRoot = root(); + + if (aRoot) + { + std::map entry2ObjNewRoot; + SUIT_DataObjectIterator::DetourType dt = SUIT_DataObjectIterator::DepthLeft; + for ( SUIT_DataObjectIterator it( aNewRootObj, dt ); it.current(); ++it ) + { + LightApp_DataObject* aCurObjN = dynamic_cast(it.current()); + if (aCurObjN) + entry2ObjNewRoot[aCurObjN->entry().toStdString()] = it.current(); + } + + for ( SUIT_DataObjectIterator it( aRoot, dt ); it.current(); ++it ) + { + LightApp_DataObject* aCurObjO = dynamic_cast(it.current()); + if (aCurObjO && aCurObjO->childCount() > 0) + { + std::string entry = aCurObjO->entry().toStdString(); + SUIT_DataObject* newNode = entry2ObjNewRoot[entry]; + if (newNode && aCurObjO->childCount() > 0) + { + DataObjectList newchildren; + newNode->children(newchildren); - //new root - remove children ++ //new root - remove children + std::map newNode2Entries; + for ( DataObjectList::const_iterator it = newchildren.begin(); it != newchildren.end(); ++it ) + { + SUIT_DataObject* cc = *it; + LightApp_DataObject* obj = dynamic_cast(cc); + newNode2Entries[obj->entry().toStdString()] = cc; + newNode->removeChild(cc); + } + // + std::set objtemp; + + DataObjectList oldchildren; - aCurObjO->children(oldchildren); ++ aCurObjO->children(oldchildren); + for ( DataObjectList::const_iterator it = oldchildren.begin(); it != oldchildren.end(); ++it ) + { + SUIT_DataObject* old_ch = *it; + std::string entr = dynamic_cast(old_ch)->entry().toStdString(); + if (newNode2Entries.count(entr) > 0) + { - SUIT_DataObject* obj = newNode2Entries[entr]; ++ SUIT_DataObject* obj = newNode2Entries[entr]; + newNode->appendChild(obj); + objtemp.insert(obj); + } + } + // + for ( DataObjectList::const_iterator it = newchildren.begin(); it != newchildren.end(); ++it ) + { + SUIT_DataObject* ch = *it; + if (objtemp.count(ch) == 0) + newNode->appendChild(ch); + } + { //IF DEBUG + //add. check + DataObjectList newchildren2; + newNode->children(newchildren2); + std::set entries2, entries1; + for ( DataObjectList::const_iterator it = newchildren2.begin(); it != newchildren2.end(); ++it ) + entries2.insert((dynamic_cast(*it))->entry().toStdString()); + for ( DataObjectList::const_iterator it = newchildren.begin(); it != newchildren.end(); ++it ) + entries1.insert((dynamic_cast(*it))->entry().toStdString()); + assert(entries1 == entries2); + } + } + } + } + } + + HYDROGUI_DataModelSync aSync( aNewRootObj ); bool isNewDoc = aRoot==0; if( isNewDoc ) aRoot = createRootModuleObject( aStudyRoot ); @@@ -602,7 -710,7 +710,7 @@@ void HYDROGUI_DataModel::clearRedos( bool HYDROGUI_DataModel::undo() { -- try ++ try { getDocument()->Undo(); } @@@ -615,7 -723,7 +723,7 @@@ bool HYDROGUI_DataModel::redo() { -- try ++ try { getDocument()->Redo(); } @@@ -636,9 -744,9 +744,9 @@@ bool HYDROGUI_DataModel::canCopy( if( !anObject.IsNull() ) { ObjectKind aKind = anObject->GetKind(); bool isUnrecognized = aKind <= KIND_UNKNOWN || aKind > KIND_LAST; -- bool isChildObject = aKind == KIND_DUMMY_3D || ++ bool isChildObject = aKind == KIND_DUMMY_3D || aKind == KIND_ZONE || -- aKind == KIND_SHAPES_GROUP || ++ aKind == KIND_SHAPES_GROUP || aKind == KIND_SPLIT_GROUP; if ( isUnrecognized || isChildObject ) { isCanCopy = false; @@@ -646,7 -754,7 +754,7 @@@ } } } -- ++ return isCanCopy; } @@@ -794,7 -905,7 +905,7 @@@ LightApp_DataObject* HYDROGUI_DataModel const bool theIsBuildTree, const bool theIsInOperation ) { -- return buildObject( theParent, new HYDROGUI_Region( theParent, theModelObject, theParentEntry, theIsInOperation ), ++ return buildObject( theParent, new HYDROGUI_Region( theParent, theModelObject, theParentEntry, theIsInOperation ), theParentEntry, theIsBuildTree, theIsInOperation ); } @@@ -803,7 -914,7 +914,7 @@@ void HYDROGUI_DataModel::createDefaultS { // Create default Strickler table object Handle(HYDROData_StricklerTable) aStricklerTableObj = -- Handle(HYDROData_StricklerTable)::DownCast( theDocument->CreateObject(KIND_STRICKLER_TABLE) ); ++ Handle(HYDROData_StricklerTable)::DownCast( theDocument->CreateObject(KIND_STRICKLER_TABLE) ); if ( !aStricklerTableObj.IsNull() ) { SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr(); @@@ -845,7 -956,7 +956,7 @@@ void HYDROGUI_DataModel::buildObjectPar if ( !aGuiObj ) return; -- LightApp_DataObject* aPartSect = ++ LightApp_DataObject* aPartSect = createObject( aGuiObj, thePartName, aGuiObj->entry() ); HYDROData_SequenceOfObjects::Iterator anIter( theObjects ); @@@ -903,14 -1014,14 +1014,14 @@@ void HYDROGUI_DataModel::buildObjectTre Handle(HYDROData_ImmersibleZone) aZoneObj = Handle(HYDROData_ImmersibleZone)::DownCast( aDataObj ); -- LightApp_DataObject* aPolylineSect = ++ LightApp_DataObject* aPolylineSect = createObject( aGuiObj, tr( "ZONE_POLYLINE" ), aGuiObj->entry() ); Handle(HYDROData_PolylineXY) aPolyline = aZoneObj->GetPolyline(); if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() ) createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false ); -- LightApp_DataObject* aBathSect = ++ LightApp_DataObject* aBathSect = createObject( aGuiObj, tr( "ZONE_BATHYMETRY" ), aGuiObj->entry() ); Handle(HYDROData_IAltitudeObject) anAltitudeObj = aZoneObj->GetAltitudeObject(); @@@ -922,14 -1033,14 +1033,14 @@@ Handle(HYDROData_Polyline3D) aPolyline3D = Handle(HYDROData_Polyline3D)::DownCast( aDataObj ); -- LightApp_DataObject* aPolylineSect = ++ LightApp_DataObject* aPolylineSect = createObject( aGuiObj, tr( "POLYLINE3D_POLYLINE" ), aGuiObj->entry() ); Handle(HYDROData_PolylineXY) aPolylineXY = aPolyline3D->GetPolylineXY(); if ( !aPolylineXY.IsNull() && !aPolylineXY->IsRemoved() ) createObject( aPolylineSect, aPolylineXY, aGuiObj->entry(), false ); -- LightApp_DataObject* aProfileSect = ++ LightApp_DataObject* aProfileSect = createObject( aGuiObj, tr( "POLYLINE3D_PROFILE" ), aGuiObj->entry() ); Handle(HYDROData_ProfileUZ) aProfileUZ = aPolyline3D->GetProfileUZ(); @@@ -938,13 -1049,13 +1049,13 @@@ if ( !aProfileUZ.IsNull() && !aProfileUZ->IsRemoved() ) { -- Handle(HYDROData_Profile) aProfile = ++ Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( aProfileUZ->GetFatherObject() ); if ( !aProfile.IsNull() && !aProfile->IsRemoved() ) createObject( aProfileSect, aProfile, aGuiObj->entry(), false ); } -- LightApp_DataObject* aBathSect = ++ LightApp_DataObject* aBathSect = createObject( aGuiObj, tr( "POLYLINE3D_BATHYMETRY" ), aGuiObj->entry() ); Handle(HYDROData_IAltitudeObject) anAltitudeObj = aPolyline3D->GetAltitudeObject(); @@@ -956,17 -1067,17 +1067,17 @@@ Handle(HYDROData_CalculationCase) aCaseObj = Handle(HYDROData_CalculationCase)::DownCast( aDataObj ); -- LightApp_DataObject* aPolylineSect = ++ LightApp_DataObject* aPolylineSect = createObject( aGuiObj, tr( "CASE_BOUNDARY" ), aGuiObj->entry() ); Handle(HYDROData_PolylineXY) aPolyline = aCaseObj->GetBoundaryPolyline(); if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() ) createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false ); -- LightApp_DataObject* aCaseAOSect = ++ LightApp_DataObject* aCaseAOSect = createObject( aGuiObj, tr( partitionName( KIND_ARTIFICIAL_OBJECT ).toLatin1() ), aGuiObj->entry() ); -- LightApp_DataObject* aCaseNOSect = ++ LightApp_DataObject* aCaseNOSect = createObject( aGuiObj, tr( partitionName( KIND_NATURAL_OBJECT ).toLatin1() ), aGuiObj->entry() ); @@@ -988,17 -1099,23 +1099,23 @@@ aNObject = Handle(HYDROData_NaturalObject)::DownCast( anEntity ); if ( !aNObject.IsNull() ) createObject( aCaseNOSect, aNObject, aGuiObj->entry(), false ); - } + } } - LightApp_DataObject* aLandCoverMapSect = - LightApp_DataObject* aBoundaryPolygonSect = ++ LightApp_DataObject* aBoundaryPolygonSect = + createObject( aGuiObj, tr( "CASE_BOUNDARY_POLYGONS" ), aGuiObj->entry() ); + HYDROData_SequenceOfObjects aBCPolygons = aCaseObj->GetBoundaryPolygons(); + for (int i = 1; i <= aBCPolygons.Size(); i++ ) + createObject( aBoundaryPolygonSect, aBCPolygons(i), aGuiObj->entry(), false ); + - LightApp_DataObject* aLandCoverMapSect = ++ LightApp_DataObject* aLandCoverMapSect = createObject( aGuiObj, tr( "CASE_LAND_COVER_MAP" ), aGuiObj->entry() ); Handle(HYDROData_LandCoverMap) aLandCoverMap = aCaseObj->GetLandCoverMap(); if ( !aLandCoverMap.IsNull() && !aLandCoverMap->IsRemoved() ) createObject( aLandCoverMapSect, aLandCoverMap, aGuiObj->entry(), false ); -- LightApp_DataObject* aCaseRegionsSect = ++ LightApp_DataObject* aCaseRegionsSect = createObject( aGuiObj, tr( "CASE_REGIONS" ), aGuiObj->entry() ); HYDROData_SequenceOfObjects aCaseRegions = aCaseObj->GetRegions(); @@@ -1010,7 -1127,7 +1127,7 @@@ if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() ) createRegion( aCaseRegionsSect, aCaseRegion, "", true, theIsInOperation ); } -- ++ #ifdef DEB_GROUPS HYDROData_SequenceOfObjects aCalcGroups = aCaseObj->GetGeometryGroups(); buildObjectPartition( aGuiObj, aCalcGroups, tr( "OBJECT_GROUPS" ), false ); @@@ -1047,14 -1164,14 +1164,14 @@@ Handle(HYDROData_Channel) aChannelObj = Handle(HYDROData_Channel)::DownCast( aDataObj ); -- LightApp_DataObject* aGuideLineSect = ++ LightApp_DataObject* aGuideLineSect = createObject( aGuiObj, tr( "CHANNEL_GUIDE_LINE" ), aGuiObj->entry() ); Handle(HYDROData_Polyline3D) aGuideLine = aChannelObj->GetGuideLine(); if ( !aGuideLine.IsNull() && !aGuideLine->IsRemoved() ) { createObject( aGuideLineSect, aGuideLine, aGuiObj->entry(), false ); } -- LightApp_DataObject* aProfileSect = ++ LightApp_DataObject* aProfileSect = createObject( aGuiObj, tr( "CHANNEL_PROFILE" ), aGuiObj->entry() ); Handle(HYDROData_Profile) aProfile = aChannelObj->GetProfile(); if ( !aProfile.IsNull() && !aProfile->IsRemoved() ) { @@@ -1066,7 -1183,7 +1183,7 @@@ Handle(HYDROData_Stream) aStreamObj = Handle(HYDROData_Stream)::DownCast( aDataObj ); -- LightApp_DataObject* aHydraulicAxisSect = ++ LightApp_DataObject* aHydraulicAxisSect = createObject( aGuiObj, tr( "STREAM_HYDRAULIC_AXIS" ), aGuiObj->entry() ); Handle(HYDROData_PolylineXY) aHydraulicAxis = aStreamObj->GetHydraulicAxis(); if ( !aHydraulicAxis.IsNull() && !aHydraulicAxis->IsRemoved() ) { @@@ -1086,15 -1203,26 +1203,26 @@@ Handle(HYDROData_LandCoverMap) aLandCoverMapObj = Handle(HYDROData_LandCoverMap)::DownCast( aDataObj ); -- /*TODO: reference objects of the land cover map ++ /*TODO: reference objects of the land cover map HYDROData_SequenceOfObjects aPolylines = aLandCoverMapObj->GetPolylines(); buildObjectPartition( aGuiObj, aPolylines, tr( "LAND_COVER_POLYLINES" ), true );*/ } - + else if ( anObjectKind == KIND_BC_POLYGON ) + { + Handle(HYDROData_BCPolygon) aBCObj = + Handle(HYDROData_BCPolygon)::DownCast( aDataObj ); + - LightApp_DataObject* aPolylineSect = ++ LightApp_DataObject* aPolylineSect = + createObject( aGuiObj, tr( "BC_POLYGON_POLYLINE" ), aGuiObj->entry() ); + + Handle(HYDROData_PolylineXY) aPolyline = aBCObj->GetPolyline(); + if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() ) + createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false ); + } HYDROGUI_Module* aModule = dynamic_cast( module() ); if( aModule ) aModule->enableLCMActions(); -- ++ } void HYDROGUI_DataModel::buildCaseTree( SUIT_DataObject* theParent, Handle(HYDROData_CalculationCase) theCase ) @@@ -1148,7 -1276,7 +1276,7 @@@ void HYDROGUI_DataModel::updateObjectTr aParentEntry = aParent->entry(); } buildObjectTree( aParent, aGuiObj, aParentEntry, aGuiObj->isInOperation() ); -- } ++ } else { // workaround for the bug in SalomeApp_Study::findObjectByEntry - it can't find LightApp_DataObjects @@@ -1183,7 -1311,7 +1311,7 @@@ SUIT_DataObject* HYDROGUI_DataModel::fi return NULL; // not found } --bool HYDROGUI_DataModel::createNewRegion( Handle(HYDROData_CalculationCase) theCase, ++bool HYDROGUI_DataModel::createNewRegion( Handle(HYDROData_CalculationCase) theCase, const QList& theZonesList ) { bool isOk = !theCase.IsNull(); @@@ -1219,7 -1347,7 +1347,7 @@@ bool HYDROGUI_DataModel::rename( Handle if ( theName.isEmpty() ) return false; -- try ++ try { getDocument()->StartOperation(); theEntity->SetName( theName ); diff --cc src/HYDROGUI/HYDROGUI_DataObject.cxx index 890e29a9,f68c26e6..f0cbd8b4 --- a/src/HYDROGUI/HYDROGUI_DataObject.cxx +++ b/src/HYDROGUI/HYDROGUI_DataObject.cxx @@@ -32,8 -36,9 +36,9 @@@ #include #include + #include --HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent, ++HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent, Handle(HYDROData_Entity) theData, const QString& theParentEntry, const bool theIsInOperation ) @@@ -142,6 -149,15 +149,15 @@@ QPixmap HYDROGUI_DataObject::icon( cons { QString anIcon; Handle(HYDROData_Entity) aDataObject = modelObject(); + Handle(HYDROData_Object) anObject; + Handle(HYDROData_ArtificialObject) anAObject = Handle( HYDROData_ArtificialObject )::DownCast(aDataObject); + Handle(HYDROData_NaturalObject) aNObject = Handle( HYDROData_NaturalObject )::DownCast(aDataObject); - ++ + if (!anAObject.IsNull()) + anObject = anAObject; + if (!aNObject.IsNull()) + anObject = aNObject; + if( aDataObject.IsNull() ) { anIcon = QObject::tr( "HYDRO_TYPE0_ICO" ); // KIND_UNKNOWN @@@ -151,17 -167,53 +167,53 @@@ QString aNeedUpdate( aDataObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) ? "M_" : "" ); int anObjectKind = (int)aDataObject->GetKind(); + bool IsUnsImmZone = false; if ( anObjectKind == KIND_DUMMY_3D ) { -- Handle(HYDROData_DummyObject3D) anObject3D = ++ Handle(HYDROData_DummyObject3D) anObject3D = Handle(HYDROData_DummyObject3D)::DownCast( aDataObject ); -- ++ Handle(HYDROData_Object) aFatherObj = anObject3D->GetObject(); if ( !aFatherObj.IsNull() ) anObjectKind = aFatherObj->GetKind(); + anIcon = QObject::tr( QString("HYDRO_%1TYPE%2_ICO").arg( aNeedUpdate ).arg( anObjectKind ).toLatin1() ); } - - anIcon = QObject::tr( QString("HYDRO_%1TYPE%2_ICO").arg( aNeedUpdate ).arg( anObjectKind ).toLatin1() ); + else if ( !anObject.IsNull() ) + { + bool IsSubm = anObject->IsSubmersible(); + QString anIcon1 = QObject::tr( QString("HYDRO_%1TYPE%2_ICO").arg( aNeedUpdate ).arg( anObjectKind ).toLatin1() ); + QString anIcon2; - if (IsSubm) ++ if (IsSubm) + anIcon2 = QObject::tr( QString("HYDRO_SUBMERSIBLE16_ICO").toLatin1()); + else + anIcon2 = QObject::tr( QString("HYDRO_UNSUBMERSIBLE16_ICO").toLatin1()); + + QPixmap qpm1 = aResMgr->loadPixmap( "HYDRO", anIcon1 ); + QPixmap qpm2 = aResMgr->loadPixmap( "HYDRO", anIcon2 ); + QPixmap qpmD(32,16); + qpmD.fill(QColor(0,0,0)); + QPainter painter; + painter.begin(&qpmD); + painter.drawPixmap(0, 0, qpm1); + painter.drawPixmap(16, 0, qpm2); + painter.end(); + return qpmD; + } + else if (anObjectKind == KIND_BC_POLYGON) + { + Handle(HYDROData_BCPolygon) aBCObj = Handle(HYDROData_BCPolygon)::DownCast( aDataObject ); + int aBT = aBCObj->GetBoundaryType(); + if (aBT == 1) + anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE1_ICO").toLatin1()); + else if (aBT == 2) + anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE2_ICO").toLatin1()); + else if (aBT == 3) + anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE3_ICO").toLatin1()); + else + anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE_UNDEF_ICO").toLatin1()); + } + else + anIcon = QObject::tr( QString("HYDRO_%1TYPE%2_ICO").arg( aNeedUpdate ).arg( anObjectKind ).toLatin1() ); } return aResMgr->loadPixmap( "HYDRO", anIcon ); @@@ -300,7 -354,7 +354,7 @@@ HYDROGUI_DropTargetObject::HYDROGUI_Dro const QString& theName, const QString& theParentEntry, const bool theIsInOperation ) --: HYDROGUI_NamedObject( theParent, theName, theParentEntry, theIsInOperation ), ++: HYDROGUI_NamedObject( theParent, theName, theParentEntry, theIsInOperation ), CAM_DataObject( theParent ) { } diff --cc src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx index 2d2e8bd6,3ad5e1dc..9efd47ae --- a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx @@@ -73,7 -72,7 +73,7 @@@ QWizardPage* HYDROGUI_ImportLandCoverMa aFileNameLayout->addWidget( aFileNameLabel ); aFileNameLayout->addWidget( myFileName ); aFileNameLayout->addWidget( aBrowseBtn ); -- ++ myObjectNameGroup = new QGroupBox( tr( "LANDCOVERMAP_NAME" ) ); QLabel* aLandcoverNameLabel = new QLabel( tr( "NAME" ), myObjectNameGroup ); @@@ -111,7 -110,7 +111,7 @@@ // Conections connect( myPolygonsListWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( onItemSelectionChanged() ) ); -- connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); ++ connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); connect( myAttrCheckBox, SIGNAL(clicked(bool)), this, SLOT(onAttrCBChecked(bool))); return aPage; @@@ -123,7 -122,7 +123,7 @@@ QWizardPage* HYDROGUI_ImportLandCoverMa myAvAttrLabel = new QLabel(); myAvAttrLabel->setText(tr("AV_ATTRS")); -- ++ myDBFAttrListWidget = new QListWidget( ); myDBFAttrListWidget->setSelectionMode( QListWidget::SingleSelection ); myDBFAttrListWidget->setEditTriggers( QListWidget::NoEditTriggers ); @@@ -147,7 -146,7 +147,7 @@@ QWizardPage* HYDROGUI_ImportLandCoverMa QFrame* aFrame = new QFrame( aPage ); myCorrLabel = new QLabel(); myCorrLabel->setText(tr ("CORR")); -- ++ myCorrTableWidget = new QTableWidget(); // Layout @@@ -198,7 -197,7 +198,7 @@@ void HYDROGUI_ImportLandCoverMapDlg::se } void HYDROGUI_ImportLandCoverMapDlg::onItemSelectionChanged() --{ ++{ int aCurIndex = getCurrentWizardIndex(); if (aCurIndex == 0 && getViewerState()) emit selectionChanged( getSelectedPolygonNames() ); @@@ -252,13 -251,13 +252,13 @@@ QString HYDROGUI_ImportLandCoverMapDlg: } --void HYDROGUI_ImportLandCoverMapDlg::FillCorrespondenceTable(const QStringList& theFirstColumn, ++void HYDROGUI_ImportLandCoverMapDlg::FillCorrespondenceTable(const QStringList& theFirstColumn, const QStringList& theSecondColumn, const QVector theDefCBIndices, const QVector theColors) { int aFCSize = theFirstColumn.size(); // == theDefCBIndices.size() ! -- int aSCSize = theSecondColumn.size(); ++ int aSCSize = theSecondColumn.size(); myStrColors = theColors; diff --cc src/HYDROGUI/HYDROGUI_ListModel.cxx index 9355bbd4,a452d2b3..280814ff --- a/src/HYDROGUI/HYDROGUI_ListModel.cxx +++ b/src/HYDROGUI/HYDROGUI_ListModel.cxx @@@ -87,7 -110,7 +110,7 @@@ QVariant HYDROGUI_ListModel::data( cons case Qt::DecorationRole: { -- if( myIsDecorationEnabled && ++ if( myIsDecorationEnabled && aColumn==0 && aRow >=0 && aRow < myObjects.count() ) { bool isVisible = isObjectVisible( aRow ); if( isVisible ) @@@ -293,7 -325,7 +326,7 @@@ Qt::DropActions HYDROGUI_ListModel::sup @param theIsToSort defines if the list of ids should be sorted in ascending order @return the list of ids */ --QList HYDROGUI_ListModel::getIds( const QModelIndexList& theIndexes, ++QList HYDROGUI_ListModel::getIds( const QModelIndexList& theIndexes, bool theIsToSort ) const { QList anIds; @@@ -379,7 -411,7 +412,7 @@@ bool HYDROGUI_ListModel::move( const in aRes = true; } } -- ++ return aRes; } @@@ -391,7 -423,7 +424,7 @@@ @param theDropItem the drop item id ( used for drag and drop obly ) @return true in case of success */ --bool HYDROGUI_ListModel::move( const QList& theItems, const OpType theType, ++bool HYDROGUI_ListModel::move( const QList& theItems, const OpType theType, bool theIsVisibleOnly, const int theDropItem ) { bool aRes = true; @@@ -456,7 -488,7 +489,7 @@@ default: aRes = false; } -- ++ return aRes; } @@@ -466,12 -498,12 +499,12 @@@ @param theDropItem the drop item id @return true if drag and drop allowed */ --bool HYDROGUI_ListModel::isDragAndDropAllowed( const QList& theItems, ++bool HYDROGUI_ListModel::isDragAndDropAllowed( const QList& theItems, const int theDropItem ) const { bool isAllowed = false; -- if ( theDropItem >= 0 && ++ if ( theDropItem >= 0 && // TODO: to disable drop between items use: theDropItem < myObjects.count() theDropItem <= myObjects.count() && !theItems.empty() && theItems.count() < myObjects.count() && diff --cc src/HYDROGUI/HYDROGUI_ListModel.h index 920222e9,f8246036..89b43870 --- a/src/HYDROGUI/HYDROGUI_ListModel.h +++ b/src/HYDROGUI/HYDROGUI_ListModel.h @@@ -56,8 -58,8 +58,9 @@@ public virtual QStringList mimeTypes() const; virtual bool dropMimeData( const QMimeData* theData, Qt::DropAction theAction, int theRow, int theColumn, const QModelIndex& theParent ); + virtual Qt::DropActions supportedDragActions() const; virtual Qt::DropActions supportedDropActions() const; + virtual Qt::DropActions supportedDragActions() const; QList getIds( const QModelIndexList& theIndexes, bool theIsToSort = true ) const; diff --cc src/HYDROGUI/HYDROGUI_PriorityWidget.cxx index 59ef21ae,2f84a822..825cbc91 --- a/src/HYDROGUI/HYDROGUI_PriorityWidget.cxx +++ b/src/HYDROGUI/HYDROGUI_PriorityWidget.cxx @@@ -41,7 -42,7 +41,7 @@@ HYDROGUI_PriorityWidget::Delegate::Dele /** */ --QWidget* HYDROGUI_PriorityWidget::Delegate::createEditor( ++QWidget* HYDROGUI_PriorityWidget::Delegate::createEditor( QWidget* theParent, const QStyleOptionViewItem& theOption, const QModelIndex& theIndex ) const { @@@ -56,7 -57,7 +56,7 @@@ QStringList anObjNames = theIndex.data( Qt::UserRole ).toStringList(); aComboBox->addItems( anObjNames ); } -- ++ connect( aComboBox, SIGNAL( activated( int ) ), this, SLOT( finishEditing() ) ); return aComboBox; @@@ -64,7 -65,7 +64,7 @@@ /** */ --void HYDROGUI_PriorityWidget::Delegate::setEditorData( ++void HYDROGUI_PriorityWidget::Delegate::setEditorData( QWidget* theEditor, const QModelIndex& theIndex ) const { QComboBox* aComboBox = dynamic_cast( theEditor ); @@@ -88,7 -89,7 +88,7 @@@ /** */ --void HYDROGUI_PriorityWidget::Delegate::setModelData( ++void HYDROGUI_PriorityWidget::Delegate::setModelData( QWidget* theEditor, QAbstractItemModel* theModel, const QModelIndex& theIndex) const { QComboBox* aComboBox = dynamic_cast( theEditor ); @@@ -139,27 -140,27 +139,27 @@@ HYDROGUI_PriorityWidget::HYDROGUI_Prior myRemove->setText( tr( "REMOVE" ) ); myClear = new QToolButton; myClear->setText( tr( "CLEAR_ALL" ) ); -- ++ // Table view myTable = new QTableView( this ); myTable->setItemDelegate( new Delegate( this ) ); myTable->setEditTriggers( QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed ); -- ++ // Set the custom model HYDROGUI_PriorityTableModel* aModel = new HYDROGUI_PriorityTableModel(); myTable->setModel( aModel ); // Set resize mode myTable->horizontalHeader()->setStretchLastSection( false); - HYDROGUI_Tool::setResizeMode( myTable->horizontalHeader(), 0, QHeaderView::Stretch ); - HYDROGUI_Tool::setResizeMode( myTable->horizontalHeader(), 1, QHeaderView::ResizeToContents ); - HYDROGUI_Tool::setResizeMode( myTable->horizontalHeader(), 2, QHeaderView::Stretch ); - HYDROGUI_Tool::setResizeMode( myTable->horizontalHeader(), 3, QHeaderView::ResizeToContents ); + myTable->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::Stretch ); + myTable->horizontalHeader()->setSectionResizeMode( 1, QHeaderView::ResizeToContents ); + myTable->horizontalHeader()->setSectionResizeMode( 2, QHeaderView::Stretch ); + myTable->horizontalHeader()->setSectionResizeMode( 3, QHeaderView::ResizeToContents ); + + myTable->verticalHeader()->setSectionResizeMode( QHeaderView::ResizeToContents ); - + - HYDROGUI_Tool::setResizeMode( myTable->verticalHeader(), QHeaderView::ResizeToContents ); - // Layout // buttons QHBoxLayout* aButtonsLayout = new QHBoxLayout(); @@@ -171,7 -172,7 +171,7 @@@ // main aMainLayout->addLayout( aButtonsLayout ); aMainLayout->addWidget( myTable ); -- ++ // Update controls updateControls(); @@@ -180,7 -181,7 +180,7 @@@ connect( myRemove, SIGNAL( clicked() ), this, SLOT( onRemoveRule() ) ); connect( myClear, SIGNAL( clicked() ), this, SLOT( onClearRules() ) ); -- connect ( myTable->selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), ++ connect ( myTable->selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), this, SLOT( onSelectionChanged() ) ); connect( aModel, SIGNAL( showError( const QString& ) ), this, SLOT( onShowError( const QString& ) ) ); @@@ -199,7 -200,7 +199,7 @@@ HYDROGUI_PriorityWidget::~HYDROGUI_Prio */ void HYDROGUI_PriorityWidget::onAddRule() { -- HYDROGUI_PriorityTableModel* aModel = ++ HYDROGUI_PriorityTableModel* aModel = dynamic_cast( myTable->model() ); if ( aModel ) { if (aModel->createNewRule()) { @@@ -214,7 -215,7 +214,7 @@@ */ void HYDROGUI_PriorityWidget::onRemoveRule() { -- HYDROGUI_PriorityTableModel* aModel = ++ HYDROGUI_PriorityTableModel* aModel = dynamic_cast( myTable->model() ); if (aModel) { @@@ -226,7 -227,7 +226,7 @@@ if ( !aRows.contains( aRowIndex ) ) aRows << aRowIndex; } -- ++ if ( aModel->removeRows( aRows ) ) { updateControls(); emit ruleChanged(); @@@ -239,7 -240,7 +239,7 @@@ */ void HYDROGUI_PriorityWidget::onClearRules() { -- HYDROGUI_PriorityTableModel* aModel = ++ HYDROGUI_PriorityTableModel* aModel = dynamic_cast( myTable->model() ); if ( aModel && aModel->removeAll() ) { updateControls(); @@@ -253,7 -254,7 +253,7 @@@ */ void HYDROGUI_PriorityWidget::setObjects( const QList& theObjects ) { -- HYDROGUI_PriorityTableModel* aModel = ++ HYDROGUI_PriorityTableModel* aModel = dynamic_cast( myTable->model() ); if( aModel ) { aModel->setObjects( theObjects ); @@@ -269,7 -270,7 +269,7 @@@ HYDROData_ListOfRules HYDROGUI_Priority { HYDROData_ListOfRules aRules; -- HYDROGUI_PriorityTableModel* aModel = ++ HYDROGUI_PriorityTableModel* aModel = dynamic_cast( myTable->model() ); if( aModel ) { aRules = aModel->getRules(); @@@ -284,7 -285,7 +284,7 @@@ */ void HYDROGUI_PriorityWidget::setRules( const HYDROData_ListOfRules& theRules ) { -- HYDROGUI_PriorityTableModel* aModel = ++ HYDROGUI_PriorityTableModel* aModel = dynamic_cast( myTable->model() ); if( aModel ) { aModel->setRules( theRules ); @@@ -315,7 -316,7 +315,7 @@@ void HYDROGUI_PriorityWidget::onSelecti */ void HYDROGUI_PriorityWidget::updateControls() { -- HYDROGUI_PriorityTableModel* aModel = ++ HYDROGUI_PriorityTableModel* aModel = dynamic_cast( myTable->model() ); if( aModel ) { myAdd->setEnabled( aModel->canCreateNewRule() ); @@@ -337,7 -338,7 +337,7 @@@ void HYDROGUI_PriorityWidget::onShowErr */ void HYDROGUI_PriorityWidget::undoLastChange() { -- HYDROGUI_PriorityTableModel* aModel = ++ HYDROGUI_PriorityTableModel* aModel = dynamic_cast( myTable->model() ); if ( aModel ) aModel->undoLastChange(); diff --cc src/HYDROGUI/HYDROGUI_StricklerTableDlg.cxx index 16b60704,b09540c4..6eadf8c5 --- a/src/HYDROGUI/HYDROGUI_StricklerTableDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_StricklerTableDlg.cxx @@@ -201,8 -206,8 +206,8 @@@ HYDROGUI_StricklerTableDlg::HYDROGUI_St connect( myAddBtn, SIGNAL( clicked() ), this, SLOT( onAddCoefficient() ) ); connect( myRemoveBtn, SIGNAL( clicked() ), this, SLOT( onRemoveCoefficient() ) ); connect( myClearBtn, SIGNAL( clicked() ), this, SLOT( onClearCoefficients() ) ); -- connect( myTable->selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), -- this, SLOT( onSelectionChanged() ) ); ++ connect( myTable->selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), ++ this, SLOT( onSelectionChanged() ) ); setMinimumWidth( 450 ); @@@ -307,7 -312,7 +312,7 @@@ void HYDROGUI_StricklerTableDlg::setGui myTable->insertRow( aRow ); // "Type" column -- QTableWidgetItem* aTypeItem = new QTableWidgetItem( aType ); ++ QTableWidgetItem* aTypeItem = new QTableWidgetItem( aType ); myTable->setItem( aRow, 0, aTypeItem ); // "Coefficient" column @@@ -331,7 -336,7 +336,7 @@@ void HYDROGUI_StricklerTableDlg::updateControls() { bool isTableNotEmpty = myTable->rowCount() > 0; -- myClearBtn->setEnabled( isTableNotEmpty ); ++ myClearBtn->setEnabled( isTableNotEmpty ); onSelectionChanged(); } @@@ -380,7 -385,7 +385,7 @@@ void HYDROGUI_StricklerTableDlg::onAddC // Set default type (=> generate unique type name) and coefficient //... -- updateControls(); ++ updateControls(); } /** diff --cc src/HYDROGUI/HYDROGUI_Tool.h index 1c658794,90756880..2fe2d9a3 --- a/src/HYDROGUI/HYDROGUI_Tool.h +++ b/src/HYDROGUI/HYDROGUI_Tool.h @@@ -47,12 -46,12 +47,12 @@@ namespace HYDROGUI_Too QDockWidget* WindowDock( QWidget* wid ); - QStringList FindExistingObjectsNames( const Handle_HYDROData_Document& theDoc, - QStringList FindExistingObjectsNames( const Handle(HYDROData_Document)& theDoc, -- const ObjectKind theObjectKind, ++ QStringList FindExistingObjectsNames( const Handle(HYDROData_Document)& theDoc, ++ const ObjectKind theObjectKind, bool isCheckValidProfile = false ); QString GetCoordinateString( const double theNumber, bool isInLocale ); -- - Handle_Image_PixMap Pixmap( const QImage& theImage ); ++ + Handle(Image_PixMap) Pixmap( const QImage& theImage ); void GetObjectReferences( const Handle(HYDROData_Entity)& theObj, HYDROData_SequenceOfObjects& theRefObjects, diff --cc src/HYDROPy/HYDROData_Entity.sip index 1986b5c1,d32d61b7..0833eb5e --- a/src/HYDROPy/HYDROData_Entity.sip +++ b/src/HYDROPy/HYDROData_Entity.sip @@@ -127,7 -128,7 +128,7 @@@ class HYDROData_Entit case KIND_SHAPES_GROUP: sipClass = sipClass_HYDROData_ShapesGroup; break; -- ++ case KIND_SPLIT_GROUP: sipClass = sipClass_HYDROData_SplitShapesGroup; break; @@@ -206,7 -211,7 +211,7 @@@ public */ virtual bool CanBeUpdated() const; -- ++ /** * Checks is object exists in the data structure. * \returns true is object is not exists in the data model @@@ -222,15 -227,15 +227,15 @@@ * Returns father object. For object created under root document label * this method always return NULL object. */ - HYDROData_Entity GetFatherObject() const [Handle_HYDROData_Entity ()]; + HYDROData_Entity GetFatherObject() const [opencascade::handle ()]; %MethodCode Handle(HYDROData_Entity) aFather; -- ++ Py_BEGIN_ALLOW_THREADS -- aFather = sipSelfWasArg ? sipCpp->HYDROData_Entity::GetFatherObject() : ++ aFather = sipSelfWasArg ? sipCpp->HYDROData_Entity::GetFatherObject() : sipCpp->GetFatherObject(); Py_END_ALLOW_THREADS -- ++ sipRes = createPointer( aFather ); %End @@@ -256,11 -261,12 +261,12 @@@ */ virtual void RemoveZLevel(); + void SetColor( const QColor& theColor, const int theTag = 0 ); - + protected: /** -- * Creates new object in the internal data structure. Use higher level objects ++ * Creates new object in the internal data structure. Use higher level objects * to create objects with real content. */ HYDROData_Entity( Geometry ); @@@ -269,5 -275,5 +275,5 @@@ * Destructs properties of the object and object itself, removes it from the document. */ virtual ~HYDROData_Entity(); -- ++ }; diff --cc src/HYDRO_tests/CMakeLists.txt index 61cc4e7f,10b6c87f..a9dfb54a --- a/src/HYDRO_tests/CMakeLists.txt +++ b/src/HYDRO_tests/CMakeLists.txt @@@ -18,7 -21,16 +21,16 @@@ set(PROJECT_HEADER test_HYDROGUI_ListModel.h test_HYDROGUI_Shape.h test_HYDROGUI_LandCoverMapDlg.h + test_HYDROData_CalcCase.h + test_HYDROData_Stream.h + test_HYDROData_Tool.h + test_HYDROGUI_BathymetryPrs.h - ++ test_Dependencies.h + test_HYDROData_DTM.h + test_HYDROData_BoundaryPolygons.h + test_GraphicsView.h + test_Overview.h TestShape.h TestViewer.h @@@ -43,8 -57,15 +57,15 @@@ set(PROJECT_SOURCE test_HYDROGUI_ListModel.cxx test_HYDROGUI_Shape.cxx test_HYDROGUI_LandCoverMapDlg.cxx + test_HYDROData_CalcCase.cxx + test_HYDROData_Stream.cxx test_Dependencies.cxx + test_HYDROData_Tool.cxx + test_GraphicsView.cxx + test_Overview.cxx + test_HYDROGUI_ProfilesDlg.cxx + test_HYDROGUI_BathymetryPrs.cxx - + TestShape.cxx TestViewer.cxx TestLib_Listener.cxx diff --cc src/HYDRO_tests/ExternalFiles.cmake index 97d01b8e,86c5ab5d..6a5b7e0b --- a/src/HYDRO_tests/ExternalFiles.cmake +++ b/src/HYDRO_tests/ExternalFiles.cmake @@@ -69,15 -79,27 +79,27 @@@ set( EXTERNAL_FILE ../HYDROGUI/HYDROGUI_StricklerTableDlg.cxx ../HYDROGUI/HYDROGUI_LineEditDoubleValidator.cxx ../HYDROGUI/HYDROGUI_Tool.cxx + ../HYDROGUI/HYDROGUI_StreamDlg.cxx + ../HYDROGUI/HYDROGUI_ListSelector.cxx + ../HYDROGUI/HYDROGUI_OrderedListWidget.cxx + ../HYDROGUI/HYDROGUI_Overview.cxx + ../HYDROGUI/HYDROGUI_ZoneTool.cxx + ../HYDROGUI/HYDROGUI_ProfileDlg.cxx + ../HYDROGUI/HYDROGUI_ViewerDlg.cxx + ../HYDROGUI/HYDROGUI_AISTrihedron.cxx + ../HYDROGUI/HYDROGUI_CurveCreatorProfile.cxx ) --set( MOC_HEADERS ++set( MOC_HEADERS ../HYDROGUI/HYDROGUI_InputPanel.h ../HYDROGUI/HYDROGUI_StricklerTableDlg.h + ../HYDROGUI/HYDROGUI_StreamDlg.h + ../HYDROGUI/HYDROGUI_ListSelector.h + ../HYDROGUI/HYDROGUI_OrderedListWidget.h + ../HYDROGUI/HYDROGUI_Overview.h + ../HYDROGUI/HYDROGUI_ZoneTool.h + ../HYDROGUI/HYDROGUI_ProfileDlg.h + ../HYDROGUI/HYDROGUI_ViewerDlg.h ) - IF (SalomeGUI_VERSION VERSION_LESS "8.0.0") - QT4_WRAP_CPP( PROJECT_MOC_HEADERS ${MOC_HEADERS} ) - ELSE() - QT_WRAP_MOC( PROJECT_MOC_HEADERS ${MOC_HEADERS} ) - ENDIF() + #QT5_WRAP_MOC( PROJECT_MOC_HEADERS ${MOC_HEADERS} ) diff --cc src/HYDRO_tests/test_HYDROData_Main.cxx index 90a5559e,15ea61a6..4b04a8fb --- a/src/HYDRO_tests/test_HYDROData_Main.cxx +++ b/src/HYDRO_tests/test_HYDROData_Main.cxx @@@ -56,21 -68,25 +68,25 @@@ int main( int argc, char* argv[] // Create the event manager and test controller CppUnit::TestResult controller; - // Add a listener that colllects test result + // Add a listener that collects test result CppUnit::TestResultCollector result; -- controller.addListener( &result ); ++ controller.addListener( &result ); // Add a listener that print dots as test run. TestLib_Listener progress; -- controller.addListener( &progress ); ++ controller.addListener( &progress ); -- CppUnit::TestFactoryRegistry& registry = ++ CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry(); // Add the top suite to the test runner TestLib_Runner runner; + #ifdef WIN32 QString aPath = qgetenv( "HYDRO_SRC_DIR" ) + "/src/tests.cfg"; + #else + QString aPath = qgetenv( "HYDRO_ROOT_DIR" ) + "/tests.cfg"; + #endif runner.Load( aPath.toStdString() ); -- runner.addTest( registry.makeTest() ); ++ runner.addTest( registry.makeTest() ); try { std::cout << "Running tests " << testPath << "..." << std::endl; @@@ -84,7 -100,7 +100,7 @@@ } catch ( std::invalid_argument &e ) // Test path not resolved { -- std::cerr << std::endl ++ std::cerr << std::endl << "ERROR: " << e.what() << std::endl; return 0;