6 #include "XGUI_ViewPort.h"
7 #include "XGUI_ViewWindow.h"
8 #include "XGUI_Viewer.h"
9 #include "XGUI_Constants.h"
11 #include <QPaintEvent>
15 #include <V3d_OrthographicView.hxx>
16 #include <V3d_PerspectiveView.hxx>
17 #include <Visual3d_View.hxx>
18 #include <Graphic3d_GraphicDriver.hxx>
21 #include <WNT_Window.hxx>
23 #include <Xw_Window.hxx>
27 //qmetatype.h must be included before any header file that defines Bool
28 //see /QtCore/qmetatype.h:53 for more info
30 # ifndef GLX_GLXEXT_LEGACY
31 # define GLX_GLXEXT_LEGACY
37 static double rx = 0.;
38 static double ry = 0.;
41 static Standard_Boolean zRotation = Standard_False;
44 Create native view window for CasCade view [ static ]
46 Handle(Aspect_Window) CreateCasWindow(const Handle(V3d_View)& view, WId winId)
48 Aspect_Handle aWindowHandle = (Aspect_Handle) winId;
50 Handle(WNT_Window) viewWindow = new WNT_Window(aWindowHandle);
52 Handle(Aspect_DisplayConnection) aDispConnection = view->Viewer()->Driver()->GetDisplayConnection();
53 Handle(Xw_Window) viewWindow = new Xw_Window( aDispConnection, aWindowHandle );
58 class OpenGLUtils_FrameBuffer
61 OpenGLUtils_FrameBuffer();
62 ~OpenGLUtils_FrameBuffer();
64 bool init(const GLsizei&, const GLsizei&);
80 #define APIENTRYP APIENTRY *
83 #ifndef GL_FRAMEBUFFER_EXT
84 #define GL_FRAMEBUFFER_EXT 0x8D40
87 #ifndef GL_RENDERBUFFER_EXT
88 #define GL_RENDERBUFFER_EXT 0x8D41
91 #ifndef GL_COLOR_ATTACHMENT0_EXT
92 #define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
95 #ifndef GL_DEPTH_ATTACHMENT_EXT
96 #define GL_DEPTH_ATTACHMENT_EXT 0x8D00
99 #ifndef GL_FRAMEBUFFER_COMPLETE_EXT
100 #define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
103 typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC)(GLsizei n, GLuint *framebuffers);
104 typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC)(GLenum target, GLuint framebuffer);
105 typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)(GLenum target, GLenum attachment,
106 GLenum textarget, GLuint texture,
108 typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target);
109 typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC)(GLsizei n, const GLuint *framebuffers);
110 typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC)(GLsizei n, GLuint *renderbuffers);
111 typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC)(GLenum target, GLuint renderbuffer);
112 typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target, GLenum internalformat,
113 GLsizei width, GLsizei height);
114 typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)(GLenum target, GLenum attachment,
115 GLenum renderbuffertarget,
116 GLuint renderbuffer);
117 typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC)(GLsizei n, const GLuint *renderbuffers);
119 static PFNGLGENFRAMEBUFFERSEXTPROC vglGenFramebuffersEXT = NULL;
120 static PFNGLBINDFRAMEBUFFEREXTPROC vglBindFramebufferEXT = NULL;
121 static PFNGLFRAMEBUFFERTEXTURE2DEXTPROC vglFramebufferTexture2DEXT = NULL;
122 static PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC vglCheckFramebufferStatusEXT = NULL;
123 static PFNGLDELETEFRAMEBUFFERSEXTPROC vglDeleteFramebuffersEXT = NULL;
124 static PFNGLGENRENDERBUFFERSEXTPROC vglGenRenderbuffersEXT = NULL;
125 static PFNGLBINDRENDERBUFFEREXTPROC vglBindRenderbufferEXT = NULL;
126 static PFNGLRENDERBUFFERSTORAGEEXTPROC vglRenderbufferStorageEXT = NULL;
127 static PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC vglFramebufferRenderbufferEXT = NULL;
128 static PFNGLDELETERENDERBUFFERSEXTPROC vglDeleteRenderbuffersEXT = NULL;
131 #define GL_GetProcAddress( x ) glXGetProcAddressARB( (const GLubyte*)x )
133 #define GL_GetProcAddress( x ) wglGetProcAddress( (const LPCSTR)x )
138 vglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) GL_GetProcAddress("glGenFramebuffersEXT");
139 vglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) GL_GetProcAddress("glBindFramebufferEXT");
140 vglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) GL_GetProcAddress(
141 "glFramebufferTexture2DEXT");
142 vglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) GL_GetProcAddress(
143 "glCheckFramebufferStatusEXT");
144 vglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) GL_GetProcAddress(
145 "glDeleteFramebuffersEXT");
146 vglGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) GL_GetProcAddress(
147 "glGenRenderbuffersEXT");
148 vglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) GL_GetProcAddress(
149 "glBindRenderbufferEXT");
150 vglRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) GL_GetProcAddress(
151 "glRenderbufferStorageEXT");
152 vglFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) GL_GetProcAddress(
153 "glFramebufferRenderbufferEXT");
154 vglDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) GL_GetProcAddress(
155 "glDeleteRenderbuffersEXT");
157 bool ok = vglGenFramebuffersEXT && vglBindFramebufferEXT && vglFramebufferTexture2DEXT
158 && vglCheckFramebufferStatusEXT && vglDeleteFramebuffersEXT && vglGenRenderbuffersEXT
159 && vglBindRenderbufferEXT && vglRenderbufferStorageEXT && vglFramebufferRenderbufferEXT
160 && vglDeleteRenderbuffersEXT;
165 static bool IsEXTInitialized = InitializeEXT();
167 OpenGLUtils_FrameBuffer::OpenGLUtils_FrameBuffer()
168 : textureId(0), fboId(0), rboId(0)
172 OpenGLUtils_FrameBuffer::~OpenGLUtils_FrameBuffer()
177 bool OpenGLUtils_FrameBuffer::init(const GLsizei& xSize, const GLsizei& ySize)
179 char* ext = (char*) glGetString(GL_EXTENSIONS);
180 if (!IsEXTInitialized || strstr(ext, "GL_EXT_framebuffer_object") == NULL) {
181 qDebug( "Initializing OpenGL FrameBuffer extension failed");
185 // create a texture object
186 glEnable (GL_TEXTURE_2D);
187 glGenTextures(1, &textureId);
188 glBindTexture(GL_TEXTURE_2D, textureId);
189 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
190 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
191 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, xSize, ySize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
192 glBindTexture(GL_TEXTURE_2D, 0);
194 // create a renderbuffer object to store depth info
195 vglGenRenderbuffersEXT(1, &rboId);
196 vglBindRenderbufferEXT( GL_RENDERBUFFER_EXT, rboId);
197 vglRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, xSize, ySize);
198 vglBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0);
200 // create a framebuffer object
201 vglGenFramebuffersEXT(1, &fboId);
202 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fboId);
204 // attach the texture to FBO color attachment point
205 vglFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D,
208 // attach the renderbuffer to depth attachment point
209 vglFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
214 GLenum status = vglCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT);
217 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0);
219 return status == GL_FRAMEBUFFER_COMPLETE_EXT;
222 void OpenGLUtils_FrameBuffer::release()
224 if (!IsEXTInitialized)
227 glDeleteTextures(1, &textureId);
230 vglDeleteFramebuffersEXT(1, &fboId);
233 vglDeleteRenderbuffersEXT(1, &rboId);
237 void OpenGLUtils_FrameBuffer::bind()
239 if (!IsEXTInitialized)
242 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fboId);
245 void OpenGLUtils_FrameBuffer::unbind()
247 if (!IsEXTInitialized)
250 vglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0);
253 //************************************************************************
254 //************************************************************************
255 //************************************************************************
256 XGUI_ViewPort::XGUI_ViewPort(XGUI_ViewWindow* theParent,
257 const Handle(V3d_Viewer)& theViewer,
258 V3d_TypeOfView theType)
259 : QWidget(theParent),
260 myPaintersRedrawing(false),
262 myIsAdvancedZoomingEnabled(false),
266 setMouseTracking(true);
267 setBackgroundRole(QPalette::NoRole);
269 // set focus policy to threat QContextMenuEvent from keyboard
270 setFocusPolicy(Qt::StrongFocus);
271 setAttribute(Qt::WA_PaintOnScreen);
272 setAttribute(Qt::WA_NoSystemBackground);
274 if (theType == V3d_ORTHOGRAPHIC) {
275 myOrthoView = new V3d_OrthographicView(theViewer);
276 myActiveView = myOrthoView;
279 myPerspView = new V3d_PerspectiveView(theViewer);
280 myActiveView = myPerspView;
282 myActiveView->SetSurfaceDetail(V3d_TEX_ALL);
285 //***********************************************
286 XGUI_ViewPort::~XGUI_ViewPort()
290 //***********************************************
291 bool XGUI_ViewPort::mapView(const Handle(V3d_View)& theView)
293 if (!setWindow(theView))
296 if (!mapped(theView)) {
297 theView->SetWindow(myWindow);
298 if (theView != activeView())
299 theView->View()->Deactivate();
302 /* create static trihedron (16551: EDF PAL 501) */
303 //OCCViewer_ViewWindow* aVW = dynamic_cast<OCCViewer_ViewWindow*>( parentWidget()->parentWidget()->parentWidget() );
305 // OCCViewer_Viewer* aViewModel = dynamic_cast<OCCViewer_Viewer*>( aVW->getViewManager()->getViewModel() );
306 // if ( aViewModel && aViewModel->isStaticTrihedronDisplayed() ){
307 //theView->ZBufferTriedronSetup();
308 theView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER);
317 //***********************************************
318 bool XGUI_ViewPort::setWindow(const Handle(V3d_View)& theView)
320 if (!myWindow.IsNull())
323 if (theView.IsNull())
326 attachWindow(theView, CreateCasWindow(theView, winId()));
328 myWindow = theView->Window();
329 return !myWindow.IsNull();
332 //***********************************************
333 bool XGUI_ViewPort::mapped(const Handle(V3d_View)& theView) const
335 return (!theView.IsNull() && theView->View()->IsDefined());
338 //***********************************************
339 void XGUI_ViewPort::updateBackground()
341 if (activeView().IsNull())
343 if (!myBackground.isValid())
346 // VSR: Important note on below code.
347 // In OCCT (in version 6.5.2), things about the background drawing
348 // are not straightforward and not clearly understandable:
349 // - Horizontal gradient is drawn vertically (!), well ok, from top side to bottom one.
350 // - Vertical gradient is drawn horizontally (!), from right side to left one (!!!).
351 // - First and second diagonal gradients are confused.
352 // - Image texture, once set, can not be removed (!).
353 // - Texture image fill mode Aspect_FM_NONE is not taken into account (and means the same
354 // as Aspect_FM_CENTERED).
355 // - The only way to cancel gradient background (and get back to single colored) is to
356 // set gradient background style to Aspect_GFM_NONE while passing two colors is also needed
357 // (see V3d_View::SetBgGradientColors() function).
358 // - Also, it is impossible to draw texture image above the gradiented background (only above
360 // In OCCT 6.5.3 all above mentioned problems are fixed; so, above comment should be removed as soon
361 // as SALOME is migrated to OCCT 6.5.3. The same concerns #ifdef statements in the below code
362 switch(myBackground.mode()) {
363 case XGUI::ColorBackground: {
364 QColor c = myBackground.color();
366 // Unset texture should be done here
368 Quantity_Color qCol(c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB);
369 activeView()->SetBgGradientStyle(Aspect_GFM_NONE); // cancel gradient background
370 activeView()->SetBgImageStyle(Aspect_FM_NONE); // cancel texture background
371 // then change background color
372 activeView()->SetBackgroundColor(qCol);
374 activeView()->Update();
378 case XGUI::SimpleGradientBackground: {
380 int type = myBackground.gradient(c1, c2);
381 if (c1.isValid() && type >= XGUI::HorizontalGradient && type <= XGUI::LastGradient) {
382 // Unset texture should be done here
384 // Get colors and set-up gradiented background
387 Quantity_Color qCol1(c1.red() / 255., c1.green() / 255., c1.blue() / 255., Quantity_TOC_RGB);
388 Quantity_Color qCol2(c2.red() / 255., c2.green() / 255., c2.blue() / 255., Quantity_TOC_RGB);
389 activeView()->SetBgImageStyle(Aspect_FM_NONE); // cancel texture background
391 case XGUI::HorizontalGradient:
392 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_HOR,
395 case XGUI::VerticalGradient:
396 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_VER,
399 case XGUI::Diagonal1Gradient:
400 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG1,
403 case XGUI::Diagonal2Gradient:
404 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG2,
407 case XGUI::Corner1Gradient:
408 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER1,
411 case XGUI::Corner2Gradient:
412 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER2,
415 case XGUI::Corner3Gradient:
416 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER3,
419 case XGUI::Corner4Gradient:
420 activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER4,
429 case XGUI::CustomGradientBackground:
430 // NOT IMPLEMENTED YET
435 // VSR: In OCCT before v6.5.3 below code can't be used because of very ugly bug - it has been impossible to
436 // clear the background texture image as soon as it was once set to the viewer.
437 if (myBackground.isTextureShown()) {
439 int textureMode = myBackground.texture(fileName);
440 QFileInfo fi(fileName);
441 if (!fileName.isEmpty() && fi.exists()) {
442 // set texture image: file name and fill mode
443 switch(textureMode) {
444 case XGUI::CenterTexture:
445 activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
448 case XGUI::TileTexture:
449 activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
452 case XGUI::StretchTexture:
453 activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
459 activeView()->Update();
464 //***********************************************
465 void XGUI_ViewPort::attachWindow(const Handle(V3d_View)& theView,
466 const Handle(Aspect_Window)& theWnd)
468 if (!theView.IsNull()) {
469 theView->SetWindow(theWnd);
474 //***********************************************
475 void XGUI_ViewPort::paintEvent(QPaintEvent* theEvent)
478 /* X11 : map before show doesn't work */
479 if ( !mapped( activeView() ) )
480 mapView( activeView() );
482 if (!myWindow.IsNull()) {
483 //QGuiApplication::sync();
484 QRect rc = theEvent->rect();
485 //if ( !myPaintersRedrawing ) {
486 //activeView()->Redraw();
487 activeView()->Redraw(rc.x(), rc.y(), rc.width(), rc.height());
491 //if ( myPaintersRedrawing ) {
492 // QPainter p( this );
493 // //emit vpDrawExternal( &p );
494 // myPaintersRedrawing = false;
498 //***********************************************
499 void XGUI_ViewPort::resizeEvent(QResizeEvent*)
502 /* Win32 : map before first show to avoid flicker */
503 if (!mapped(activeView()))
504 mapView(activeView());
506 //QGuiApplication::sync();
507 if (!activeView().IsNull())
508 activeView()->MustBeResized();
511 //***********************************************
512 QImage XGUI_ViewPort::dumpView(QRect theRect, bool toUpdate)
514 Handle(V3d_View) view = getView();
520 if (theRect.isNull()) {
524 aWidth = theRect.width();
525 aHeight = theRect.height();
527 //QApplication::syncX();
529 OpenGLUtils_FrameBuffer aFrameBuffer;
530 if (aFrameBuffer.init(aWidth, aHeight)) {
531 QImage anImage(aWidth, aHeight, QImage::Format_RGB32);
533 glPushAttrib (GL_VIEWPORT_BIT);
534 glViewport(0, 0, aWidth, aHeight);
539 if (theRect.isNull())
542 view->Redraw(theRect.x(), theRect.y(), theRect.width(), theRect.height());
544 aFrameBuffer.unbind();
548 if (theRect.isNull())
549 glReadPixels(0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits());
551 glReadPixels(theRect.x(), theRect.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE,
553 aFrameBuffer.unbind();
555 anImage = anImage.rgbSwapped();
556 anImage = anImage.mirrored();
559 // if frame buffers are unsupported, use old functionality
560 unsigned char* data = new unsigned char[aWidth * aHeight * 4];
563 if (theRect.isNull()) {
566 p = mapFromParent(geometry().topLeft());
569 view->Redraw(theRect.x(), theRect.y(), theRect.width(), theRect.height());
570 p = theRect.topLeft();
572 glReadPixels(p.x(), p.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, data);
574 QImage anImage(data, aWidth, aHeight, QImage::Format_ARGB32);
575 anImage = anImage.mirrored();
576 anImage = anImage.rgbSwapped();
581 Inits 'rotation' transformation.
583 void XGUI_ViewPort::startRotation(int x, int y, int theRotationPointType,
584 const gp_Pnt& theSelectedPoint)
586 if (!activeView().IsNull()) {
587 switch(theRotationPointType) {
589 activeView()->StartRotation(x, y, 0.45);
596 activeView()->Size(X, Y);
597 rx = Standard_Real(activeView()->Convert(X));
598 ry = Standard_Real(activeView()->Convert(Y));
600 activeView()->Rotate(0., 0., 0., theSelectedPoint.X(), theSelectedPoint.Y(),
601 theSelectedPoint.Z(),
604 Quantity_Ratio zRotationThreshold;
605 zRotation = Standard_False;
606 zRotationThreshold = 0.45;
607 if (zRotationThreshold > 0.) {
608 Standard_Real dx = Abs(sx - rx / 2.);
609 Standard_Real dy = Abs(sy - ry / 2.);
610 Standard_Real dd = zRotationThreshold * (rx + ry) / 2.;
611 if (dx > dd || dy > dd)
612 zRotation = Standard_True;
618 activeView()->DepthFitAll();
623 Rotates the viewport.
625 void XGUI_ViewPort::rotate(int x, int y, int theRotationPointType, const gp_Pnt& theSelectedPoint)
627 if (!activeView().IsNull()) {
628 switch(theRotationPointType) {
630 activeView()->Rotation(x, y);
635 dz = atan2(Standard_Real(x) - rx / 2., ry / 2. - Standard_Real(y))
636 - atan2(sx - rx / 2., ry / 2. - sy);
639 dx = (Standard_Real(x) - sx) * M_PI / rx;
640 dy = (sy - Standard_Real(y)) * M_PI / ry;
644 activeView()->Rotate(dx, dy, dz, theSelectedPoint.X(), theSelectedPoint.Y(),
645 theSelectedPoint.Z(),
651 emit vpTransformed();
653 // setZSize( getZSize() );
657 Resets the viewport after 'rotation'.
659 void XGUI_ViewPort::endRotation()
661 if (!activeView().IsNull()) {
662 activeView()->ZFitAll(1.);
663 activeView()->SetZSize(0.);
664 activeView()->Update();
665 emit vpTransformed();
670 Inits 'zoom' transformation.
672 void XGUI_ViewPort::startZoomAtPoint(int x, int y)
674 if (!activeView().IsNull()/* && isAdvancedZoomingEnabled() */)
675 activeView()->StartZoomAtPoint(x, y);
679 Centers the viewport.
681 void XGUI_ViewPort::setCenter(int x, int y)
683 if (!activeView().IsNull()) {
684 activeView()->Place(x, y, myScale);
685 emit vpTransformed();
690 Called at 'pan' transformation.
692 void XGUI_ViewPort::pan(int dx, int dy)
694 if (!activeView().IsNull()) {
695 activeView()->Pan(dx, dy, 1.0);
696 emit vpTransformed();
701 Called at 'window fit' transformation.
703 void XGUI_ViewPort::fitRect(const QRect& rect)
705 if (!activeView().IsNull()) {
706 activeView()->WindowFit(rect.left(), rect.top(), rect.right(), rect.bottom());
707 emit vpTransformed();
712 Called at 'zoom' transformation.
714 void XGUI_ViewPort::zoom(int x0, int y0, int x, int y)
716 if (!activeView().IsNull()) {
717 if (isAdvancedZoomingEnabled())
718 activeView()->ZoomAtPoint(x0, y0, x, y);
720 activeView()->Zoom(x0 + y0, 0, x + y, 0);
721 emit vpTransformed();
726 Sets the background data
728 void XGUI_ViewPort::setBackground(const XGUI_ViewBackground& bgData)
730 if (bgData.isValid()) {
731 myBackground = bgData;
733 emit vpChangeBackground(myBackground);
737 void XGUI_ViewPort::fitAll(bool theKeepScale, bool theWithZ, bool theUpd)
739 if ( activeView().IsNull() )
743 myScale = activeView()->Scale();
745 Standard_Real aMargin = 0.01;
746 activeView()->FitAll( aMargin, theWithZ, theUpd );
747 activeView()->SetZSize(0.);
748 emit vpTransformed( );
751 void XGUI_ViewPort::syncronizeWith( const XGUI_ViewPort* ref )
753 Handle(V3d_View) refView = ref->getView();
754 Handle(V3d_View) tgtView = getView();
756 /* The following params are copied:
757 - view type( ortho/persp )
758 - position of view point
759 - orientation of high point
760 - position of the eye
767 /* we'll update after setting all params */
768 tgtView->SetImmediateUpdate( Standard_False );
771 if ( refView->Type() == V3d_PERSPECTIVE )
772 tgtView->SetFocale( refView->Focale() );
775 Standard_Real x, y, z;
776 refView->At( x, y, z ); tgtView->SetAt( x, y, z );
777 refView->Up( x, y, z ); tgtView->SetUp( x, y, z );
778 refView->Eye( x, y, z ); tgtView->SetEye( x, y, z );
779 refView->Proj( x, y, z ); tgtView->SetProj( x, y, z );
780 refView->Center( x, y ); tgtView->SetCenter( x, y );
781 tgtView->SetScale( refView->Scale() );
782 tgtView->SetTwist( refView->Twist() );
786 tgtView->SetImmediateUpdate( Standard_True );