#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewPort3d.h>
#include "OCCViewer_Utilities.h"
+#include "OCCViewer_ViewWidget.h"
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
Qt::WindowFlags fl)
: QWidget(parent), myNewSectionEditor(NULL), myCurve(theCurve), mySection(0),
myDragStarted( false ), myDragInteractionStyle( SUIT_ViewModel::STANDARD ),
- myOCCViewer( 0 )
+ myOCCViewer( 0 ), myOCCViewWidget( 0 )
{
myNewSectionEditor = new CurveCreator_NewSectionDlg( this );
myNewSectionEditor->hide();
this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
connect( aViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
- OCCViewer_Utilities::setViewer2DMode( theViewer, OCCViewer_ViewWindow::XYPlane );
+ OCCViewer_Utilities::setViewer2DMode( myOCCViewer, OCCViewer_ViewWindow::XYPlane );
}
}
return myOCCViewer;
}
+/**
+ * Set an OCC viewer
+ */
+void CurveCreator_Widget::setOCCViewWidget( OCCViewer_ViewWidget* theViewWidget )
+{
+ if ( myOCCViewWidget == theViewWidget )
+ return;
+
+ if ( myOCCViewWidget ) {
+ disconnect( myOCCViewWidget, SIGNAL( mousePressed( QMouseEvent* ) ),
+ this, SLOT( onMousePress( QMouseEvent* ) ) );
+ disconnect( myOCCViewWidget, SIGNAL( mouseReleased( QMouseEvent* ) ),
+ this, SLOT( onMouseRelease( QMouseEvent* ) ) );
+ disconnect( myOCCViewWidget, SIGNAL( mouseMoving( QMouseEvent* ) ),
+ this, SLOT( onMouseMove( QMouseEvent* ) ) );
+ //disconnect( myOCCViewWidget, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+ // this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+
+ // restore normal mode in the viewer
+ OCCViewer_Utilities::setViewWidget2DMode( myOCCViewWidget, OCCViewer_ViewWidget::No2dMode );
+ // all local contexts should be closed if the viewer is not more used
+ setLocalPointContext( false, true );
+ }
+
+ myOCCViewWidget = theViewWidget;
+ if ( myOCCViewWidget ) {
+ connect( myOCCViewWidget, SIGNAL( mousePressed( QMouseEvent* ) ),
+ this, SLOT( onMousePress( QMouseEvent* ) ) );
+ connect( myOCCViewWidget, SIGNAL( mouseReleased( QMouseEvent* ) ),
+ this, SLOT( onMouseRelease( QMouseEvent* ) ) );
+ connect( myOCCViewWidget, SIGNAL( mouseMoving( QMouseEvent* ) ),
+ this, SLOT( onMouseMove( QMouseEvent* ) ) );
+ //connect( aViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+ // this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
+ OCCViewer_Utilities::setViewWidget2DMode( myOCCViewWidget, OCCViewer_ViewWidget::XYPlane );
+ }
+}
+
+/**
+ * Returns current OCC viewer
+ */
+OCCViewer_ViewWidget* CurveCreator_Widget::getOCCViewWidget()
+{
+ return myOCCViewWidget;
+}
+
/**
* Returns OCC viewer context
*/
Handle(AIS_InteractiveContext) CurveCreator_Widget::getAISContext()
{
+ Handle(AIS_InteractiveContext) aContext;
OCCViewer_Viewer* aViewer = getOCCViewer();
- return aViewer ? aViewer->getAISContext() : 0;
+ if ( aViewer )
+ aContext = aViewer->getAISContext();
+ else if ( myOCCViewWidget )
+ aContext = myOCCViewWidget->getAISContext();
+
+ return aContext;
}
/**
OCCViewer_Viewer* aViewer = getOCCViewer();
if ( aViewer )
aViewPort = ((OCCViewer_ViewWindow*)aViewer->getViewManager()->getActiveView())->getViewPort();
-
+ else if ( myOCCViewWidget )
+ aViewPort = myOCCViewWidget->getViewPort();
+
return aViewPort;
}
OCCViewer_Viewer* aViewer = getOCCViewer();
if ( aViewer )
aViewer->setObjectsSelected(theList);
+ else if ( myOCCViewWidget ) {
+ Handle(AIS_InteractiveContext) aContext = myOCCViewWidget->getAISContext();
+
+ AIS_ListIteratorOfListOfInteractive aIt;
+ for (aIt.Initialize(theList); aIt.More(); aIt.Next())
+ aContext->AddOrRemoveSelected(aIt.Value(), false);
+ aContext->UpdateCurrentViewer();
+ }
+}
+
+//=======================================================================
+// function: reset
+// purpose: reset the widget viewer, close local context, clear selection
+//=======================================================================
+void CurveCreator_Widget::reset()
+{
}
//=======================================================================
myOCCViewer = 0;
}
+void CurveCreator_Widget::onMousePress( QMouseEvent* theEvent )
+{
+ onMousePress( 0, theEvent );
+}
+
+void CurveCreator_Widget::onMouseRelease( QMouseEvent* theEvent )
+{
+ onMouseRelease( 0, theEvent );
+}
+
+void CurveCreator_Widget::onMouseMove( QMouseEvent* theEvent )
+{
+ onMouseMove( 0, theEvent );
+}
+
void CurveCreator_Widget::onCellChanged( int theRow, int theColumn )
{
int aCurrSect = getSectionId( theRow );