From: isn Date: Thu, 11 Oct 2018 13:14:04 +0000 (+0300) Subject: lots 3,8 - corrections X-Git-Tag: HYDRO_V2_0_0~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8c43e399105149105b2a3e3c22c427ec24145e07;p=modules%2Fhydro.git lots 3,8 - corrections Signed-off-by: isn --- diff --git a/src/HYDROData/HYDROData_IPolyline.cxx b/src/HYDROData/HYDROData_IPolyline.cxx index 3bcb60dc..1ec97913 100644 --- a/src/HYDROData/HYDROData_IPolyline.cxx +++ b/src/HYDROData/HYDROData_IPolyline.cxx @@ -168,42 +168,49 @@ void HYDROData_IPolyline::removePointsLists( const int theSectionIndex ) const } } -void HYDROData_IPolyline::getSectionColor( const int theSectionIndex, - QColor& theColor, - const bool theIsCreate ) const +bool HYDROData_IPolyline::getSectionColor( const int theSectionIndex, QColor &theColor) const { - TDF_Label aLabel = myLab.FindChild( DataTag_SectionColors, theIsCreate ); + TDF_Label aLabel = myLab.FindChild( DataTag_SectionColors, false ); if ( aLabel.IsNull() ) - return; + return false; - TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, theIsCreate ); + TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, false ); if ( aSectLabel.IsNull() ) - return; + return false; Handle(TDataStd_IntegerArray) aColorArray; - if (theIsCreate) - { - if ( !aSectLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) ) - aColorArray = TDataStd_IntegerArray::Set( aSectLabel, 1, 4 ); - aColorArray->SetValue( 1, theColor.red() ); - aColorArray->SetValue( 2, theColor.green() ); - aColorArray->SetValue( 3, theColor.blue() ); - aColorArray->SetValue( 4, theColor.alpha() ); - } - else + if ( aSectLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) ) { - Handle(TDataStd_IntegerArray) aColorArray; - if ( aSectLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) ) - { - theColor.setRed( aColorArray->Value( 1 ) ); - theColor.setGreen( aColorArray->Value( 2 ) ); - theColor.setBlue( aColorArray->Value( 3 ) ); - theColor.setAlpha( aColorArray->Value( 4 ) ); - } + theColor.setRed( aColorArray->Value( 1 ) ); + theColor.setGreen( aColorArray->Value( 2 ) ); + theColor.setBlue( aColorArray->Value( 3 ) ); + theColor.setAlpha( aColorArray->Value( 4 ) ); } } +void HYDROData_IPolyline::setSectionColor( const int theSectionIndex, + const QColor& theColor ) const +{ + TDF_Label aLabel = myLab.FindChild( DataTag_SectionColors, true ); + if ( aLabel.IsNull() ) + return; + + TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, true ); + if ( aSectLabel.IsNull() ) + return; + + Handle(TDataStd_IntegerArray) aColorArray; + + if ( !aSectLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) ) + aColorArray = TDataStd_IntegerArray::Set( aSectLabel, 1, 4 ); + + aColorArray->SetValue( 1, theColor.red() ); + aColorArray->SetValue( 2, theColor.green() ); + aColorArray->SetValue( 3, theColor.blue() ); + aColorArray->SetValue( 4, theColor.alpha() ); +} + void HYDROData_IPolyline::removeSectionColor( const int theSectionIndex ) const { TDF_Label aLabel = myLab.FindChild( DataTag_SectionColors, false ); diff --git a/src/HYDROData/HYDROData_IPolyline.h b/src/HYDROData/HYDROData_IPolyline.h index cd306e97..c8916d4c 100644 --- a/src/HYDROData/HYDROData_IPolyline.h +++ b/src/HYDROData/HYDROData_IPolyline.h @@ -191,9 +191,10 @@ public: HYDRODATA_EXPORT TopoDS_Shape GetShape() const; HYDRODATA_EXPORT void SetShape( const TopoDS_Shape& theShape ); - HYDRODATA_EXPORT void getSectionColor( const int theSectionIndex, - QColor& theColor, - const bool theIsCreate = true ) const; + HYDRODATA_EXPORT void setSectionColor( const int theSectionIndex, + const QColor& theColor ) const; + + HYDRODATA_EXPORT bool getSectionColor( const int theSectionIndex, QColor &theColor) const; HYDRODATA_EXPORT void removeSectionColor( const int theSectionIndex = -1 ) const; diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx index 16e02e74..cd7a7100 100644 --- a/src/HYDROData/HYDROData_PolylineXY.cxx +++ b/src/HYDROData/HYDROData_PolylineXY.cxx @@ -1249,6 +1249,7 @@ void HYDROData_PolylineXY::RemoveSection( const int theSectionIndex ) { removeSectionsLists(); removePointsLists(); + removeSectionColor(); } else { @@ -1281,7 +1282,8 @@ void HYDROData_PolylineXY::RemoveSection( const int theSectionIndex ) } // Remove points that belongs to removed section - removePointsLists( theSectionIndex ); //TODO remove colors + removePointsLists( theSectionIndex ); + removeSectionColor (theSectionIndex); } Changed( Geom_2d ); diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx index cbb18cba..ff4205b1 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx @@ -185,7 +185,7 @@ void HYDROGUI_PolylineOp::startOperation() Quantity_Color aColor = CurveCreator_Utils::getRandColor(); QColor aQColor = CurveCreator_Utils::colorConv(aColor); - myEditedObject->getSectionColor(i-1, aQColor, false); + myEditedObject->getSectionColor(i-1, aQColor); myCurve->addSectionInternal( aSectName.toStdString(), aCurveType, aSectClosure, aCurveCoords, CurveCreator_Utils::colorConv(aQColor) ); @@ -359,7 +359,7 @@ bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags, aPolylineObj->AddSection( aSectName, aSectType, aSectClosure ); Quantity_Color aColor = myCurve->getColorSection(i); - aPolylineObj->getSectionColor(i, CurveCreator_Utils::colorConv(aColor), true); + aPolylineObj->setSectionColor(i, CurveCreator_Utils::colorConv(aColor)); // Add the points from section CurveCreator::Coordinates aCurveCoords = myCurve->getCoords( i ); diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx index 6e8479d1..a60b6310 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx @@ -358,9 +358,14 @@ void HYDROGUI_ProfileDlg::onSetColorBtnPressed(bool) Quantity_Color newOCCCol = HYDROData_Tool::toOccColor(newQCurCol); aCurve->setColorSectionInternal(0, newOCCCol); - //Handle(AIS_InteractiveObject) anAISObject = aCurve->getAISObject(); - //if (anAISObject) - // anAISObject->SetColor(newOCCCol); + Handle(AIS_InteractiveObject) anAISObject = aCurve->getAISObject(); + if (anAISObject) + { + //color points of shape in the same color as edges + Handle(Prs3d_PointAspect) anAspect = anAISObject->Attributes()->PointAspect(); + anAspect->SetColor(newOCCCol); + anAISObject->Attributes()->SetPointAspect( anAspect ); + } QListWidgetItem* item = myProfileNames->item(theIndex); QPixmap SPixmap(16, 16); diff --git a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx index a6398c62..0ad3e45a 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx @@ -263,7 +263,7 @@ void HYDROGUI_ProfileOp::onAddProfiles() int ExistingProfLen = myEditedObjects.Length(); for (int i = 1; i <= aSelectedObj.Length(); i++) { - Handle(HYDROData_Entity) CurProf = Handle(HYDROData_Entity)::DownCast(aSelectedObj(i)); + Handle(HYDROData_Profile) CurProf = Handle(HYDROData_Profile)::DownCast(aSelectedObj.Value(i)); if (CurProf.IsNull()) continue; if (!edObjNamesMap.contains(CurProf->GetName()))