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 <QPaintEvent>
21 #include <V3d_OrthographicView.hxx>
22 #include <V3d_PerspectiveView.hxx>
23 #include <Visual3d_View.hxx>
26 #include <WNT_Window.hxx>
28 #include <Xw_Window.hxx>
33 static double rx = 0.;
34 static double ry = 0.;
37 static Standard_Boolean zRotation = Standard_False;
40 Create native view window for CasCade view [ static ]
42 Handle(Aspect_Window) CreateCasWindow(const Handle(V3d_View)& view, WId winId)
44 Aspect_Handle aWindowHandle = (Aspect_Handle) winId;
46 Handle(WNT_Window) viewWindow = new WNT_Window(aWindowHandle);
48 Handle(Aspect_DisplayConnection) aDispConnection = view->Viewer()->Driver()->GetDisplayConnection();
49 Handle(Xw_Window) viewWindow = new Xw_Window( aDispConnection, aWindowHandle );
54 class OpenGLUtils_FrameBuffer
57 OpenGLUtils_FrameBuffer();
58 ~OpenGLUtils_FrameBuffer();
60 bool init(const GLsizei&, const GLsizei&);
76 #define APIENTRYP APIENTRY *
79 #ifndef GL_FRAMEBUFFER_EXT
80 #define GL_FRAMEBUFFER_EXT 0x8D40
83 #ifndef GL_RENDERBUFFER_EXT
84 #define GL_RENDERBUFFER_EXT 0x8D41
87 #ifndef GL_COLOR_ATTACHMENT0_EXT
88 #define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
91 #ifndef GL_DEPTH_ATTACHMENT_EXT
92 #define GL_DEPTH_ATTACHMENT_EXT 0x8D00
95 #ifndef GL_FRAMEBUFFER_COMPLETE_EXT
96 #define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
99 typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC)(GLsizei n, GLuint *framebuffers);
100 typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC)(GLenum target, GLuint framebuffer);
101 typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)(GLenum target, GLenum attachment,
102 GLenum textarget, GLuint texture,
104 typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target);
105 typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC)(GLsizei n, const GLuint *framebuffers);
106 typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC)(GLsizei n, GLuint *renderbuffers);
107 typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC)(GLenum target, GLuint renderbuffer);
108 typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target, GLenum internalformat,
109 GLsizei width, GLsizei height);
110 typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)(GLenum target, GLenum attachment,
111 GLenum renderbuffertarget,
112 GLuint renderbuffer);
113 typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC)(GLsizei n, const GLuint *renderbuffers);
115 static PFNGLGENFRAMEBUFFERSEXTPROC vglGenFramebuffersEXT = NULL;
116 static PFNGLBINDFRAMEBUFFEREXTPROC vglBindFramebufferEXT = NULL;
117 static PFNGLFRAMEBUFFERTEXTURE2DEXTPROC vglFramebufferTexture2DEXT = NULL;
118 static PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC vglCheckFramebufferStatusEXT = NULL;
119 static PFNGLDELETEFRAMEBUFFERSEXTPROC vglDeleteFramebuffersEXT = NULL;
120 static PFNGLGENRENDERBUFFERSEXTPROC vglGenRenderbuffersEXT = NULL;
121 static PFNGLBINDRENDERBUFFEREXTPROC vglBindRenderbufferEXT = NULL;
122 static PFNGLRENDERBUFFERSTORAGEEXTPROC vglRenderbufferStorageEXT = NULL;
123 static PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC vglFramebufferRenderbufferEXT = NULL;
124 static PFNGLDELETERENDERBUFFERSEXTPROC vglDeleteRenderbuffersEXT = NULL;
127 #define GL_GetProcAddress( x ) glXGetProcAddressARB( (const GLubyte*)x )
129 #define GL_GetProcAddress( x ) wglGetProcAddress( (const LPCSTR)x )
134 vglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) GL_GetProcAddress("glGenFramebuffersEXT");
135 vglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) GL_GetProcAddress("glBindFramebufferEXT");
136 vglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) GL_GetProcAddress(
137 "glFramebufferTexture2DEXT");
138 vglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) GL_GetProcAddress(
139 "glCheckFramebufferStatusEXT");
140 vglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) GL_GetProcAddress(
141 "glDeleteFramebuffersEXT");
142 vglGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) GL_GetProcAddress(
143 "glGenRenderbuffersEXT");
144 vglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) GL_GetProcAddress(
145 "glBindRenderbufferEXT");
146 vglRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) GL_GetProcAddress(
147 "glRenderbufferStorageEXT");
148 vglFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) GL_GetProcAddress(
149 "glFramebufferRenderbufferEXT");
150 vglDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) GL_GetProcAddress(
151 "glDeleteRenderbuffersEXT");
153 bool ok = vglGenFramebuffersEXT && vglBindFramebufferEXT && vglFramebufferTexture2DEXT
154 && vglCheckFramebufferStatusEXT && vglDeleteFramebuffersEXT && vglGenRenderbuffersEXT
155 && vglBindRenderbufferEXT && vglRenderbufferStorageEXT && vglFramebufferRenderbufferEXT
156 && vglDeleteRenderbuffersEXT;
161 static bool IsEXTInitialized = InitializeEXT();
163 OpenGLUtils_FrameBuffer::OpenGLUtils_FrameBuffer()
164 : textureId(0), fboId(0), rboId(0)
168 OpenGLUtils_FrameBuffer::~OpenGLUtils_FrameBuffer()
173 bool OpenGLUtils_FrameBuffer::init(const GLsizei& xSize, const GLsizei& ySize)
175 char* ext = (char*) glGetString(GL_EXTENSIONS);
176 if (!IsEXTInitialized || strstr(ext, "GL_EXT_framebuffer_object") == NULL) {
177 qDebug( "Initializing OpenGL FrameBuffer extension failed");
181 // create a texture object
182 glEnable (GL_TEXTURE_2D);
183 glGenTextures(1, &textureId);
184 glBindTexture(GL_TEXTURE_2D, textureId);
185 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
186 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
187 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, xSize, ySize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
188 glBindTexture(GL_TEXTURE_2D, 0);
190 // create a renderbuffer object to store depth info
191 vglGenRenderbuffersEXT(1, &rboId);
192 vglBindRenderbufferEXT( GL_RENDERBUFFER_EXT, rboId);
193 vglRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, xSize, ySize);
194 vglBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0);
196 // create a framebuffer object
197 vglGenFramebuffersEXT(1, &fboId);
198 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fboId);
200 // attach the texture to FBO color attachment point
201 vglFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D,
204 // attach the renderbuffer to depth attachment point
205 vglFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
210 GLenum status = vglCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT);
213 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0);
215 return status == GL_FRAMEBUFFER_COMPLETE_EXT;
218 void OpenGLUtils_FrameBuffer::release()
220 if (!IsEXTInitialized)
223 glDeleteTextures(1, &textureId);
226 vglDeleteFramebuffersEXT(1, &fboId);
229 vglDeleteRenderbuffersEXT(1, &rboId);
233 void OpenGLUtils_FrameBuffer::bind()
235 if (!IsEXTInitialized)
238 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fboId);
241 void OpenGLUtils_FrameBuffer::unbind()
243 if (!IsEXTInitialized)
246 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0);
249 //************************************************************************
250 //************************************************************************
251 //************************************************************************
252 XGUI_ViewPort::XGUI_ViewPort(XGUI_ViewWindow* theParent,
253 const Handle(V3d_Viewer)& theViewer,
254 V3d_TypeOfView theType)
255 : QWidget(theParent),
256 myPaintersRedrawing(false),
258 myIsAdvancedZoomingEnabled(false),
262 setMouseTracking(true);
263 setBackgroundRole(QPalette::NoRole);
265 // set focus policy to threat QContextMenuEvent from keyboard
266 setFocusPolicy(Qt::StrongFocus);
267 setAttribute(Qt::WA_PaintOnScreen);
268 setAttribute(Qt::WA_NoSystemBackground);
270 if (theType == V3d_ORTHOGRAPHIC) {
271 myOrthoView = new V3d_OrthographicView(theViewer);
272 myActiveView = myOrthoView;
275 myPerspView = new V3d_PerspectiveView(theViewer);
276 myActiveView = myPerspView;
278 myActiveView->SetSurfaceDetail(V3d_TEX_ALL);
281 //***********************************************
282 XGUI_ViewPort::~XGUI_ViewPort()
286 //***********************************************
287 bool XGUI_ViewPort::mapView(const Handle(V3d_View)& theView)
289 if (!setWindow(theView))
292 if (!mapped(theView)) {
293 theView->SetWindow(myWindow);
294 if (theView != activeView())
295 theView->View()->Deactivate();
298 /* create static trihedron (16551: EDF PAL 501) */
299 //OCCViewer_ViewWindow* aVW = dynamic_cast<OCCViewer_ViewWindow*>( parentWidget()->parentWidget()->parentWidget() );
301 // OCCViewer_Viewer* aViewModel = dynamic_cast<OCCViewer_Viewer*>( aVW->getViewManager()->getViewModel() );
302 // if ( aViewModel && aViewModel->isStaticTrihedronDisplayed() ){
303 //theView->ZBufferTriedronSetup();
304 theView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER);
313 //***********************************************
314 bool XGUI_ViewPort::setWindow(const Handle(V3d_View)& theView)
316 if (!myWindow.IsNull())
319 if (theView.IsNull())
322 attachWindow(theView, CreateCasWindow(theView, winId()));
324 myWindow = theView->Window();
325 return !myWindow.IsNull();
328 //***********************************************
329 bool XGUI_ViewPort::mapped(const Handle(V3d_View)& theView) const
331 return (!theView.IsNull() && theView->View()->IsDefined());
334 //***********************************************
335 void XGUI_ViewPort::updateBackground()
337 if (activeView().IsNull())
339 if (!myBackground.isValid())
342 // VSR: Important note on below code.
343 // In OCCT (in version 6.5.2), things about the background drawing
344 // are not straightforward and not clearly understandable:
345 // - Horizontal gradient is drawn vertically (!), well ok, from top side to bottom one.
346 // - Vertical gradient is drawn horizontally (!), from right side to left one (!!!).
347 // - First and second diagonal gradients are confused.
348 // - Image texture, once set, can not be removed (!).
349 // - Texture image fill mode Aspect_FM_NONE is not taken into account (and means the same
350 // as Aspect_FM_CENTERED).
351 // - The only way to cancel gradient background (and get back to single colored) is to
352 // set gradient background style to Aspect_GFM_NONE while passing two colors is also needed
353 // (see V3d_View::SetBgGradientColors() function).
354 // - Also, it is impossible to draw texture image above the gradiented background (only above
356 // In OCCT 6.5.3 all above mentioned problems are fixed; so, above comment should be removed as soon
357 // as SALOME is migrated to OCCT 6.5.3. The same concerns #ifdef statements in the below code
358 switch(myBackground.mode()) {
359 case XGUI::ColorBackground: {
360 QColor c = myBackground.color();
362 // Unset texture should be done here
364 Quantity_Color qCol(c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB);
365 activeView()->SetBgGradientStyle(Aspect_GFM_NONE); // cancel gradient background
366 activeView()->SetBgImageStyle(Aspect_FM_NONE); // cancel texture background
367 // then change background color
368 activeView()->SetBackgroundColor(qCol);
370 activeView()->Update();
374 case XGUI::SimpleGradientBackground: {
376 int type = myBackground.gradient(c1, c2);
377 if (c1.isValid() && type >= XGUI::HorizontalGradient && type <= XGUI::LastGradient) {
378 // Unset texture should be done here
380 // Get colors and set-up gradiented background
383 Quantity_Color qCol1(c1.red() / 255., c1.green() / 255., c1.blue() / 255., Quantity_TOC_RGB);
384 Quantity_Color qCol2(c2.red() / 255., c2.green() / 255., c2.blue() / 255., Quantity_TOC_RGB);
385 activeView()->SetBgImageStyle(Aspect_FM_NONE); // cancel texture background
387 case XGUI::HorizontalGradient:
388 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_HOR,
391 case XGUI::VerticalGradient:
392 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_VER,
395 case XGUI::Diagonal1Gradient:
396 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG1,
399 case XGUI::Diagonal2Gradient:
400 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG2,
403 case XGUI::Corner1Gradient:
404 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER1,
407 case XGUI::Corner2Gradient:
408 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER2,
411 case XGUI::Corner3Gradient:
412 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER3,
415 case XGUI::Corner4Gradient:
416 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER4,
425 case XGUI::CustomGradientBackground:
426 // NOT IMPLEMENTED YET
431 // VSR: In OCCT before v6.5.3 below code can't be used because of very ugly bug - it has been impossible to
432 // clear the background texture image as soon as it was once set to the viewer.
433 if (myBackground.isTextureShown()) {
435 int textureMode = myBackground.texture(fileName);
436 QFileInfo fi(fileName);
437 if (!fileName.isEmpty() && fi.exists()) {
438 // set texture image: file name and fill mode
439 switch(textureMode) {
440 case XGUI::CenterTexture:
441 activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
444 case XGUI::TileTexture:
445 activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
448 case XGUI::StretchTexture:
449 activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
455 activeView()->Update();
460 //***********************************************
461 void XGUI_ViewPort::attachWindow(const Handle(V3d_View)& theView,
462 const Handle(Aspect_Window)& theWnd)
464 if (!theView.IsNull()) {
465 theView->SetWindow(theWnd);
470 //***********************************************
471 void XGUI_ViewPort::paintEvent(QPaintEvent* theEvent)
474 /* X11 : map before show doesn't work */
475 if ( !mapped( activeView() ) )
476 mapView( activeView() );
478 if (!myWindow.IsNull()) {
479 //QGuiApplication::sync();
480 QRect rc = theEvent->rect();
481 //if ( !myPaintersRedrawing ) {
482 //activeView()->Redraw();
483 activeView()->Redraw(rc.x(), rc.y(), rc.width(), rc.height());
487 //if ( myPaintersRedrawing ) {
488 // QPainter p( this );
489 // //emit vpDrawExternal( &p );
490 // myPaintersRedrawing = false;
494 //***********************************************
495 void XGUI_ViewPort::resizeEvent(QResizeEvent*)
498 /* Win32 : map before first show to avoid flicker */
499 if (!mapped(activeView()))
500 mapView(activeView());
502 //QGuiApplication::sync();
503 if (!activeView().IsNull())
504 activeView()->MustBeResized();
507 //***********************************************
508 QImage XGUI_ViewPort::dumpView(QRect theRect, bool toUpdate)
510 Handle(V3d_View) view = getView();
516 if (theRect.isNull()) {
520 aWidth = theRect.width();
521 aHeight = theRect.height();
523 //QApplication::syncX();
525 OpenGLUtils_FrameBuffer aFrameBuffer;
526 if (aFrameBuffer.init(aWidth, aHeight)) {
527 QImage anImage(aWidth, aHeight, QImage::Format_RGB32);
529 glPushAttrib (GL_VIEWPORT_BIT);
530 glViewport(0, 0, aWidth, aHeight);
535 if (theRect.isNull())
538 view->Redraw(theRect.x(), theRect.y(), theRect.width(), theRect.height());
540 aFrameBuffer.unbind();
544 if (theRect.isNull())
545 glReadPixels(0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits());
547 glReadPixels(theRect.x(), theRect.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE,
549 aFrameBuffer.unbind();
551 anImage = anImage.rgbSwapped();
552 anImage = anImage.mirrored();
555 // if frame buffers are unsupported, use old functionality
556 unsigned char* data = new unsigned char[aWidth * aHeight * 4];
559 if (theRect.isNull()) {
562 p = mapFromParent(geometry().topLeft());
565 view->Redraw(theRect.x(), theRect.y(), theRect.width(), theRect.height());
566 p = theRect.topLeft();
568 glReadPixels(p.x(), p.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, data);
570 QImage anImage(data, aWidth, aHeight, QImage::Format_ARGB32);
571 anImage = anImage.mirrored();
572 anImage = anImage.rgbSwapped();
577 Inits 'rotation' transformation.
579 void XGUI_ViewPort::startRotation(int x, int y, int theRotationPointType,
580 const gp_Pnt& theSelectedPoint)
582 if (!activeView().IsNull()) {
583 switch(theRotationPointType) {
585 activeView()->StartRotation(x, y, 0.45);
592 activeView()->Size(X, Y);
593 rx = Standard_Real(activeView()->Convert(X));
594 ry = Standard_Real(activeView()->Convert(Y));
596 activeView()->Rotate(0., 0., 0., theSelectedPoint.X(), theSelectedPoint.Y(),
597 theSelectedPoint.Z(),
600 Quantity_Ratio zRotationThreshold;
601 zRotation = Standard_False;
602 zRotationThreshold = 0.45;
603 if (zRotationThreshold > 0.) {
604 Standard_Real dx = Abs(sx - rx / 2.);
605 Standard_Real dy = Abs(sy - ry / 2.);
606 Standard_Real dd = zRotationThreshold * (rx + ry) / 2.;
607 if (dx > dd || dy > dd)
608 zRotation = Standard_True;
614 activeView()->DepthFitAll();
619 Rotates the viewport.
621 void XGUI_ViewPort::rotate(int x, int y, int theRotationPointType, const gp_Pnt& theSelectedPoint)
623 if (!activeView().IsNull()) {
624 switch(theRotationPointType) {
626 activeView()->Rotation(x, y);
631 dz = atan2(Standard_Real(x) - rx / 2., ry / 2. - Standard_Real(y))
632 - atan2(sx - rx / 2., ry / 2. - sy);
635 dx = (Standard_Real(x) - sx) * M_PI / rx;
636 dy = (sy - Standard_Real(y)) * M_PI / ry;
640 activeView()->Rotate(dx, dy, dz, theSelectedPoint.X(), theSelectedPoint.Y(),
641 theSelectedPoint.Z(),
647 emit vpTransformed();
649 // setZSize( getZSize() );
653 Resets the viewport after 'rotation'.
655 void XGUI_ViewPort::endRotation()
657 if (!activeView().IsNull()) {
658 activeView()->ZFitAll(1.);
659 activeView()->SetZSize(0.);
660 activeView()->Update();
661 emit vpTransformed();
666 Inits 'zoom' transformation.
668 void XGUI_ViewPort::startZoomAtPoint(int x, int y)
670 if (!activeView().IsNull()/* && isAdvancedZoomingEnabled() */)
671 activeView()->StartZoomAtPoint(x, y);
675 Centers the viewport.
677 void XGUI_ViewPort::setCenter(int x, int y)
679 if (!activeView().IsNull()) {
680 activeView()->Place(x, y, myScale);
681 emit vpTransformed();
686 Called at 'pan' transformation.
688 void XGUI_ViewPort::pan(int dx, int dy)
690 if (!activeView().IsNull()) {
691 activeView()->Pan(dx, dy, 1.0);
692 emit vpTransformed();
697 Called at 'window fit' transformation.
699 void XGUI_ViewPort::fitRect(const QRect& rect)
701 if (!activeView().IsNull()) {
702 activeView()->WindowFit(rect.left(), rect.top(), rect.right(), rect.bottom());
703 emit vpTransformed();
708 Called at 'zoom' transformation.
710 void XGUI_ViewPort::zoom(int x0, int y0, int x, int y)
712 if (!activeView().IsNull()) {
713 if (isAdvancedZoomingEnabled())
714 activeView()->ZoomAtPoint(x0, y0, x, y);
716 activeView()->Zoom(x0 + y0, 0, x + y, 0);
717 emit vpTransformed();
722 Sets the background data
724 void XGUI_ViewPort::setBackground(const XGUI_ViewBackground& bgData)
726 if (bgData.isValid()) {
727 myBackground = bgData;
729 emit vpChangeBackground(myBackground);
733 void XGUI_ViewPort::fitAll(bool theKeepScale, bool theWithZ, bool theUpd)
735 if ( activeView().IsNull() )
739 myScale = activeView()->Scale();
741 Standard_Real aMargin = 0.01;
742 activeView()->FitAll( aMargin, theWithZ, theUpd );
743 activeView()->SetZSize(0.);
744 emit vpTransformed( );
747 void XGUI_ViewPort::syncronizeWith( const XGUI_ViewPort* ref )
749 Handle(V3d_View) refView = ref->getView();
750 Handle(V3d_View) tgtView = getView();
752 /* The following params are copied:
753 - view type( ortho/persp )
754 - position of view point
755 - orientation of high point
756 - position of the eye
763 /* we'll update after setting all params */
764 tgtView->SetImmediateUpdate( Standard_False );
767 if ( refView->Type() == V3d_PERSPECTIVE )
768 tgtView->SetFocale( refView->Focale() );
771 Standard_Real x, y, z;
772 refView->At( x, y, z ); tgtView->SetAt( x, y, z );
773 refView->Up( x, y, z ); tgtView->SetUp( x, y, z );
774 refView->Eye( x, y, z ); tgtView->SetEye( x, y, z );
775 refView->Proj( x, y, z ); tgtView->SetProj( x, y, z );
776 refView->Center( x, y ); tgtView->SetCenter( x, y );
777 tgtView->SetScale( refView->Scale() );
778 tgtView->SetTwist( refView->Twist() );
782 tgtView->SetImmediateUpdate( Standard_True );