-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// Author :
#include "OCCViewer_ViewWindow.h"
+#include "OCCViewer_ViewFrame.h"
#include "OCCViewer_ViewModel.h"
#include "OCCViewer_ViewPort3d.h"
#include "OCCViewer_ViewManager.h"
#include <Graphic3d_RenderingParams.hxx>
#endif
+#if OCC_VERSION_MAJOR < 7
+ #include <Visual3d_View.hxx>
+#endif
-#include <Visual3d_View.hxx>
#include <V3d_Plane.hxx>
#include <V3d_Light.hxx>
static QEvent* l_mbPressEvent = 0;
-#ifdef WIN32
-# include <QWindowsStyle>
-#endif
+//#ifdef WIN32
+//# include <QWindowsStyle>
+//#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
// To avoid conflict between KeyPress from the X.h (define KeyPress 2)
// and QEvent::KeyPress (qevent.h)
setCentralWidget(myViewPort);
myOperation = NOTHING;
- myCurrPointType = GRAVITY;
- myPrevPointType = GRAVITY;
+ myCurrPointType = BBCENTER;
+ myPrevPointType = BBCENTER;
mySelectedPoint = gp_Pnt(0.,0.,0.);
myRotationPointSelection = false;
if ( aEvent->modifiers().testFlag(Qt::ControlModifier) ) {
Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
- if ( isPreselectionEnabled() && ic->HasOpenedContext() ) {
+ if ( isPreselectionEnabled() && myModel->useLocalSelection() ) {
if ( aEvent->delta() > 0 ) {
ic->HilightNextDetected( myViewPort->getView() );
} else {
int x1 = (int)( aEvent->x() + width()*delta/100 );
int y1 = (int)( aEvent->y() + height()*delta/100 );
myViewPort->zoom( x, y, x1, y1 );
+#if OCC_VERSION_LARGE <= 0x07000000
myViewPort->getView()->ZFitAll();
+#endif
emit vpTransformationFinished ( ZOOMVIEW );
}
}
if ( theEvent->button() == Qt::LeftButton )
{
Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
- ic->Select();
+ ic->Select( Standard_True );
for ( ic->InitSelected(); ic->MoreSelected(); ic->NextSelected() )
{
TopoDS_Shape aShape = ic->SelectedShape();
}
if ( ic->NbSelected() == 0 ) myCurrPointType = myPrevPointType;
if ( mySetRotationPointDlg ) mySetRotationPointDlg->toggleChange();
- ic->CloseAllContexts();
+ ic->CloseAllContexts( Standard_True );
myOperation = NOTHING;
myViewPort->setCursor( myCursor );
myCursorIsHand = false;
if ( myRotationPointSelection )
{
Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
- ic->CloseAllContexts();
+ ic->CloseAllContexts( Standard_True );
myOperation = NOTHING;
myViewPort->setCursor( myCursor );
myCursorIsHand = false;
}
myPrevPointType = myCurrPointType;
- myCurrPointType = GRAVITY;
+ myCurrPointType = BBCENTER;
Standard_Real Xcenter, Ycenter, Zcenter;
- if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) )
+ if ( OCCViewer_Utilities::computeVisibleBBCenter( myViewPort->getView(), Xcenter, Ycenter, Zcenter ) )
mySetRotationPointDlg->setCoords( Xcenter, Ycenter, Zcenter );
}
*/
void OCCViewer_ViewWindow::updateGravityCoords()
{
- if ( mySetRotationPointDlg && mySetRotationPointDlg->isVisible() && myCurrPointType == GRAVITY )
+ if ( mySetRotationPointDlg && mySetRotationPointDlg->isVisible() && myCurrPointType == BBCENTER )
{
Standard_Real Xcenter, Ycenter, Zcenter;
- if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) )
+ if ( OCCViewer_Utilities::computeVisibleBBCenter( myViewPort->getView(), Xcenter, Ycenter, Zcenter ) )
mySetRotationPointDlg->setCoords( Xcenter, Ycenter, Zcenter );
}
}
if ( myRotationPointSelection )
{
Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
- ic->CloseAllContexts();
+ ic->CloseAllContexts( Standard_True );
myOperation = NOTHING;
myViewPort->setCursor( myCursor );
myCursorIsHand = false;
case PANVIEW:
case ZOOMVIEW:
+#if OCC_VERSION_LARGE <= 0x07000000
myViewPort->getView()->ZFitAll();
+#endif
resetState();
break;
if (!mySetRotationPointDlg->isVisible())
{
//if (mySetRotationPointDlg->IsFirstShown())
- if (myCurrPointType == GRAVITY)
+ if (myCurrPointType == BBCENTER)
{
Standard_Real Xcenter, Ycenter, Zcenter;
- if (computeGravityCenter(Xcenter, Ycenter, Zcenter))
+ if (OCCViewer_Utilities::computeVisibleBBCenter(myViewPort->getView(), Xcenter, Ycenter, Zcenter))
mySetRotationPointDlg->setCoords(Xcenter, Ycenter, Zcenter);
}
mySetRotationPointDlg->show();
SUIT_ViewWindow* vw = myManager->createViewWindow();
//vw->show();
emit viewCloned( vw );
+ OCCViewer_ViewWindow* occVw = dynamic_cast<OCCViewer_ViewWindow*> (vw);
+ if(occVw && occVw->getView(OCCViewer_ViewFrame::MAIN_VIEW)) {
+ occVw->getView(OCCViewer_ViewFrame::MAIN_VIEW)->synchronize(this);
+ }
}
/*!
void OCCViewer_ViewWindow::onAxialScale()
{
if ( !myScalingDlg )
- myScalingDlg = new OCCViewer_AxialScaleDlg( this );
+ myScalingDlg = new OCCViewer_AxialScaleDlg( this , myModel );
if ( !myScalingDlg->isVisible() )
{
if ( format != "PS" && format != "EPS")
res = myViewPort->getView()->Dump( fileName.toStdString().c_str() );
+#if OCC_VERSION_MAJOR < 7
Handle(Visual3d_View) a3dView = myViewPort->getView()->View();
+#else
+ Handle(Graphic3d_CView) a3dView = myViewPort->getView()->View();
+#endif
if (format == "PS")
res = a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_PostScript);
gp_Pln pln (gp_Pnt(x, y, z), gp_Dir(dx, dy, dz));
double a, b, c, d;
pln.Coefficients(a, b, c, d);
-
+#if OCC_VERSION_LARGE > 0x07000000
+ Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = view->ClipPlanes();
+ Graphic3d_SequenceOfHClipPlane::Iterator anIter (*aPlanes);
+ if(aPlanes->Size() > 0 ) {
+#else
Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();
+ Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
if(aPlanes.Size() > 0 ) {
- Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
+#endif
Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value();
aClipPlane->SetEquation(pln);
aClipPlane->SetOn(Standard_True);
}
}
else {
+#if OCC_VERSION_LARGE > 0x07000000
+ Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = view->ClipPlanes();
+ Graphic3d_SequenceOfHClipPlane::Iterator anIter (*aPlanes);
+#else
Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();
Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
+#endif
for( ;anIter.More();anIter.Next() ){
Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value();
aClipPlane->SetOn(Standard_False);
{
Handle(V3d_View) view = myViewPort->getView();
bool res = false;
- Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();
- Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
+#if OCC_VERSION_LARGE > 0x07000000
+ Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = view->ClipPlanes();
+ Graphic3d_SequenceOfHClipPlane::Iterator anIter (*aPlanes);
+#else
+ Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes();
+ Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes);
+#endif
for( ;anIter.More();anIter.Next() ) {
Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value();
if(aClipPlane->IsOn()) {
aTexture = new Graphic3d_TextureEnv( TCollection_AsciiString( et_paramValue.toStdString().c_str() ) );
Handle(V3d_View) aView = this->getViewPort()->getView();
aView->SetTextureEnv( aTexture );
+#if OCC_VERSION_LARGE <= 0x07000000
aView->SetSurfaceDetail( V3d_TEX_ENVIRONMENT );
+#endif
}
}
else if ( paramName == "lightSource" )
while ( myModel->getViewer3d()->MoreDefinedLights() )
{
Handle(V3d_Light) aLight = myModel->getViewer3d()->DefinedLight();
- if( aLight->Type() != V3d_AMBIENT )
+ if( aLight->Type() != V3d_AMBIENT ) {
myModel->getViewer3d()->DelLight( aLight );
- myModel->getViewer3d()->NextDefinedLights();
+ myModel->getViewer3d()->InitDefinedLights();
+ } else {
+ myModel->getViewer3d()->NextDefinedLights();
+ }
}
double aX, aY, aZ;
double cR, cG, cB;
#endif
getViewPort()->setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] );
-
+#if OCC_VERSION_LARGE <= 0x07000000
aDestView->ZFitAll();
+#endif
aDestView->SetImmediateUpdate( Standard_True );
aDestView->Redraw();