Salome HOME
lots 3,8 - corrections
authorisn <isn@opencascade.com>
Thu, 11 Oct 2018 13:14:04 +0000 (16:14 +0300)
committerisn <isn@opencascade.com>
Thu, 11 Oct 2018 13:44:05 +0000 (16:44 +0300)
Signed-off-by: isn <isn@opencascade.com>
src/HYDROData/HYDROData_IPolyline.cxx
src/HYDROData/HYDROData_IPolyline.h
src/HYDROData/HYDROData_PolylineXY.cxx
src/HYDROGUI/HYDROGUI_PolylineOp.cxx
src/HYDROGUI/HYDROGUI_ProfileDlg.cxx
src/HYDROGUI/HYDROGUI_ProfileOp.cxx

index 3bcb60dc9b8376dca158dacf025dd6793d91670c..1ec97913a28b97a035e8b46d213c000c7c06389d 100644 (file)
@@ -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 );
index cd306e979b759de8abb4741fed1f5174cb2db9c8..c8916d4cc9ea78492e96c740c730dc816361d01a 100644 (file)
@@ -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;
 
index 16e02e74551d12ddc8a3dd26712fbcc68df9ceac..cd7a710078d56bd9978b6eef4b1ff46dbdc19d05 100644 (file)
@@ -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 );
index cbb18cba0c0e210c92299d4872d543cbc62f0855..ff4205b1f9af7fa52fe67b5dcf393f9b33b6e5b0 100755 (executable)
@@ -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 );
index 6e8479d111eb75ed57c4044e6ed6e974859ba6b6..a60b631053fca3ec3325d9614d23dd4a9cf0e63f 100644 (file)
@@ -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);
index a6398c62b661722e8e2d399b0a10e91dcc234f4a..0ad3e45ac4789506905d246b01f21e111f815952 100644 (file)
@@ -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()))