- QString aPolylineName = aPanel->getPolylineName();
- aPolylineObj->SetName(aPolylineName);
- int aDimInt = 3;
- if( myCurve->getDimension() == CurveCreator::Dim2d )
- aDimInt = 2;
- aPolylineObj->setDimension(aDimInt);
- QList<PolylineSection> aPolylineData;
- for( int i=0 ; i < myCurve->getNbSections() ; i++ ){
- PolylineSection aSect;
- aSect.mySectionName = HYDROGUI_Tool::ToExtString( QString::fromLocal8Bit(myCurve->getSectionName(i).c_str()));
- aSect.myIsClosed = myCurve->isClosed(i);
- aSect.myType = PolylineSection::SECTION_POLYLINE;
- if( myCurve->getType(i) == CurveCreator::BSpline ){
- aSect.myType = PolylineSection::SECTION_SPLINE;
- }
- CurveCreator::Coordinates aCoords = myCurve->getPoints(i);
- for( int j = 0 ; j < aCoords.size() ; j++ ){
- aSect.myCoords << aCoords.at(j);
+ myCurve = new CurveCreator_Curve( CurveCreator::Dim2d );
+
+ HYDROGUI_Operation::startOperation();
+
+ HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
+ aPanel->reset();
+
+ LightApp_Application* anApp = module()->getApp();
+ OCCViewer_ViewManager* aViewManager =
+ dynamic_cast<OCCViewer_ViewManager*>( anApp->getViewManager( OCCViewer_Viewer::Type(), true ) );
+ aPanel->setOCCViewer( aViewManager ? aViewManager->getOCCViewer() : 0 );
+ setPreviewManager( aViewManager );
+
+ QString aPolylineName;
+ if( !myEditedObject.IsNull() )
+ {
+ NCollection_Sequence<TCollection_AsciiString> aSectNames;
+ NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
+ NCollection_Sequence<bool> aSectClosures;
+ myEditedObject->GetSections( aSectNames, aSectTypes, aSectClosures );
+
+ for ( int i = 1, n = aSectNames.Size(); i <= n; ++i )
+ {
+ QString aSectName = HYDROGUI_Tool::ToQString( aSectNames.Value( i ) );
+ HYDROData_PolylineXY::SectionType aSectType = aSectTypes.Value( i );
+ bool aSectClosure = aSectClosures.Value( i );
+
+ CurveCreator::SectionType aCurveType = CurveCreator::Polyline;
+ if( aSectType == HYDROData_PolylineXY::SECTION_SPLINE )
+ aCurveType = CurveCreator::Spline;
+
+ CurveCreator::Coordinates aCurveCoords;
+
+ HYDROData_PolylineXY::PointsList aSectPointsList = myEditedObject->GetPoints( i - 1 );
+ for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k )
+ {
+ const HYDROData_PolylineXY::Point& aSectPoint = aSectPointsList.Value( k );
+ aCurveCoords.push_back( aSectPoint.X() );
+ aCurveCoords.push_back( aSectPoint.Y() );
+ }
+
+ myCurve->addSectionInternal( aSectName.toStdString(), aCurveType, aSectClosure, aCurveCoords );