#include "HYDROGUI_PolylineOp.h"
#include "HYDROGUI_PolylineDlg.h"
#include "HYDROGUI_Tool.h"
+#include "CurveCreator.hxx"
+#include "CurveCreator_Curve.hxx"
+#include "CurveCreator_CurveEditor.hxx"
+#include "HYDROGUI_AISCurve.h"
#include <HYDROData_Document.h>
#include <HYDROData_Polyline.h>
#include <CurveCreator_CurveEditor.hxx>
#include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
#include <LightApp_UpdateFlags.h>
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+
+#include <OCCViewer_AISSelector.h>
HYDROGUI_PolylineOp::HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool theIsEdit )
-: HYDROGUI_Operation( theModule ), myIsEdit(theIsEdit), myCurve(NULL)
+: HYDROGUI_Operation( theModule ), myIsEdit(theIsEdit), myCurve(NULL),
+ myActiveViewManager(NULL), myPreviewViewManager(NULL), myAISCurve(NULL)
{
setName( theIsEdit ? tr( "EDIT_POLYLINE" ) : tr( "CREATE_POLYLINE" ) );
}
HYDROGUI_InputPanel* HYDROGUI_PolylineOp::createInputPanel() const
{
- return new HYDROGUI_PolylineDlg( module(), getName() );
+ HYDROGUI_PolylineDlg* aDlg = new HYDROGUI_PolylineDlg( module(), getName() );
+ connect( aDlg ,SIGNAL( selectionChanged() ), this, SLOT( onEditorSelectionChanged() ) );
+ return aDlg;
}
bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags,
aPolylineObj->setPolylineData(aPolylineData);
theUpdateFlags = UF_Model;
- aPolylineObj->SetVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), true );
+ module()->setObjectVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), aPolylineObj, true );
return true;
}
+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;
aPanel->setPolylineName(aNewName);
}
aPanel->setCurve(myCurve);
+ if( myAISCurve )
+ myAISCurve->setCurve(myCurve);
if( anOldCurve )
delete anOldCurve;
+ onCreatePreview();
+}
+
+void HYDROGUI_PolylineOp::onEditorSelectionChanged()
+{
+ HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
+ if( !aPanel )
+ return;
+ if( !myCurve )
+ return;
+ if( !myAISCurve )
+ return;
+ QList<int> aSelSections = aPanel->getSelectedSections();
+ for( int i = 0 ; i < myCurve->getNbSections() ; i++ ){
+ bool aIsHl = false;
+ if( aSelSections.contains(i) ){
+ myAISCurve->highlightSection(i, aIsHl);
+ }
+ }
}