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);
277 //***********************************************
278 XGUI_ViewPort::~XGUI_ViewPort()
282 //***********************************************
283 bool XGUI_ViewPort::mapView(const Handle(V3d_View)& theView)
285 if (!setWindow(theView))
288 if (!mapped(theView)) {
289 theView->SetWindow(myWindow);
290 if (theView != activeView())
291 theView->View()->Deactivate();
294 /* create static trihedron (16551: EDF PAL 501) */
295 //OCCViewer_ViewWindow* aVW = dynamic_cast<OCCViewer_ViewWindow*>( parentWidget()->parentWidget()->parentWidget() );
297 // OCCViewer_Viewer* aViewModel = dynamic_cast<OCCViewer_Viewer*>( aVW->getViewManager()->getViewModel() );
298 // if ( aViewModel && aViewModel->isStaticTrihedronDisplayed() ){
299 //theView->ZBufferTriedronSetup();
300 theView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER);
309 //***********************************************
310 bool XGUI_ViewPort::setWindow(const Handle(V3d_View)& theView)
312 if (!myWindow.IsNull())
315 if (theView.IsNull())
318 attachWindow(theView, CreateCasWindow(theView, winId()));
320 myWindow = theView->Window();
321 return !myWindow.IsNull();
324 //***********************************************
325 bool XGUI_ViewPort::mapped(const Handle(V3d_View)& theView) const
327 return (!theView.IsNull() && theView->View()->IsDefined());
330 //***********************************************
331 void XGUI_ViewPort::updateBackground()
333 if (activeView().IsNull())
335 if (!myBackground.isValid())
338 // VSR: Important note on below code.
339 // In OCCT (in version 6.5.2), things about the background drawing
340 // are not straightforward and not clearly understandable:
341 // - Horizontal gradient is drawn vertically (!), well ok, from top side to bottom one.
342 // - Vertical gradient is drawn horizontally (!), from right side to left one (!!!).
343 // - First and second diagonal gradients are confused.
344 // - Image texture, once set, can not be removed (!).
345 // - Texture image fill mode Aspect_FM_NONE is not taken into account (and means the same
346 // as Aspect_FM_CENTERED).
347 // - The only way to cancel gradient background (and get back to single colored) is to
348 // set gradient background style to Aspect_GFM_NONE while passing two colors is also needed
349 // (see V3d_View::SetBgGradientColors() function).
350 // - Also, it is impossible to draw texture image above the gradiented background (only above
352 // In OCCT 6.5.3 all above mentioned problems are fixed; so, above comment should be removed as soon
353 // as SALOME is migrated to OCCT 6.5.3. The same concerns #ifdef statements in the below code
354 switch(myBackground.mode()) {
355 case XGUI::ColorBackground: {
356 QColor c = myBackground.color();
358 // Unset texture should be done here
360 Quantity_Color qCol(c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB);
361 activeView()->SetBgGradientStyle(Aspect_GFM_NONE); // cancel gradient background
362 activeView()->SetBgImageStyle(Aspect_FM_NONE); // cancel texture background
363 // then change background color
364 activeView()->SetBackgroundColor(qCol);
366 activeView()->Update();
370 case XGUI::SimpleGradientBackground: {
372 int type = myBackground.gradient(c1, c2);
373 if (c1.isValid() && type >= XGUI::HorizontalGradient && type <= XGUI::LastGradient) {
374 // Unset texture should be done here
376 // Get colors and set-up gradiented background
379 Quantity_Color qCol1(c1.red() / 255., c1.green() / 255., c1.blue() / 255., Quantity_TOC_RGB);
380 Quantity_Color qCol2(c2.red() / 255., c2.green() / 255., c2.blue() / 255., Quantity_TOC_RGB);
381 activeView()->SetBgImageStyle(Aspect_FM_NONE); // cancel texture background
383 case XGUI::HorizontalGradient:
384 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_HOR,
387 case XGUI::VerticalGradient:
388 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_VER,
391 case XGUI::Diagonal1Gradient:
392 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG1,
395 case XGUI::Diagonal2Gradient:
396 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG2,
399 case XGUI::Corner1Gradient:
400 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER1,
403 case XGUI::Corner2Gradient:
404 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER2,
407 case XGUI::Corner3Gradient:
408 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER3,
411 case XGUI::Corner4Gradient:
412 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER4,
421 case XGUI::CustomGradientBackground:
422 // NOT IMPLEMENTED YET
427 // VSR: In OCCT before v6.5.3 below code can't be used because of very ugly bug - it has been impossible to
428 // clear the background texture image as soon as it was once set to the viewer.
429 if (myBackground.isTextureShown()) {
431 int textureMode = myBackground.texture(fileName);
432 QFileInfo fi(fileName);
433 if (!fileName.isEmpty() && fi.exists()) {
434 // set texture image: file name and fill mode
435 switch(textureMode) {
436 case XGUI::CenterTexture:
437 activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
440 case XGUI::TileTexture:
441 activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
444 case XGUI::StretchTexture:
445 activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
451 activeView()->Update();
456 //***********************************************
457 void XGUI_ViewPort::attachWindow(const Handle(V3d_View)& theView,
458 const Handle(Aspect_Window)& theWnd)
460 if (!theView.IsNull()) {
461 theView->SetWindow(theWnd);
466 //***********************************************
467 void XGUI_ViewPort::paintEvent(QPaintEvent* theEvent)
470 /* X11 : map before show doesn't work */
471 if ( !mapped( activeView() ) )
472 mapView( activeView() );
474 if (!myWindow.IsNull()) {
475 //QGuiApplication::sync();
476 QRect rc = theEvent->rect();
477 //if ( !myPaintersRedrawing ) {
478 //activeView()->Redraw();
479 activeView()->Redraw(rc.x(), rc.y(), rc.width(), rc.height());
483 //if ( myPaintersRedrawing ) {
484 // QPainter p( this );
485 // //emit vpDrawExternal( &p );
486 // myPaintersRedrawing = false;
490 //***********************************************
491 void XGUI_ViewPort::resizeEvent(QResizeEvent*)
494 /* Win32 : map before first show to avoid flicker */
495 if (!mapped(activeView()))
496 mapView(activeView());
498 //QGuiApplication::sync();
499 if (!activeView().IsNull())
500 activeView()->MustBeResized();
503 //***********************************************
504 QImage XGUI_ViewPort::dumpView(QRect theRect, bool toUpdate)
506 Handle(V3d_View) view = getView();
512 if (theRect.isNull()) {
516 aWidth = theRect.width();
517 aHeight = theRect.height();
519 //QApplication::syncX();
521 OpenGLUtils_FrameBuffer aFrameBuffer;
522 if (aFrameBuffer.init(aWidth, aHeight)) {
523 QImage anImage(aWidth, aHeight, QImage::Format_RGB32);
525 glPushAttrib (GL_VIEWPORT_BIT);
526 glViewport(0, 0, aWidth, aHeight);
531 if (theRect.isNull())
534 view->Redraw(theRect.x(), theRect.y(), theRect.width(), theRect.height());
536 aFrameBuffer.unbind();
540 if (theRect.isNull())
541 glReadPixels(0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits());
543 glReadPixels(theRect.x(), theRect.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE,
545 aFrameBuffer.unbind();
547 anImage = anImage.rgbSwapped();
548 anImage = anImage.mirrored();
551 // if frame buffers are unsupported, use old functionality
552 unsigned char* data = new unsigned char[aWidth * aHeight * 4];
555 if (theRect.isNull()) {
558 p = mapFromParent(geometry().topLeft());
561 view->Redraw(theRect.x(), theRect.y(), theRect.width(), theRect.height());
562 p = theRect.topLeft();
564 glReadPixels(p.x(), p.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, data);
566 QImage anImage(data, aWidth, aHeight, QImage::Format_ARGB32);
567 anImage = anImage.mirrored();
568 anImage = anImage.rgbSwapped();
573 Inits 'rotation' transformation.
575 void XGUI_ViewPort::startRotation(int x, int y, int theRotationPointType,
576 const gp_Pnt& theSelectedPoint)
578 if (!activeView().IsNull()) {
579 switch(theRotationPointType) {
581 activeView()->StartRotation(x, y, 0.45);
588 activeView()->Size(X, Y);
589 rx = Standard_Real(activeView()->Convert(X));
590 ry = Standard_Real(activeView()->Convert(Y));
592 activeView()->Rotate(0., 0., 0., theSelectedPoint.X(), theSelectedPoint.Y(),
593 theSelectedPoint.Z(),
596 Quantity_Ratio zRotationThreshold;
597 zRotation = Standard_False;
598 zRotationThreshold = 0.45;
599 if (zRotationThreshold > 0.) {
600 Standard_Real dx = Abs(sx - rx / 2.);
601 Standard_Real dy = Abs(sy - ry / 2.);
602 Standard_Real dd = zRotationThreshold * (rx + ry) / 2.;
603 if (dx > dd || dy > dd)
604 zRotation = Standard_True;
610 activeView()->DepthFitAll();
615 Rotates the viewport.
617 void XGUI_ViewPort::rotate(int x, int y, int theRotationPointType, const gp_Pnt& theSelectedPoint)
619 if (!activeView().IsNull()) {
620 switch(theRotationPointType) {
622 activeView()->Rotation(x, y);
627 dz = atan2(Standard_Real(x) - rx / 2., ry / 2. - Standard_Real(y))
628 - atan2(sx - rx / 2., ry / 2. - sy);
631 dx = (Standard_Real(x) - sx) * M_PI / rx;
632 dy = (sy - Standard_Real(y)) * M_PI / ry;
636 activeView()->Rotate(dx, dy, dz, theSelectedPoint.X(), theSelectedPoint.Y(),
637 theSelectedPoint.Z(),
643 emit vpTransformed();
645 // setZSize( getZSize() );
649 Resets the viewport after 'rotation'.
651 void XGUI_ViewPort::endRotation()
653 if (!activeView().IsNull()) {
654 activeView()->ZFitAll(1.);
655 activeView()->SetZSize(0.);
656 activeView()->Update();
657 emit vpTransformed();
662 Inits 'zoom' transformation.
664 void XGUI_ViewPort::startZoomAtPoint(int x, int y)
666 if (!activeView().IsNull()/* && isAdvancedZoomingEnabled() */)
667 activeView()->StartZoomAtPoint(x, y);
671 Centers the viewport.
673 void XGUI_ViewPort::setCenter(int x, int y)
675 if (!activeView().IsNull()) {
676 activeView()->Place(x, y, myScale);
677 emit vpTransformed();
682 Called at 'pan' transformation.
684 void XGUI_ViewPort::pan(int dx, int dy)
686 if (!activeView().IsNull()) {
687 activeView()->Pan(dx, dy, 1.0);
688 emit vpTransformed();
693 Called at 'window fit' transformation.
695 void XGUI_ViewPort::fitRect(const QRect& rect)
697 if (!activeView().IsNull()) {
698 activeView()->WindowFit(rect.left(), rect.top(), rect.right(), rect.bottom());
699 emit vpTransformed();
704 Called at 'zoom' transformation.
706 void XGUI_ViewPort::zoom(int x0, int y0, int x, int y)
708 if (!activeView().IsNull()) {
709 if (isAdvancedZoomingEnabled())
710 activeView()->ZoomAtPoint(x0, y0, x, y);
712 activeView()->Zoom(x0 + y0, 0, x + y, 0);
713 emit vpTransformed();
718 Sets the background data
720 void XGUI_ViewPort::setBackground(const XGUI_ViewBackground& bgData)
722 if (bgData.isValid()) {
723 myBackground = bgData;
725 emit vpChangeBackground(myBackground);
729 void XGUI_ViewPort::fitAll(bool theKeepScale, bool theWithZ, bool theUpd)
731 if ( activeView().IsNull() )
735 myScale = activeView()->Scale();
737 Standard_Real aMargin = 0.01;
738 activeView()->FitAll( aMargin, theWithZ, theUpd );
739 activeView()->SetZSize(0.);
740 emit vpTransformed( );
743 void XGUI_ViewPort::syncronizeWith( const XGUI_ViewPort* ref )
745 Handle(V3d_View) refView = ref->getView();
746 Handle(V3d_View) tgtView = getView();
748 /* The following params are copied:
749 - view type( ortho/persp )
750 - position of view point
751 - orientation of high point
752 - position of the eye
759 /* we'll update after setting all params */
760 tgtView->SetImmediateUpdate( Standard_False );
763 if ( refView->Type() == V3d_PERSPECTIVE )
764 tgtView->SetFocale( refView->Focale() );
767 Standard_Real x, y, z;
768 refView->At( x, y, z ); tgtView->SetAt( x, y, z );
769 refView->Up( x, y, z ); tgtView->SetUp( x, y, z );
770 refView->Eye( x, y, z ); tgtView->SetEye( x, y, z );
771 refView->Proj( x, y, z ); tgtView->SetProj( x, y, z );
772 refView->Center( x, y ); tgtView->SetCenter( x, y );
773 tgtView->SetScale( refView->Scale() );
774 tgtView->SetTwist( refView->Twist() );
778 tgtView->SetImmediateUpdate( Standard_True );