6 #include "XGUI_ViewPort.h"
7 #include "XGUI_ViewWindow.h"
8 #include "XGUI_Viewer.h"
9 #include "XGUI_Constants.h"
11 #include <QPaintEvent>
14 #include <QApplication>
16 #include <V3d_OrthographicView.hxx>
17 #include <V3d_PerspectiveView.hxx>
18 #include <Visual3d_View.hxx>
19 #include <Graphic3d_GraphicDriver.hxx>
22 #include <WNT_Window.hxx>
24 #include <Xw_Window.hxx>
28 //qmetatype.h must be included before any header file that defines Bool
29 //see /QtCore/qmetatype.h:53 for more info
31 # ifndef GLX_GLXEXT_LEGACY
32 # define GLX_GLXEXT_LEGACY
38 static double rx = 0.;
39 static double ry = 0.;
42 static Standard_Boolean zRotation = Standard_False;
45 Create native view window for CasCade view [ static ]
47 Handle(Aspect_Window) CreateCasWindow(const Handle(V3d_View)& view, WId winId)
49 Aspect_Handle aWindowHandle = (Aspect_Handle) winId;
51 Handle(WNT_Window) viewWindow = new WNT_Window(aWindowHandle);
53 Handle(Aspect_DisplayConnection) aDispConnection = view->Viewer()->Driver()->GetDisplayConnection();
54 Handle(Xw_Window) viewWindow = new Xw_Window( aDispConnection, aWindowHandle );
59 class OpenGLUtils_FrameBuffer
62 OpenGLUtils_FrameBuffer();
63 ~OpenGLUtils_FrameBuffer();
65 bool init(const GLsizei&, const GLsizei&);
81 #define APIENTRYP APIENTRY *
84 #ifndef GL_FRAMEBUFFER_EXT
85 #define GL_FRAMEBUFFER_EXT 0x8D40
88 #ifndef GL_RENDERBUFFER_EXT
89 #define GL_RENDERBUFFER_EXT 0x8D41
92 #ifndef GL_COLOR_ATTACHMENT0_EXT
93 #define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
96 #ifndef GL_DEPTH_ATTACHMENT_EXT
97 #define GL_DEPTH_ATTACHMENT_EXT 0x8D00
100 #ifndef GL_FRAMEBUFFER_COMPLETE_EXT
101 #define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
104 typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC)(GLsizei n, GLuint *framebuffers);
105 typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC)(GLenum target, GLuint framebuffer);
106 typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)(GLenum target, GLenum attachment,
107 GLenum textarget, GLuint texture,
109 typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target);
110 typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC)(GLsizei n, const GLuint *framebuffers);
111 typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC)(GLsizei n, GLuint *renderbuffers);
112 typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC)(GLenum target, GLuint renderbuffer);
113 typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target, GLenum internalformat,
114 GLsizei width, GLsizei height);
115 typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)(GLenum target, GLenum attachment,
116 GLenum renderbuffertarget,
117 GLuint renderbuffer);
118 typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC)(GLsizei n, const GLuint *renderbuffers);
120 static PFNGLGENFRAMEBUFFERSEXTPROC vglGenFramebuffersEXT = NULL;
121 static PFNGLBINDFRAMEBUFFEREXTPROC vglBindFramebufferEXT = NULL;
122 static PFNGLFRAMEBUFFERTEXTURE2DEXTPROC vglFramebufferTexture2DEXT = NULL;
123 static PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC vglCheckFramebufferStatusEXT = NULL;
124 static PFNGLDELETEFRAMEBUFFERSEXTPROC vglDeleteFramebuffersEXT = NULL;
125 static PFNGLGENRENDERBUFFERSEXTPROC vglGenRenderbuffersEXT = NULL;
126 static PFNGLBINDRENDERBUFFEREXTPROC vglBindRenderbufferEXT = NULL;
127 static PFNGLRENDERBUFFERSTORAGEEXTPROC vglRenderbufferStorageEXT = NULL;
128 static PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC vglFramebufferRenderbufferEXT = NULL;
129 static PFNGLDELETERENDERBUFFERSEXTPROC vglDeleteRenderbuffersEXT = NULL;
132 #define GL_GetProcAddress( x ) glXGetProcAddressARB( (const GLubyte*)x )
134 #define GL_GetProcAddress( x ) wglGetProcAddress( (const LPCSTR)x )
139 vglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) GL_GetProcAddress("glGenFramebuffersEXT");
140 vglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) GL_GetProcAddress("glBindFramebufferEXT");
141 vglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) GL_GetProcAddress(
142 "glFramebufferTexture2DEXT");
143 vglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) GL_GetProcAddress(
144 "glCheckFramebufferStatusEXT");
145 vglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) GL_GetProcAddress(
146 "glDeleteFramebuffersEXT");
147 vglGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) GL_GetProcAddress(
148 "glGenRenderbuffersEXT");
149 vglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) GL_GetProcAddress(
150 "glBindRenderbufferEXT");
151 vglRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) GL_GetProcAddress(
152 "glRenderbufferStorageEXT");
153 vglFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) GL_GetProcAddress(
154 "glFramebufferRenderbufferEXT");
155 vglDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) GL_GetProcAddress(
156 "glDeleteRenderbuffersEXT");
158 bool ok = vglGenFramebuffersEXT && vglBindFramebufferEXT && vglFramebufferTexture2DEXT
159 && vglCheckFramebufferStatusEXT && vglDeleteFramebuffersEXT && vglGenRenderbuffersEXT
160 && vglBindRenderbufferEXT && vglRenderbufferStorageEXT && vglFramebufferRenderbufferEXT
161 && vglDeleteRenderbuffersEXT;
166 static bool IsEXTInitialized = InitializeEXT();
168 OpenGLUtils_FrameBuffer::OpenGLUtils_FrameBuffer()
169 : textureId(0), fboId(0), rboId(0)
173 OpenGLUtils_FrameBuffer::~OpenGLUtils_FrameBuffer()
178 bool OpenGLUtils_FrameBuffer::init(const GLsizei& xSize, const GLsizei& ySize)
180 char* ext = (char*) glGetString(GL_EXTENSIONS);
183 if (!IsEXTInitialized || strstr(ext, "GL_EXT_framebuffer_object") == NULL) {
184 //qDebug( "Initializing OpenGL FrameBuffer extension failed");
188 // create a texture object
189 glEnable (GL_TEXTURE_2D);
190 glGenTextures(1, &textureId);
191 glBindTexture(GL_TEXTURE_2D, textureId);
192 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
193 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
194 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, xSize, ySize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
195 glBindTexture(GL_TEXTURE_2D, 0);
197 // create a renderbuffer object to store depth info
198 vglGenRenderbuffersEXT(1, &rboId);
199 vglBindRenderbufferEXT( GL_RENDERBUFFER_EXT, rboId);
200 vglRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, xSize, ySize);
201 vglBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0);
203 // create a framebuffer object
204 vglGenFramebuffersEXT(1, &fboId);
205 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fboId);
207 // attach the texture to FBO color attachment point
208 vglFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D,
211 // attach the renderbuffer to depth attachment point
212 vglFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
217 GLenum status = vglCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT);
220 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0);
222 return status == GL_FRAMEBUFFER_COMPLETE_EXT;
225 void OpenGLUtils_FrameBuffer::release()
227 if (!IsEXTInitialized)
230 glDeleteTextures(1, &textureId);
233 vglDeleteFramebuffersEXT(1, &fboId);
236 vglDeleteRenderbuffersEXT(1, &rboId);
240 void OpenGLUtils_FrameBuffer::bind()
242 if (!IsEXTInitialized)
245 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fboId);
248 void OpenGLUtils_FrameBuffer::unbind()
250 if (!IsEXTInitialized)
253 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0);
256 //************************************************************************
257 //************************************************************************
258 //************************************************************************
259 XGUI_ViewPort::XGUI_ViewPort(XGUI_ViewWindow* theParent,
260 const Handle(V3d_Viewer)& theViewer,
261 V3d_TypeOfView theType)
262 : QWidget(theParent),
263 myPaintersRedrawing(false),
265 myIsAdvancedZoomingEnabled(false),
269 setMouseTracking(true);
270 setBackgroundRole(QPalette::NoRole);
272 // set focus policy to threat QContextMenuEvent from keyboard
273 setFocusPolicy(Qt::StrongFocus);
274 setAttribute(Qt::WA_PaintOnScreen);
275 setAttribute(Qt::WA_NoSystemBackground);
276 setAutoFillBackground(false);
278 if (theType == V3d_ORTHOGRAPHIC) {
279 myOrthoView = new V3d_OrthographicView(theViewer);
280 myActiveView = myOrthoView;
283 myPerspView = new V3d_PerspectiveView(theViewer);
284 myActiveView = myPerspView;
286 myActiveView->SetSurfaceDetail(V3d_TEX_ALL);
289 //***********************************************
290 XGUI_ViewPort::~XGUI_ViewPort()
294 //***********************************************
295 bool XGUI_ViewPort::mapView(const Handle(V3d_View)& theView)
297 if (!setWindow(theView))
300 if (!mapped(theView)) {
301 theView->SetWindow(myWindow);
302 //if (theView != activeView())
303 //theView->View()->Deactivate();
306 /* create static trihedron (16551: EDF PAL 501) */
307 //OCCViewer_ViewWindow* aVW = dynamic_cast<OCCViewer_ViewWindow*>( parentWidget()->parentWidget()->parentWidget() );
309 // OCCViewer_Viewer* aViewModel = dynamic_cast<OCCViewer_Viewer*>( aVW->getViewManager()->getViewModel() );
310 // if ( aViewModel && aViewModel->isStaticTrihedronDisplayed() ){
311 //theView->ZBufferTriedronSetup();
312 theView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER);
321 //***********************************************
322 bool XGUI_ViewPort::setWindow(const Handle(V3d_View)& theView)
324 if (!myWindow.IsNull())
327 if (theView.IsNull())
330 attachWindow(theView, CreateCasWindow(theView, winId()));
332 myWindow = theView->Window();
333 return !myWindow.IsNull();
336 //***********************************************
337 bool XGUI_ViewPort::mapped(const Handle(V3d_View)& theView) const
339 return (!theView.IsNull() && theView->View()->IsDefined());
342 //***********************************************
343 void XGUI_ViewPort::updateBackground()
345 if (activeView().IsNull())
347 if (!myBackground.isValid())
350 // VSR: Important note on below code.
351 // In OCCT (in version 6.5.2), things about the background drawing
352 // are not straightforward and not clearly understandable:
353 // - Horizontal gradient is drawn vertically (!), well ok, from top side to bottom one.
354 // - Vertical gradient is drawn horizontally (!), from right side to left one (!!!).
355 // - First and second diagonal gradients are confused.
356 // - Image texture, once set, can not be removed (!).
357 // - Texture image fill mode Aspect_FM_NONE is not taken into account (and means the same
358 // as Aspect_FM_CENTERED).
359 // - The only way to cancel gradient background (and get back to single colored) is to
360 // set gradient background style to Aspect_GFM_NONE while passing two colors is also needed
361 // (see V3d_View::SetBgGradientColors() function).
362 // - Also, it is impossible to draw texture image above the gradiented background (only above
364 // In OCCT 6.5.3 all above mentioned problems are fixed; so, above comment should be removed as soon
365 // as SALOME is migrated to OCCT 6.5.3. The same concerns #ifdef statements in the below code
366 switch(myBackground.mode()) {
367 case XGUI::ColorBackground: {
368 QColor c = myBackground.color();
370 // Unset texture should be done here
372 Quantity_Color qCol(c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB);
373 activeView()->SetBgGradientStyle(Aspect_GFM_NONE); // cancel gradient background
374 activeView()->SetBgImageStyle(Aspect_FM_NONE); // cancel texture background
375 // then change background color
376 activeView()->SetBackgroundColor(qCol);
378 activeView()->Update();
382 case XGUI::SimpleGradientBackground: {
384 int type = myBackground.gradient(c1, c2);
385 if (c1.isValid() && type >= XGUI::HorizontalGradient && type <= XGUI::LastGradient) {
386 // Unset texture should be done here
388 // Get colors and set-up gradiented background
391 Quantity_Color qCol1(c1.red() / 255., c1.green() / 255., c1.blue() / 255., Quantity_TOC_RGB);
392 Quantity_Color qCol2(c2.red() / 255., c2.green() / 255., c2.blue() / 255., Quantity_TOC_RGB);
393 activeView()->SetBgImageStyle(Aspect_FM_NONE); // cancel texture background
395 case XGUI::HorizontalGradient:
396 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_HOR,
399 case XGUI::VerticalGradient:
400 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_VER,
403 case XGUI::Diagonal1Gradient:
404 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG1,
407 case XGUI::Diagonal2Gradient:
408 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG2,
411 case XGUI::Corner1Gradient:
412 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER1,
415 case XGUI::Corner2Gradient:
416 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER2,
419 case XGUI::Corner3Gradient:
420 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER3,
423 case XGUI::Corner4Gradient:
424 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER4,
433 case XGUI::CustomGradientBackground:
434 // NOT IMPLEMENTED YET
439 // VSR: In OCCT before v6.5.3 below code can't be used because of very ugly bug - it has been impossible to
440 // clear the background texture image as soon as it was once set to the viewer.
441 if (myBackground.isTextureShown()) {
443 int textureMode = myBackground.texture(fileName);
444 QFileInfo fi(fileName);
445 if (!fileName.isEmpty() && fi.exists()) {
446 // set texture image: file name and fill mode
447 switch(textureMode) {
448 case XGUI::CenterTexture:
449 activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
452 case XGUI::TileTexture:
453 activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
456 case XGUI::StretchTexture:
457 activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
463 activeView()->Update();
468 //***********************************************
469 void XGUI_ViewPort::attachWindow(const Handle(V3d_View)& theView,
470 const Handle(Aspect_Window)& theWnd)
472 if (!theView.IsNull()) {
473 theView->SetWindow(theWnd);
478 //***********************************************
479 void XGUI_ViewPort::paintEvent(QPaintEvent* theEvent)
482 /* X11 : map before show doesn't work */
483 if ( !mapped( activeView() ) )
484 mapView( activeView() );
486 if (!myWindow.IsNull()) {
487 QApplication::syncX();
488 QRect rc = theEvent->rect();
489 //if ( !myPaintersRedrawing ) {
490 //activeView()->Redraw();
491 activeView()->Redraw(rc.x(), rc.y(), rc.width(), rc.height());
495 //if ( myPaintersRedrawing ) {
496 // QPainter p( this );
497 // //emit vpDrawExternal( &p );
498 // myPaintersRedrawing = false;
502 //***********************************************
503 void XGUI_ViewPort::resizeEvent(QResizeEvent* theEvent)
506 /* Win32 : map before first show to avoid flicker */
507 if (!mapped(activeView()))
508 mapView(activeView());
510 QApplication::syncX();
511 if (!activeView().IsNull()) {
512 activeView()->MustBeResized();
516 //***********************************************
517 QImage XGUI_ViewPort::dumpView(QRect theRect, bool toUpdate)
519 Handle(V3d_View) view = getView();
525 if (theRect.isNull()) {
529 aWidth = theRect.width();
530 aHeight = theRect.height();
532 QApplication::syncX();
534 OpenGLUtils_FrameBuffer aFrameBuffer;
535 if (aFrameBuffer.init(aWidth, aHeight)) {
536 QImage anImage(aWidth, aHeight, QImage::Format_RGB32);
538 glPushAttrib (GL_VIEWPORT_BIT);
539 glViewport(0, 0, aWidth, aHeight);
544 if (theRect.isNull())
547 view->Redraw(theRect.x(), theRect.y(), theRect.width(), theRect.height());
549 aFrameBuffer.unbind();
553 if (theRect.isNull())
554 glReadPixels(0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits());
556 glReadPixels(theRect.x(), theRect.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE,
558 aFrameBuffer.unbind();
560 anImage = anImage.rgbSwapped();
561 anImage = anImage.mirrored();
564 // if frame buffers are unsupported, use old functionality
565 unsigned char* data = new unsigned char[aWidth * aHeight * 4];
568 if (theRect.isNull()) {
571 p = mapFromParent(geometry().topLeft());
574 view->Redraw(theRect.x(), theRect.y(), theRect.width(), theRect.height());
575 p = theRect.topLeft();
577 glReadPixels(p.x(), p.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, data);
579 QImage anImage(data, aWidth, aHeight, QImage::Format_ARGB32);
580 anImage = anImage.mirrored();
581 anImage = anImage.rgbSwapped();
586 Inits 'rotation' transformation.
588 void XGUI_ViewPort::startRotation(int x, int y, int theRotationPointType,
589 const gp_Pnt& theSelectedPoint)
591 if (!activeView().IsNull()) {
592 switch(theRotationPointType) {
594 activeView()->StartRotation(x, y, 0.45);
601 activeView()->Size(X, Y);
602 rx = Standard_Real(activeView()->Convert(X));
603 ry = Standard_Real(activeView()->Convert(Y));
605 activeView()->Rotate(0., 0., 0., theSelectedPoint.X(), theSelectedPoint.Y(),
606 theSelectedPoint.Z(),
609 Quantity_Ratio zRotationThreshold;
610 zRotation = Standard_False;
611 zRotationThreshold = 0.45;
612 if (zRotationThreshold > 0.) {
613 Standard_Real dx = Abs(sx - rx / 2.);
614 Standard_Real dy = Abs(sy - ry / 2.);
615 Standard_Real dd = zRotationThreshold * (rx + ry) / 2.;
616 if (dx > dd || dy > dd)
617 zRotation = Standard_True;
623 activeView()->DepthFitAll();
628 Rotates the viewport.
630 void XGUI_ViewPort::rotate(int x, int y, int theRotationPointType, const gp_Pnt& theSelectedPoint)
632 if (!activeView().IsNull()) {
633 switch(theRotationPointType) {
635 activeView()->Rotation(x, y);
640 dz = atan2(Standard_Real(x) - rx / 2., ry / 2. - Standard_Real(y))
641 - atan2(sx - rx / 2., ry / 2. - sy);
644 dx = (Standard_Real(x) - sx) * M_PI / rx;
645 dy = (sy - Standard_Real(y)) * M_PI / ry;
649 activeView()->Rotate(dx, dy, dz, theSelectedPoint.X(), theSelectedPoint.Y(),
650 theSelectedPoint.Z(),
656 emit vpTransformed();
658 // setZSize( getZSize() );
662 Resets the viewport after 'rotation'.
664 void XGUI_ViewPort::endRotation()
666 if (!activeView().IsNull()) {
667 activeView()->ZFitAll(1.);
668 activeView()->SetZSize(0.);
669 activeView()->Update();
670 emit vpTransformed();
675 Inits 'zoom' transformation.
677 void XGUI_ViewPort::startZoomAtPoint(int x, int y)
679 if (!activeView().IsNull()/* && isAdvancedZoomingEnabled() */)
680 activeView()->StartZoomAtPoint(x, y);
684 Centers the viewport.
686 void XGUI_ViewPort::setCenter(int x, int y)
688 if (!activeView().IsNull()) {
689 activeView()->Place(x, y, myScale);
690 emit vpTransformed();
695 Called at 'pan' transformation.
697 void XGUI_ViewPort::pan(int dx, int dy)
699 if (!activeView().IsNull()) {
700 activeView()->Pan(dx, dy, 1.0);
701 emit vpTransformed();
706 Called at 'window fit' transformation.
708 void XGUI_ViewPort::fitRect(const QRect& rect)
710 if (!activeView().IsNull()) {
711 activeView()->WindowFit(rect.left(), rect.top(), rect.right(), rect.bottom());
712 emit vpTransformed();
717 Called at 'zoom' transformation.
719 void XGUI_ViewPort::zoom(int x0, int y0, int x, int y)
721 if (!activeView().IsNull()) {
722 if (isAdvancedZoomingEnabled())
723 activeView()->ZoomAtPoint(x0, y0, x, y);
725 activeView()->Zoom(x0 + y0, 0, x + y, 0);
726 emit vpTransformed();
731 Sets the background data
733 void XGUI_ViewPort::setBackground(const XGUI_ViewBackground& bgData)
735 if (bgData.isValid()) {
736 myBackground = bgData;
738 emit vpChangeBackground(myBackground);
742 void XGUI_ViewPort::fitAll(bool theKeepScale, bool theWithZ, bool theUpd)
744 if ( activeView().IsNull() )
748 myScale = activeView()->Scale();
750 Standard_Real aMargin = 0.01;
751 activeView()->FitAll( aMargin, theWithZ, theUpd );
752 activeView()->SetZSize(0.);
753 emit vpTransformed( );
756 void XGUI_ViewPort::syncronizeWith( const XGUI_ViewPort* ref )
758 Handle(V3d_View) refView = ref->getView();
759 Handle(V3d_View) tgtView = getView();
761 /* The following params are copied:
762 - view type( ortho/persp )
763 - position of view point
764 - orientation of high point
765 - position of the eye
772 /* we'll update after setting all params */
773 tgtView->SetImmediateUpdate( Standard_False );
776 if ( refView->Type() == V3d_PERSPECTIVE )
777 tgtView->SetFocale( refView->Focale() );
780 Standard_Real x, y, z;
781 refView->At( x, y, z ); tgtView->SetAt( x, y, z );
782 refView->Up( x, y, z ); tgtView->SetUp( x, y, z );
783 refView->Eye( x, y, z ); tgtView->SetEye( x, y, z );
784 refView->Proj( x, y, z ); tgtView->SetProj( x, y, z );
785 refView->Center( x, y ); tgtView->SetCenter( x, y );
786 tgtView->SetScale( refView->Scale() );
787 tgtView->SetTwist( refView->Twist() );
791 tgtView->SetImmediateUpdate( Standard_True );