2 # ifndef GLX_GLXEXT_LEGACY
3 # define GLX_GLXEXT_LEGACY
12 #include "XGUI_ViewPort.h"
13 #include "XGUI_ViewWindow.h"
14 #include "XGUI_Viewer.h"
15 #include "XGUI_Constants.h"
17 #include <QGuiApplication>
18 #include <QPaintEvent>
22 #include <V3d_OrthographicView.hxx>
23 #include <V3d_PerspectiveView.hxx>
24 #include <Visual3d_View.hxx>
27 #include <WNT_Window.hxx>
29 #include <Xw_Window.hxx>
34 static double rx = 0.;
35 static double ry = 0.;
38 static Standard_Boolean zRotation = Standard_False;
41 Create native view window for CasCade view [ static ]
43 Handle(Aspect_Window) CreateCasWindow(const Handle(V3d_View)& view, WId winId)
45 Aspect_Handle aWindowHandle = (Aspect_Handle) winId;
47 Handle(WNT_Window) viewWindow = new WNT_Window(aWindowHandle);
49 Handle(Aspect_DisplayConnection) aDispConnection = view->Viewer()->Driver()->GetDisplayConnection();
50 Handle(Xw_Window) viewWindow = new Xw_Window( aDispConnection, aWindowHandle );
55 class OpenGLUtils_FrameBuffer
58 OpenGLUtils_FrameBuffer();
59 ~OpenGLUtils_FrameBuffer();
61 bool init(const GLsizei&, const GLsizei&);
77 #define APIENTRYP APIENTRY *
80 #ifndef GL_FRAMEBUFFER_EXT
81 #define GL_FRAMEBUFFER_EXT 0x8D40
84 #ifndef GL_RENDERBUFFER_EXT
85 #define GL_RENDERBUFFER_EXT 0x8D41
88 #ifndef GL_COLOR_ATTACHMENT0_EXT
89 #define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
92 #ifndef GL_DEPTH_ATTACHMENT_EXT
93 #define GL_DEPTH_ATTACHMENT_EXT 0x8D00
96 #ifndef GL_FRAMEBUFFER_COMPLETE_EXT
97 #define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
100 typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC)(GLsizei n, GLuint *framebuffers);
101 typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC)(GLenum target, GLuint framebuffer);
102 typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)(GLenum target, GLenum attachment,
103 GLenum textarget, GLuint texture,
105 typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target);
106 typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC)(GLsizei n, const GLuint *framebuffers);
107 typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC)(GLsizei n, GLuint *renderbuffers);
108 typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC)(GLenum target, GLuint renderbuffer);
109 typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target, GLenum internalformat,
110 GLsizei width, GLsizei height);
111 typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)(GLenum target, GLenum attachment,
112 GLenum renderbuffertarget,
113 GLuint renderbuffer);
114 typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC)(GLsizei n, const GLuint *renderbuffers);
116 static PFNGLGENFRAMEBUFFERSEXTPROC vglGenFramebuffersEXT = NULL;
117 static PFNGLBINDFRAMEBUFFEREXTPROC vglBindFramebufferEXT = NULL;
118 static PFNGLFRAMEBUFFERTEXTURE2DEXTPROC vglFramebufferTexture2DEXT = NULL;
119 static PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC vglCheckFramebufferStatusEXT = NULL;
120 static PFNGLDELETEFRAMEBUFFERSEXTPROC vglDeleteFramebuffersEXT = NULL;
121 static PFNGLGENRENDERBUFFERSEXTPROC vglGenRenderbuffersEXT = NULL;
122 static PFNGLBINDRENDERBUFFEREXTPROC vglBindRenderbufferEXT = NULL;
123 static PFNGLRENDERBUFFERSTORAGEEXTPROC vglRenderbufferStorageEXT = NULL;
124 static PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC vglFramebufferRenderbufferEXT = NULL;
125 static PFNGLDELETERENDERBUFFERSEXTPROC vglDeleteRenderbuffersEXT = NULL;
128 #define GL_GetProcAddress( x ) glXGetProcAddressARB( (const GLubyte*)x )
130 #define GL_GetProcAddress( x ) wglGetProcAddress( (const LPCSTR)x )
135 vglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) GL_GetProcAddress("glGenFramebuffersEXT");
136 vglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) GL_GetProcAddress("glBindFramebufferEXT");
137 vglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) GL_GetProcAddress(
138 "glFramebufferTexture2DEXT");
139 vglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) GL_GetProcAddress(
140 "glCheckFramebufferStatusEXT");
141 vglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) GL_GetProcAddress(
142 "glDeleteFramebuffersEXT");
143 vglGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) GL_GetProcAddress(
144 "glGenRenderbuffersEXT");
145 vglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) GL_GetProcAddress(
146 "glBindRenderbufferEXT");
147 vglRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) GL_GetProcAddress(
148 "glRenderbufferStorageEXT");
149 vglFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) GL_GetProcAddress(
150 "glFramebufferRenderbufferEXT");
151 vglDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) GL_GetProcAddress(
152 "glDeleteRenderbuffersEXT");
154 bool ok = vglGenFramebuffersEXT && vglBindFramebufferEXT && vglFramebufferTexture2DEXT
155 && vglCheckFramebufferStatusEXT && vglDeleteFramebuffersEXT && vglGenRenderbuffersEXT
156 && vglBindRenderbufferEXT && vglRenderbufferStorageEXT && vglFramebufferRenderbufferEXT
157 && vglDeleteRenderbuffersEXT;
162 static bool IsEXTInitialized = InitializeEXT();
164 OpenGLUtils_FrameBuffer::OpenGLUtils_FrameBuffer()
165 : textureId(0), fboId(0), rboId(0)
169 OpenGLUtils_FrameBuffer::~OpenGLUtils_FrameBuffer()
174 bool OpenGLUtils_FrameBuffer::init(const GLsizei& xSize, const GLsizei& ySize)
176 char* ext = (char*) glGetString(GL_EXTENSIONS);
177 if (!IsEXTInitialized || strstr(ext, "GL_EXT_framebuffer_object") == NULL) {
178 qDebug( "Initializing OpenGL FrameBuffer extension failed");
182 // create a texture object
183 glEnable (GL_TEXTURE_2D);
184 glGenTextures(1, &textureId);
185 glBindTexture(GL_TEXTURE_2D, textureId);
186 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
187 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
188 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, xSize, ySize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
189 glBindTexture(GL_TEXTURE_2D, 0);
191 // create a renderbuffer object to store depth info
192 vglGenRenderbuffersEXT(1, &rboId);
193 vglBindRenderbufferEXT( GL_RENDERBUFFER_EXT, rboId);
194 vglRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, xSize, ySize);
195 vglBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0);
197 // create a framebuffer object
198 vglGenFramebuffersEXT(1, &fboId);
199 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fboId);
201 // attach the texture to FBO color attachment point
202 vglFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D,
205 // attach the renderbuffer to depth attachment point
206 vglFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
211 GLenum status = vglCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT);
214 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0);
216 return status == GL_FRAMEBUFFER_COMPLETE_EXT;
219 void OpenGLUtils_FrameBuffer::release()
221 if (!IsEXTInitialized)
224 glDeleteTextures(1, &textureId);
227 vglDeleteFramebuffersEXT(1, &fboId);
230 vglDeleteRenderbuffersEXT(1, &rboId);
234 void OpenGLUtils_FrameBuffer::bind()
236 if (!IsEXTInitialized)
239 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fboId);
242 void OpenGLUtils_FrameBuffer::unbind()
244 if (!IsEXTInitialized)
247 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0);
250 //************************************************************************
251 //************************************************************************
252 //************************************************************************
253 XGUI_ViewPort::XGUI_ViewPort(XGUI_ViewWindow* theParent, const Handle(V3d_Viewer)& theViewer,
254 V3d_TypeOfView theType)
255 : QWidget(theParent), myPaintersRedrawing(false), myScale(1.0), myIsAdvancedZoomingEnabled(
258 setMouseTracking(true);
259 setBackgroundRole(QPalette::NoRole);
261 // set focus policy to threat QContextMenuEvent from keyboard
262 setFocusPolicy(Qt::StrongFocus);
263 setAttribute(Qt::WA_PaintOnScreen);
264 setAttribute(Qt::WA_NoSystemBackground);
266 if (theType == V3d_ORTHOGRAPHIC) {
267 myOrthoView = new V3d_OrthographicView(theViewer);
268 myActiveView = myOrthoView;
271 myPerspView = new V3d_PerspectiveView(theViewer);
272 myActiveView = myPerspView;
274 myActiveView->SetSurfaceDetail(V3d_TEX_ALL);
276 //setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
279 //***********************************************
280 XGUI_ViewPort::~XGUI_ViewPort()
284 //***********************************************
285 bool XGUI_ViewPort::mapView(const Handle(V3d_View)& theView)
287 if (!setWindow(theView))
290 if (!mapped(theView)) {
291 theView->SetWindow(myWindow);
292 if (theView != activeView())
293 theView->View()->Deactivate();
296 /* create static trihedron (16551: EDF PAL 501) */
297 //OCCViewer_ViewWindow* aVW = dynamic_cast<OCCViewer_ViewWindow*>( parentWidget()->parentWidget()->parentWidget() );
299 // OCCViewer_Viewer* aViewModel = dynamic_cast<OCCViewer_Viewer*>( aVW->getViewManager()->getViewModel() );
300 // if ( aViewModel && aViewModel->isStaticTrihedronDisplayed() ){
301 //theView->ZBufferTriedronSetup();
302 theView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER);
311 //***********************************************
312 bool XGUI_ViewPort::setWindow(const Handle(V3d_View)& theView)
314 if (!myWindow.IsNull())
317 if (theView.IsNull())
320 attachWindow(theView, CreateCasWindow(theView, winId()));
322 myWindow = theView->Window();
323 return !myWindow.IsNull();
326 //***********************************************
327 bool XGUI_ViewPort::mapped(const Handle(V3d_View)& theView) const
329 return (!theView.IsNull() && theView->View()->IsDefined());
332 //***********************************************
333 void XGUI_ViewPort::updateBackground()
335 if (activeView().IsNull())
337 if (!myBackground.isValid())
340 // VSR: Important note on below code.
341 // In OCCT (in version 6.5.2), things about the background drawing
342 // are not straightforward and not clearly understandable:
343 // - Horizontal gradient is drawn vertically (!), well ok, from top side to bottom one.
344 // - Vertical gradient is drawn horizontally (!), from right side to left one (!!!).
345 // - First and second diagonal gradients are confused.
346 // - Image texture, once set, can not be removed (!).
347 // - Texture image fill mode Aspect_FM_NONE is not taken into account (and means the same
348 // as Aspect_FM_CENTERED).
349 // - The only way to cancel gradient background (and get back to single colored) is to
350 // set gradient background style to Aspect_GFM_NONE while passing two colors is also needed
351 // (see V3d_View::SetBgGradientColors() function).
352 // - Also, it is impossible to draw texture image above the gradiented background (only above
354 // In OCCT 6.5.3 all above mentioned problems are fixed; so, above comment should be removed as soon
355 // as SALOME is migrated to OCCT 6.5.3. The same concerns #ifdef statements in the below code
356 switch(myBackground.mode()) {
357 case XGUI::ColorBackground: {
358 QColor c = myBackground.color();
360 // Unset texture should be done here
362 Quantity_Color qCol(c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB);
363 activeView()->SetBgGradientStyle(Aspect_GFM_NONE); // cancel gradient background
364 activeView()->SetBgImageStyle(Aspect_FM_NONE); // cancel texture background
365 // then change background color
366 activeView()->SetBackgroundColor(qCol);
368 activeView()->Update();
372 case XGUI::SimpleGradientBackground: {
374 int type = myBackground.gradient(c1, c2);
375 if (c1.isValid() && type >= XGUI::HorizontalGradient && type <= XGUI::LastGradient) {
376 // Unset texture should be done here
378 // Get colors and set-up gradiented background
381 Quantity_Color qCol1(c1.red() / 255., c1.green() / 255., c1.blue() / 255., Quantity_TOC_RGB);
382 Quantity_Color qCol2(c2.red() / 255., c2.green() / 255., c2.blue() / 255., Quantity_TOC_RGB);
383 activeView()->SetBgImageStyle(Aspect_FM_NONE); // cancel texture background
385 case XGUI::HorizontalGradient:
386 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_HOR,
389 case XGUI::VerticalGradient:
390 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_VER,
393 case XGUI::Diagonal1Gradient:
394 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG1,
397 case XGUI::Diagonal2Gradient:
398 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG2,
401 case XGUI::Corner1Gradient:
402 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER1,
405 case XGUI::Corner2Gradient:
406 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER2,
409 case XGUI::Corner3Gradient:
410 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER3,
413 case XGUI::Corner4Gradient:
414 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER4,
423 case XGUI::CustomGradientBackground:
424 // NOT IMPLEMENTED YET
429 // VSR: In OCCT before v6.5.3 below code can't be used because of very ugly bug - it has been impossible to
430 // clear the background texture image as soon as it was once set to the viewer.
431 if (myBackground.isTextureShown()) {
433 int textureMode = myBackground.texture(fileName);
434 QFileInfo fi(fileName);
435 if (!fileName.isEmpty() && fi.exists()) {
436 // set texture image: file name and fill mode
437 switch(textureMode) {
438 case XGUI::CenterTexture:
439 activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
442 case XGUI::TileTexture:
443 activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
446 case XGUI::StretchTexture:
447 activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
453 activeView()->Update();
458 //***********************************************
459 void XGUI_ViewPort::attachWindow(const Handle(V3d_View)& theView,
460 const Handle(Aspect_Window)& theWnd)
462 if (!theView.IsNull()) {
463 theView->SetWindow(theWnd);
468 //***********************************************
469 void XGUI_ViewPort::paintEvent(QPaintEvent* theEvent)
472 /* X11 : map before show doesn't work */
473 if ( !mapped( activeView() ) )
474 mapView( activeView() );
476 if (!myWindow.IsNull()) {
477 //QGuiApplication::sync();
478 QRect rc = theEvent->rect();
479 //if ( !myPaintersRedrawing ) {
480 //activeView()->Redraw();
481 activeView()->Redraw(rc.x(), rc.y(), rc.width(), rc.height());
485 //if ( myPaintersRedrawing ) {
486 // QPainter p( this );
487 // //emit vpDrawExternal( &p );
488 // myPaintersRedrawing = false;
492 //***********************************************
493 void XGUI_ViewPort::resizeEvent(QResizeEvent*)
496 /* Win32 : map before first show to avoid flicker */
497 if (!mapped(activeView()))
498 mapView(activeView());
500 //QGuiApplication::sync();
501 if (!activeView().IsNull())
502 activeView()->MustBeResized();
505 //***********************************************
506 QImage XGUI_ViewPort::dumpView(QRect theRect, bool toUpdate)
508 Handle(V3d_View) view = getView();
514 if (theRect.isNull()) {
518 aWidth = theRect.width();
519 aHeight = theRect.height();
521 //QApplication::syncX();
523 OpenGLUtils_FrameBuffer aFrameBuffer;
524 if (aFrameBuffer.init(aWidth, aHeight)) {
525 QImage anImage(aWidth, aHeight, QImage::Format_RGB32);
527 glPushAttrib (GL_VIEWPORT_BIT);
528 glViewport(0, 0, aWidth, aHeight);
533 if (theRect.isNull())
536 view->Redraw(theRect.x(), theRect.y(), theRect.width(), theRect.height());
538 aFrameBuffer.unbind();
542 if (theRect.isNull())
543 glReadPixels(0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits());
545 glReadPixels(theRect.x(), theRect.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE,
547 aFrameBuffer.unbind();
549 anImage = anImage.rgbSwapped();
550 anImage = anImage.mirrored();
553 // if frame buffers are unsupported, use old functionality
554 unsigned char* data = new unsigned char[aWidth * aHeight * 4];
557 if (theRect.isNull()) {
560 p = mapFromParent(geometry().topLeft());
563 view->Redraw(theRect.x(), theRect.y(), theRect.width(), theRect.height());
564 p = theRect.topLeft();
566 glReadPixels(p.x(), p.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, data);
568 QImage anImage(data, aWidth, aHeight, QImage::Format_ARGB32);
569 anImage = anImage.mirrored();
570 anImage = anImage.rgbSwapped();
575 Inits 'rotation' transformation.
577 void XGUI_ViewPort::startRotation(int x, int y, int theRotationPointType,
578 const gp_Pnt& theSelectedPoint)
580 if (!activeView().IsNull()) {
581 switch(theRotationPointType) {
583 activeView()->StartRotation(x, y, 0.45);
590 activeView()->Size(X, Y);
591 rx = Standard_Real(activeView()->Convert(X));
592 ry = Standard_Real(activeView()->Convert(Y));
594 activeView()->Rotate(0., 0., 0., theSelectedPoint.X(), theSelectedPoint.Y(),
595 theSelectedPoint.Z(),
598 Quantity_Ratio zRotationThreshold;
599 zRotation = Standard_False;
600 zRotationThreshold = 0.45;
601 if (zRotationThreshold > 0.) {
602 Standard_Real dx = Abs(sx - rx / 2.);
603 Standard_Real dy = Abs(sy - ry / 2.);
604 Standard_Real dd = zRotationThreshold * (rx + ry) / 2.;
605 if (dx > dd || dy > dd)
606 zRotation = Standard_True;
612 activeView()->DepthFitAll();
617 Rotates the viewport.
619 void XGUI_ViewPort::rotate(int x, int y, int theRotationPointType, const gp_Pnt& theSelectedPoint)
621 if (!activeView().IsNull()) {
622 switch(theRotationPointType) {
624 activeView()->Rotation(x, y);
629 dz = atan2(Standard_Real(x) - rx / 2., ry / 2. - Standard_Real(y))
630 - atan2(sx - rx / 2., ry / 2. - sy);
633 dx = (Standard_Real(x) - sx) * M_PI / rx;
634 dy = (sy - Standard_Real(y)) * M_PI / ry;
638 activeView()->Rotate(dx, dy, dz, theSelectedPoint.X(), theSelectedPoint.Y(),
639 theSelectedPoint.Z(),
645 emit vpTransformed();
647 // setZSize( getZSize() );
651 Resets the viewport after 'rotation'.
653 void XGUI_ViewPort::endRotation()
655 if (!activeView().IsNull()) {
656 activeView()->ZFitAll(1.);
657 activeView()->SetZSize(0.);
658 activeView()->Update();
659 emit vpTransformed();
664 Inits 'zoom' transformation.
666 void XGUI_ViewPort::startZoomAtPoint(int x, int y)
668 if (!activeView().IsNull()/* && isAdvancedZoomingEnabled() */)
669 activeView()->StartZoomAtPoint(x, y);
673 Centers the viewport.
675 void XGUI_ViewPort::setCenter(int x, int y)
677 if (!activeView().IsNull()) {
678 activeView()->Place(x, y, myScale);
679 emit vpTransformed();
684 Called at 'pan' transformation.
686 void XGUI_ViewPort::pan(int dx, int dy)
688 if (!activeView().IsNull()) {
689 activeView()->Pan(dx, dy, 1.0);
690 emit vpTransformed();
695 Called at 'window fit' transformation.
697 void XGUI_ViewPort::fitRect(const QRect& rect)
699 if (!activeView().IsNull()) {
700 activeView()->WindowFit(rect.left(), rect.top(), rect.right(), rect.bottom());
701 emit vpTransformed();
706 Called at 'zoom' transformation.
708 void XGUI_ViewPort::zoom(int x0, int y0, int x, int y)
710 if (!activeView().IsNull()) {
711 if (isAdvancedZoomingEnabled())
712 activeView()->ZoomAtPoint(x0, y0, x, y);
714 activeView()->Zoom(x0 + y0, 0, x + y, 0);
715 emit vpTransformed();
720 Sets the background data
722 void XGUI_ViewPort::setBackground(const XGUI_ViewBackground& bgData)
724 if (bgData.isValid()) {
725 myBackground = bgData;
727 emit vpChangeBackground(myBackground);
731 void XGUI_ViewPort::fitAll(bool theKeepScale, bool theWithZ, bool theUpd)
733 if ( activeView().IsNull() )
737 myScale = activeView()->Scale();
739 Standard_Real aMargin = 0.01;
740 activeView()->FitAll( aMargin, theWithZ, theUpd );
741 activeView()->SetZSize(0.);
742 emit vpTransformed( );
745 void XGUI_ViewPort::syncronizeWith( const XGUI_ViewPort* ref )
747 Handle(V3d_View) refView = ref->getView();
748 Handle(V3d_View) tgtView = getView();
750 /* The following params are copied:
751 - view type( ortho/persp )
752 - position of view point
753 - orientation of high point
754 - position of the eye
761 /* we'll update after setting all params */
762 tgtView->SetImmediateUpdate( Standard_False );
765 if ( refView->Type() == V3d_PERSPECTIVE )
766 tgtView->SetFocale( refView->Focale() );
769 Standard_Real x, y, z;
770 refView->At( x, y, z ); tgtView->SetAt( x, y, z );
771 refView->Up( x, y, z ); tgtView->SetUp( x, y, z );
772 refView->Eye( x, y, z ); tgtView->SetEye( x, y, z );
773 refView->Proj( x, y, z ); tgtView->SetProj( x, y, z );
774 refView->Center( x, y ); tgtView->SetCenter( x, y );
775 tgtView->SetScale( refView->Scale() );
776 tgtView->SetTwist( refView->Twist() );
780 tgtView->SetImmediateUpdate( Standard_True );