-void HYDROGUI_PolylineOp::onCreatePreview()
-{
- LightApp_Application* anApp = module()->getApp();
-
- myActiveViewManager = anApp->activeViewManager();
-
- myPreviewViewManager =
- dynamic_cast<OCCViewer_ViewManager*>( anApp->createViewManager( OCCViewer_Viewer::Type() ) );
- if( myPreviewViewManager )
- {
- anApp->selectionMgr()->setEnabled(false);
- myPreviewViewManager->setTitle( tr( "CREATE_CURVE" ) );
- OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
- aViewer->enableSelection(true);
- aViewer->enableMultiselection(true);
- Handle_AIS_InteractiveContext aCtx = aViewer->getAISContext();
-
- myAISCurve = new HYDROGUI_AISCurve(myCurve, aCtx);
-
- myAISCurve->Display();
- }
-}
-
-void HYDROGUI_PolylineOp::startOperation()
-{
- CurveCreator_Curve* anOldCurve = myCurve;
-
- HYDROGUI_Operation::startOperation();
-
- HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
- aPanel->reset();
-
- myEditedObject = Handle(HYDROData_Polyline)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
- if( !myEditedObject.IsNull() )
- {
- int anIntDim = myEditedObject->getDimension();
- CurveCreator::Dimension aDim = CurveCreator::Dim3d;
- if( anIntDim == 2 )
- aDim = CurveCreator::Dim2d;
- myCurve = new CurveCreator_Curve(aDim);
- QList<PolylineSection> aPolylineData = myEditedObject->getPolylineData();
-
- CurveCreator_CurveEditor* anEdit = new CurveCreator_CurveEditor(myCurve);
- for( int i = 0 ; i < aPolylineData.size() ; i++ ){
- std::string aName = HYDROGUI_Tool::ToQString(aPolylineData[i].mySectionName).toStdString();
- bool isClosed = aPolylineData[i].myIsClosed;
- CurveCreator::Type aType = CurveCreator::Polyline;
- if( aPolylineData[i].myType == PolylineSection::SECTION_SPLINE ){
- aType = CurveCreator::BSpline;
- }
- CurveCreator::Coordinates aCoords;
- for( int j = 0 ; j < aPolylineData[i].myCoords.size() ; j++ ){
- aCoords.push_back(aPolylineData[i].myCoords[j]);
- }
- anEdit->addSection( aName, aType, isClosed, aCoords );
- }
- delete anEdit;
- aPanel->setPolylineName( myEditedObject->GetName() );
-
- }
- else{
- myCurve = new CurveCreator_Curve(CurveCreator::Dim3d);
- aPanel->setCurve(myCurve);
- QString aNewName = HYDROGUI_Tool::GenerateObjectName( module(), tr("POLYLINE_PREFIX") );
- aPanel->setPolylineName(aNewName);
- }
- aPanel->setCurve(myCurve);
- if( myAISCurve )
- myAISCurve->setCurve(myCurve);
- if( anOldCurve )
- delete anOldCurve;
- onCreatePreview();
-}
-