From: azn Date: Fri, 19 Dec 2014 09:06:11 +0000 (+0300) Subject: 0025619: CAST analysis: Avoid classes with a non-empty destructor and not implementin... X-Git-Tag: V6_9_0~47 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=96f3baccc551c4b4ad0f515d7df303db8983592e 0025619: CAST analysis: Avoid classes with a non-empty destructor and not implementing both an assignment operator and a copy constructor - Fix compilation errors. - Branch has been rebased on new master. 0025619: CAST analysis: Avoid classes with a non-empty destructor and not implementing both an assignment operator and a copy constructor The problem has been removed from following classes: - tsee_entity - Select3D_PointData - Standard_MMgrFactory - ProjLib_OnSurface - BinomAllocator - OSD_PerfMeter - StorageInfo - OpenGl_UnpackAlignmentSentry - IntPatch_InfoPD - TableauRejection - Draw_View - BOPTest_Session - BOPCol_MemBlock - BSB_T3Bits - NCollection_Handle::Ptr - Buffer (from Standard_Boolean Message_MsgFile::LoadFile (const Standard_CString)) --- diff --git a/src/BOPTest/BOPTest_Objects.cxx b/src/BOPTest/BOPTest_Objects.cxx index 5c45f9e84b..4aa124c50c 100644 --- a/src/BOPTest/BOPTest_Objects.cxx +++ b/src/BOPTest/BOPTest_Objects.cxx @@ -110,7 +110,12 @@ class BOPTest_Session { return myFuzzyValue; }; // - protected: +protected: + // + BOPTest_Session(const BOPTest_Session&); + BOPTest_Session& operator=(const BOPTest_Session&); + // +protected: // BOPAlgo_PaveFiller* myPaveFiller; BOPAlgo_Builder* myBuilder; diff --git a/src/Draw/Draw_View.cxx b/src/Draw/Draw_View.cxx new file mode 100644 index 0000000000..cedc2a0ab8 --- /dev/null +++ b/src/Draw/Draw_View.cxx @@ -0,0 +1,406 @@ +#include +#include + +#include + +//======================================================================= +//function : Draw_View +//purpose : Constructor +//======================================================================= +Draw_View::Draw_View(Standard_Integer theId, + Draw_Viewer* theViewer, + Standard_Integer theX, + Standard_Integer theY, + Standard_Integer theWidth, + Standard_Integer theHeight) +: Draw_Window("Win", theX, theY, theWidth, theHeight), + myId (theId), + myViewer (theViewer), + myIsPers (Standard_False), + myIs2D (Standard_False), + myFocalDistance(0.0), + myZoom (0.0), + myDx (0), + myDy (0), + myFrameX0 (0), + myFrameY0 (0), + myFrameX1 (0), + myFrameY1 (0) +{ +} + +//======================================================================= +//function : Draw_View +//purpose : Constructor +//======================================================================= +#if defined(_WIN32) || defined(__WIN32__) +Draw_View::Draw_View(Standard_Integer theId, + Draw_Viewer* theViewer, + Standard_Integer theX, + Standard_Integer theY, + Standard_Integer theWidth, + Standard_Integer theHeight, + HWND theWindow) +: Draw_Window("Win", theX, theY, theWidth, theHeight, theWindow), + myId (theId), + myViewer (theViewer), + myIsPers (Standard_False), + myIs2D (Standard_False), + myFocalDistance(0.0), + myZoom (0.0), + myDx (0), + myDy (0), + myFrameX0 (0), + myFrameY0 (0), + myFrameX1 (0), + myFrameY1 (0) +{ +} + +//======================================================================= +//function : Draw_View +//purpose : Constructor +//======================================================================= +#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) +Draw_View::Draw_View(Standard_Integer theId, + Draw_Viewer* theViewer, + Standard_Integer theX, + Standard_Integer theY, + Standard_Integer theWidth, + Standard_Integer theHeight, + NSWindow* theWindow) +: Draw_Window(theWindow, "Win", theX, theY, theWidth, theHeight), + myId (theId), + myViewer (theViewer), + myIsPers (Standard_False), + myIs2D (Standard_False), + myFocalDistance(0.0), + myZoom (0.0), + myDx (0), + myDy (0), + myFrameX0 (0), + myFrameY0 (0), + myFrameX1 (0), + myFrameY1 (0) +{ +} +#endif + + +//======================================================================= +//function : Draw_View +//purpose : Constructor +//======================================================================= +#if defined(_WIN32) || defined (__WIN32__) || (defined(__APPLE__) && !defined(MACOSX_USE_GLX)) +Draw_View::Draw_View(Standard_Integer /*theId*/, + Draw_Viewer* /*theViewer*/, + const char* /*theTitle*/) +: Draw_Window (), + myId (-1), + myViewer (NULL), +#else +Draw_View::Draw_View(Standard_Integer theId, + Draw_Viewer* theViewer, + const char* theTitle) +: Draw_Window (theTitle), + myId (theId), + myViewer (theViewer), +#endif + myIsPers (Standard_False), + myIs2D (Standard_False), + myFocalDistance(0.0), + myZoom (0.0), + myDx (0), + myDy (0), + myFrameX0 (0), + myFrameY0 (0), + myFrameX1 (0), + myFrameY1 (0) +{ +} + +//======================================================================= +//function : ~Draw_View +//purpose : Destructor +//======================================================================= +Draw_View::~Draw_View() +{ + Draw_Window::Destroy(); +} + +//======================================================================= +//function : Init +//purpose : +//======================================================================= +Standard_Boolean Draw_View::Init(const char* theType) +{ + { // default fields + myFocalDistance = 500.; + myIsPers = Standard_False; + myIs2D = strcmp("-2D-", theType) ? Standard_False : Standard_True; + myZoom = 1; + + ResetFrame(); + } + + gp_Trsf aRotation; + gp_Pnt Pvise(0.0, 0.0, 0.0); + + if (!strcmp("+X+Y", theType) || myIs2D) + { + myMatrix = aRotation; + } + else if (!strcmp("-Y+X", theType)) + { + const gp_Dir aD(0., 0., 1.); + myMatrix.SetRotation(gp_Ax1(Pvise, aD), 0.5 * M_PI); + } + else if (!strcmp("-X-Y", theType)) + { + const gp_Dir aD(0., 0., 1.); + myMatrix.SetRotation(gp_Ax1(Pvise, aD), M_PI); + } + else if (!strcmp("+Y-X", theType)) + { + const gp_Dir aD(0., 0., 1.); + myMatrix.SetRotation(gp_Ax1(Pvise, aD), -0.5 * M_PI); + } + else if (!strcmp("+Y+X", theType)) + { + const gp_Dir aD1(0., 0., 1.); + const gp_Dir aD2(0., 1., 0.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), M_PI); + myMatrix.Multiply(aRotation); + } + else if (!strcmp("-X+Y", theType)) + { + const gp_Dir aD(0., 1., 0.); + myMatrix.SetRotation(gp_Ax1(Pvise, aD), M_PI); + } + else if (!strcmp("-Y-X", theType)) + { + const gp_Dir aD1(0., 0., 1.); + const gp_Dir aD2(1., 0., 0.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), M_PI); + myMatrix.Multiply(aRotation); + } + else if (!strcmp("+X-Y", theType)) + { + const gp_Dir aD(1., 0., 0.); + myMatrix.SetRotation(gp_Ax1(Pvise, aD), M_PI); + } + else if (!strcmp("+X+Z", theType)) + { + const gp_Dir aD(1., 0., 0.); + myMatrix.SetRotation(gp_Ax1(Pvise, aD), -0.5 * M_PI); + } + else if (!strcmp("-Z+X", theType)) + { + const gp_Dir aD1(1., 0., 0.); + const gp_Dir aD2(0., 1., 0.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), -0.5 * M_PI); + myMatrix.Multiply(aRotation); + } + else if (!strcmp("-X-Z", theType)) + { + const gp_Dir aD1(1., 0., 0.); + const gp_Dir aD2(0., 1., 0.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), -M_PI); + myMatrix.Multiply(aRotation); + } + else if (!strcmp("+Z-X", theType)) + { + const gp_Dir aD1(1., 0., 0.); + const gp_Dir aD2(0., 1., 0.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), 0.5 * M_PI); + myMatrix.Multiply(aRotation); + } + else if (!strcmp("+Z+X", theType)) + { + const gp_Dir aD1(1., 0., 0.); + const gp_Dir aD2(0., 1., 0.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), 0.5 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), 0.5 * M_PI); + myMatrix.Multiply(aRotation); + } + else if (!strcmp("-X+Z", theType)) + { + const gp_Dir aD1(1., 0., 0.); + const gp_Dir aD2(0., 1., 0.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), 0.5 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), M_PI); + myMatrix.Multiply(aRotation); + } + else if (!strcmp("-Z-X", theType)) + { + const gp_Dir aD1(1., 0., 0.); + const gp_Dir aD2(0., 1., 0.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), 0.5 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), -0.5 * M_PI); + myMatrix.Multiply(aRotation); + } + else if (!strcmp("+X-Z", theType)) + { + const gp_Dir aD(1., 0., 0.); + myMatrix.SetRotation(gp_Ax1(Pvise, aD), 0.5 * M_PI); + } + else if (!strcmp("+Y+Z", theType)) + { + const gp_Dir aD1(0., 1., 0.); + const gp_Dir aD2(1., 0., 0.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), -0.5 * M_PI); + myMatrix.Multiply(aRotation); + } + else if (!strcmp("-Z+Y", theType)) + { + const gp_Dir aD(0., 1., 0.); + myMatrix.SetRotation(gp_Ax1(Pvise, aD), -0.5 * M_PI); + } + else if (!strcmp("-Y-Z", theType)) + { + const gp_Dir aD1(0., 1., 0.); + const gp_Dir aD2(1., 0., 0.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), 0.5 * M_PI); + myMatrix.Multiply(aRotation); + } + else if (!strcmp("+Z-Y", theType)) + { + const gp_Dir aD1(0., 1., 0.); + const gp_Dir aD2(1., 0., 0.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.5 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), M_PI); + myMatrix.Multiply(aRotation); + } + else if (!strcmp("+Z+Y", theType)) + { + const gp_Dir aD(0., 1., 0.); + myMatrix.SetRotation(gp_Ax1(Pvise, aD), 0.5 * M_PI); + } + else if (!strcmp("-Y+Z", theType)) + { + const gp_Dir aD1(0., 1., 0.); + const gp_Dir aD2(1., 0., 0.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), 0.5 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), -0.5 * M_PI); + myMatrix.Multiply(aRotation); + } + else if (!strcmp("-Z-Y", theType)) + { + const gp_Dir aD1(0., 1., 0.); + const gp_Dir aD2(1., 0., 0.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), 0.5 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), M_PI); + myMatrix.Multiply(aRotation); + } + else if (!strcmp("+Y-Z", theType)) + { + const gp_Dir aD1(0., 1., 0.); + const gp_Dir aD2(1., 0., 0.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), 0.5 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), 0.5 * M_PI); + myMatrix.Multiply(aRotation); + } + else if (!strcmp("AXON", theType)) + { + const gp_Dir aD1(1., 0., 0.); + const gp_Dir aD2(0., 0., 1.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.25 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), -0.25 * M_PI); + myMatrix.Multiply(aRotation); + } + else if (!strcmp("PERS", theType)) + { + const gp_Dir aD1(1., 0., 0.); + const gp_Dir aD2(0., 0., 1.); + + myMatrix.SetRotation (gp_Ax1(Pvise, aD1), -0.25 * M_PI); + aRotation.SetRotation(gp_Ax1(Pvise, aD2), -0.25 * M_PI); + myMatrix.Multiply(aRotation); + + myIsPers = Standard_True; + } + else + { + return Standard_False; + } + + strcpy(myType, theType); + return Standard_True; +} + +//======================================================================= +//function : Transform +//purpose : +//======================================================================= +void Draw_View::Transform(const gp_Trsf& theTransformation) +{ + myMatrix.Multiply(theTransformation); +} + +//======================================================================= +//function : ResetFrame +//purpose : +//======================================================================= +void Draw_View::ResetFrame() +{ + myFrameX0 = 0; + myFrameY0 = 0; + myFrameX1 = 0; + myFrameY1 = 0; +} + +//======================================================================= +//function : GetFrame +//purpose : +//======================================================================= +void Draw_View::GetFrame(Standard_Integer& theX0,Standard_Integer& theY0, + Standard_Integer& theX1,Standard_Integer& theY1) +{ + if ( myFrameX0 == myFrameX1 ) + { + myViewer->GetFrame(myId, theX0, theY0, theX1, theY1); + myFrameX0 = theX0; + myFrameX1 = theX1; + myFrameY0 = theY0; + myFrameY1 = theY1; + } + else + { + theX0 = myFrameX0; + theX1 = myFrameX1; + theY0 = myFrameY0; + theY1 = myFrameY1; + } +} + +//======================================================================= +//function : WExpose +//purpose : +//======================================================================= +void Draw_View::WExpose() +{ + ResetFrame(); + myViewer->RepaintView(myId); +} diff --git a/src/Draw/Draw_View.hxx b/src/Draw/Draw_View.hxx new file mode 100644 index 0000000000..f5328957eb --- /dev/null +++ b/src/Draw/Draw_View.hxx @@ -0,0 +1,165 @@ +#ifndef Draw_View_Header +#define Draw_View_Header + +#include +#include + +class Draw_Viewer; + +class Draw_View : public Draw_Window +{ +public: + + //! Constructor + Draw_View(Standard_Integer theId, + Draw_Viewer* theViewer, + Standard_Integer theX, + Standard_Integer theY, + Standard_Integer theWidth, + Standard_Integer theHeight); + +#if defined(_WIN32) || defined(__WIN32__) + Draw_View(Standard_Integer theId, + Draw_Viewer* theViewer, + Standard_Integer theX, + Standard_Integer theY, + Standard_Integer theWidth, + Standard_Integer theHeight, + HWND theWindow); +#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) + Draw_View(Standard_Integer theId, + Draw_Viewer* theViewer, + Standard_Integer theX, + Standard_Integer theY, + Standard_Integer theWidth, + Standard_Integer theHeight, + NSWindow* theWindow); +#endif + + //! Constructor. + Draw_View(Standard_Integer theId, + Draw_Viewer* theViewer, + const char* theTitle); + + //! Destructor. + ~Draw_View(); + +public: // @name getters and setters + + //! Sets horizontal offset. + void SetDx(const Standard_Integer theDx) + { + myDx = theDx; + } + + //! Sets vertical offset. + void SetDy(const Standard_Integer theDy) + { + myDy = theDy; + } + + //! Sets parameter of zoom. + void SetZoom(const Standard_Real theZoom) + { + myZoom = theZoom; + } + + //! Sets view matrix. + void SetMatrix(const gp_Trsf& theMatrix) + { + myMatrix = theMatrix; + } + + //! Sets focal distance. + void SetFocalDistance(const Standard_Real theDistance) + { + myFocalDistance = theDistance; + } + + //! Gets horizontal offset. + const Standard_Integer GetDx() const + { + return myDx; + } + + //! Gets vertical offset. + const Standard_Integer GetDy() const + { + return myDy; + } + + //! Gets parameter of zoom. + const Standard_Real GetZoom() const + { + return myZoom; + } + + //! Gets matrix of view. + const gp_Trsf& GetMatrix() const + { + return myMatrix; + } + + //! Gets focal distance. + const Standard_Real GetFocalDistance() const + { + return myFocalDistance; + } + +public: //! @name public inline methods + + //! Returns type of view. + const char* Type() + { + return myType; + } + + //! Returns true value if current view in 2D mode. + const Standard_Boolean Is2D() const + { + return myIs2D; + } + + //! Returns true value if current view in perspective mode. + const Standard_Real IsPerspective() const + { + return myIsPers; + } + +public: //! @name view API + + //! Initialize view by the type. + Standard_Boolean Init(const char* theType); + + //! Transformates view matrix. + void Transform(const gp_Trsf& theTransformation); + + //! Resets frame of current view. + void ResetFrame(); + + //! Returns parameters of frame corners. + void GetFrame(Standard_Integer& theX0,Standard_Integer& theY0, + Standard_Integer& theX1,Standard_Integer& theY1); + + //! Perform window exposing. + void WExpose(); + +protected: + + Standard_Integer myId; + Draw_Viewer* myViewer; + char myType[5]; + Standard_Boolean myIsPers; + Standard_Boolean myIs2D; + Standard_Real myFocalDistance; + Standard_Real myZoom; + gp_Trsf myMatrix; + Standard_Integer myDx; + Standard_Integer myDy; + Standard_Integer myFrameX0; + Standard_Integer myFrameY0; + Standard_Integer myFrameX1; + Standard_Integer myFrameY1; +}; + +#endif diff --git a/src/Draw/Draw_Viewer.cxx b/src/Draw/Draw_Viewer.cxx index df7b3e9d1b..430a48e79b 100644 --- a/src/Draw/Draw_Viewer.cxx +++ b/src/Draw/Draw_Viewer.cxx @@ -20,6 +20,7 @@ // see : SaveView(filename) #include +#include #include #include @@ -58,319 +59,6 @@ static Standard_Real ps_gray[MAXCOLOR]; enum DrawingMode {DRAW, PICK, POSTSCRIPT}; static DrawingMode CurrentMode = DRAW; -/* local window class */ - -//======================================================================= -// class View -//======================================================================= - -class Draw_View : public Draw_Window { - public : - Draw_View(Standard_Integer i, - Draw_Viewer* v, - Standard_Integer X, - Standard_Integer Y, - Standard_Integer W, - Standard_Integer H); - -#if defined(_WIN32) || defined(__WIN32__) - Draw_View(Standard_Integer i, - Draw_Viewer* v, - Standard_Integer X, - Standard_Integer Y, - Standard_Integer W, - Standard_Integer H, - HWND win); -#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) - Draw_View(Standard_Integer i, - Draw_Viewer* v, - Standard_Integer X, - Standard_Integer Y, - Standard_Integer W, - Standard_Integer H, - NSWindow* theWindow); -#endif - - Draw_View(Standard_Integer i, - Draw_Viewer* v, - const char *w); - - void WExpose(); - - Standard_Boolean Init(const char* typ); - ~Draw_View() {Destroy();} - - void ResetFrame() { Framex0=Framey0=Framex1=Framey1=0; } - - void GetFrame(Standard_Integer& x0,Standard_Integer& y0, - Standard_Integer& x1,Standard_Integer& y1) { - if(Framex0==Framex1) { - viewer->GetFrame(id,x0,y0,x1,y1); - Framex0=x0; Framex1=x1; Framey0=y0; Framey1=y1; - } - else { - x0=Framex0; x1=Framex1; - y0=Framey0; y1=Framey1; - } - } - - Standard_Integer id; - Draw_Viewer* viewer; - char type[5]; - Standard_Integer FlagPers; - Standard_Integer Flag2d; - Standard_Real FocalDist; - Standard_Real Zoom; - gp_Trsf Matrix; - Standard_Integer dX; - Standard_Integer dY; - Standard_Integer lastX; - Standard_Integer lastY; - Standard_Integer Framex0,Framey0,Framex1,Framey1; -}; - -//======================================================================= -//function : Draw_View -//purpose : -//======================================================================= -Draw_View::Draw_View(Standard_Integer i, Draw_Viewer* v, - Standard_Integer X, - Standard_Integer Y, - Standard_Integer W, - Standard_Integer H) : - Draw_Window("Win", X, Y, W, H), - id(i), - viewer(v), - FlagPers(0), - Flag2d(0), - FocalDist(0.), - Zoom(0.), - dX(0),dY(0), - lastX(0),lastY(0) -{ - Framex0=Framey0=Framex1=Framey1=0; -} - -#if defined(_WIN32) || defined(__WIN32__) -//======================================================================= -//function : Draw_View -//purpose : -//======================================================================= -Draw_View::Draw_View(Standard_Integer i, Draw_Viewer* v, - Standard_Integer X, - Standard_Integer Y, - Standard_Integer W, - Standard_Integer H, - HWND theWin) : - Draw_Window("Win", X, Y, W, H, theWin), id(i), viewer(v) -{ - Framex0=Framey0=Framex1=Framey1=0; -} -#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) -Draw_View::Draw_View(Standard_Integer i, Draw_Viewer* v, - Standard_Integer X, - Standard_Integer Y, - Standard_Integer W, - Standard_Integer H, - NSWindow* theWindow) : - Draw_Window(theWindow, "Win", X, Y, W, H), id(i), viewer(v), - FlagPers(0), - Flag2d(0), - FocalDist(0.), - Zoom(0.), - dX(0),dY(0), - lastX(0),lastY(0), - Framex0(0),Framey0(0), - Framex1(0),Framey1(0) -{ -} -#endif - -//======================================================================= -//function : Draw_View -//purpose : -//======================================================================= -#if defined(_WIN32) || defined (__WIN32__) || (defined(__APPLE__) && !defined(MACOSX_USE_GLX)) - Draw_View::Draw_View(Standard_Integer /*i*/, Draw_Viewer* /*v*/, const char* /*w*/) : viewer( NULL ) -#else -Draw_View::Draw_View(Standard_Integer i, Draw_Viewer* v, const char* w) : - Draw_Window(w), id(i), viewer(v) -#endif -{ - -} - -//======================================================================= -//function : Init -//purpose : -//======================================================================= - -Standard_Boolean Draw_View::Init (const char* typ) -{ - // default fields - - Framex0=Framey0=Framex1=Framey1=0; - FocalDist = 500.; - FlagPers = 0; - Flag2d = !strcmp("-2D-",typ); - Zoom = 1; - gp_Trsf T; - gp_Pnt Pvise(0,0,0); - if (!strcmp("+X+Y",typ) || Flag2d) - { - Matrix = T; - } - else if (!strcmp("-Y+X",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(0,0,1)),M_PI/2); - } - else if (!strcmp("-X-Y",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(0,0,1)),M_PI); - } - else if (!strcmp("+Y-X",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(0,0,1)),-M_PI/2); - } - else if (!strcmp("+Y+X",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(0,0,1)),-M_PI/2); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),M_PI); - Matrix.Multiply(T); - } - else if (!strcmp("-X+Y",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),M_PI); - } - else if (!strcmp("-Y-X",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(0,0,1)),-M_PI/2); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),M_PI); - Matrix.Multiply(T); - } - else if (!strcmp("+X-Y",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),M_PI); - } - else if (!strcmp("+X+Z",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),-M_PI/2); - } - else if (!strcmp("-Z+X",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),-M_PI/2); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),-M_PI/2); - Matrix.Multiply(T); - } - else if (!strcmp("-X-Z",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),-M_PI/2); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),-M_PI); - Matrix.Multiply(T); - } - else if (!strcmp("+Z-X",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),-M_PI/2); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),M_PI/2); - Matrix.Multiply(T); - } - else if (!strcmp("+Z+X",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),M_PI/2); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),M_PI/2); - Matrix.Multiply(T); - } - else if (!strcmp("-X+Z",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),M_PI/2); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),M_PI); - Matrix.Multiply(T); - } - else if (!strcmp("-Z-X",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),M_PI/2); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),-M_PI/2); - Matrix.Multiply(T); - } - else if (!strcmp("+X-Z",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),M_PI/2); - } - else if (!strcmp("+Y+Z",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),-M_PI/2); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),-M_PI/2); - Matrix.Multiply(T); - } - else if (!strcmp("-Z+Y",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),-M_PI/2); - } - else if (!strcmp("-Y-Z",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),-M_PI/2); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),M_PI/2); - Matrix.Multiply(T); - } - else if (!strcmp("+Z-Y",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),-M_PI/2); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),M_PI); - Matrix.Multiply(T); - } - else if (!strcmp("+Z+Y",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),M_PI/2); - } - else if (!strcmp("-Y+Z",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),M_PI/2); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),-M_PI/2); - Matrix.Multiply(T); - } - else if (!strcmp("-Z-Y",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),M_PI/2); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),M_PI); - Matrix.Multiply(T); - } - else if (!strcmp("+Y-Z",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(0,1,0)),M_PI/2); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),M_PI/2); - Matrix.Multiply(T); - } - else if (!strcmp("AXON",typ)) - { - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),-M_PI/4); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(0,0,1)),-M_PI/4); - Matrix.Multiply(T); - } - else if (!strcmp("PERS",typ)) - { - FlagPers =1; - Matrix.SetRotation(gp_Ax1(Pvise,gp_Dir(1,0,0)),-M_PI/4); - T.SetRotation(gp_Ax1(Pvise,gp_Dir(0,0,1)),-M_PI/4); - Matrix.Multiply(T); - } - else { - return Standard_False; - } - strcpy(type,typ); - return Standard_True; -} - -//======================================================================= -//function : WExpose -//purpose : -//======================================================================= - -void Draw_View::WExpose() -{ - Framex0=Framey0=Framex1=Framey1=0; - viewer->RepaintView(id); -} - //======================================================================= //function : Create //purpose : @@ -416,8 +104,8 @@ void Draw_Viewer::MakeView(const Standard_Integer id, myViews[id] = new Draw_View(id,this,X , Y, W, H); // View fields - myViews[id]->dX = W / 2; - myViews[id]->dY = - H / 2; + myViews[id]->SetDx(W / 2); + myViews[id]->SetDy(- H / 2); if (!myViews[id]->Init(typ)) DeleteView(id); @@ -446,8 +134,8 @@ void Draw_Viewer::MakeView(const Standard_Integer id, myViews[id]->SetUseBuffer(useBuffer); // View fields - myViews[id]->dX = W / 2; - myViews[id]->dY = - H / 2; + myViews[id]->SetDx( W / 2); + myViews[id]->SetDy(-H / 2); if (!myViews[id]->Init(typ)) DeleteView(id); @@ -472,8 +160,8 @@ void Draw_Viewer::MakeView (const Standard_Integer id, myViews[id] = new Draw_View(id,this,window); - myViews[id]->dX = myViews[id]->WidthWin() / 2; - myViews[id]->dY = - myViews[id]->HeightWin() / 2; + myViews[id]->SetDx(myViews[id]->WidthWin() / 2); + myViews[id]->SetDy(-myViews[id]->HeightWin() / 2); if (!myViews[id]->Init(typ)) DeleteView(id); @@ -503,7 +191,7 @@ void Draw_Viewer::ResetView(const Standard_Integer id) { if (Draw_Batch) return; if (myViews[id]) { - myViews[id]->Init(myViews[id]->type); + myViews[id]->Init(myViews[id]->Type()); ConfigView(id); } } @@ -515,16 +203,27 @@ void Draw_Viewer::ResetView(const Standard_Integer id) void Draw_Viewer::SetZoom (const Standard_Integer id, const Standard_Real z) { - if (Draw_Batch) return; - if (myViews[id]) { - Standard_Real zz = z / myViews[id]->Zoom; - myViews[id]->Zoom = z; + if (Draw_Batch) + return; + + Draw_View* aView = myViews[id]; + if (aView) + { + Standard_Real zz = z / aView->GetZoom(); + aView->SetZoom(z); Standard_Integer X,Y,W,H; GetPosSize(id,X,Y,W,H); - Standard_Real w = W; - myViews[id]->dX = (Standard_Integer )( w / 2 - zz * (w/2 - myViews[id]->dX)); - Standard_Real h = H; - myViews[id]->dY = (Standard_Integer )( - h / 2 + zz * (h/2 + myViews[id]->dY)); + + const Standard_Real w = 0.5 * static_cast(W); + const Standard_Real h = 0.5 * static_cast(H); + + const Standard_Integer aDx = static_cast + ( w - zz * (w - aView->GetDx()) ); + const Standard_Integer aDy = static_cast + ( -h + zz * (h + aView->GetDy()) ); + + aView->SetDx(aDx); + aView->SetDy(aDy); } } @@ -539,7 +238,7 @@ void Draw_Viewer::RotateView (const Standard_Integer id, { if (Draw_Batch) return; if (myViews[id]) { - gp_Trsf T = myViews[id]->Matrix; + gp_Trsf T = myViews[id]->GetMatrix(); T.Invert(); gp_Pnt PP(0,0,0); @@ -564,7 +263,7 @@ void Draw_Viewer::RotateView (const Standard_Integer id, if (myViews[id]) { gp_Trsf T; T.SetRotation(gp_Ax1(P,D),A); - myViews[id]->Matrix.Multiply(T); + myViews[id]->Transform(T); } } @@ -578,7 +277,7 @@ void Draw_Viewer::SetFocal (const Standard_Integer id, const Standard_Real F) { if (Draw_Batch) return; if (myViews[id]) - myViews[id]->FocalDist = F; + myViews[id]->SetFocalDistance(F); } //======================================================================= @@ -590,7 +289,7 @@ char* Draw_Viewer::GetType (const Standard_Integer id) const { if (Draw_Batch) return blank; if (myViews[id]) - return myViews[id]->type; + return const_cast(myViews[id]->Type()); else return blank; } @@ -604,9 +303,9 @@ Standard_Real Draw_Viewer::Zoom (const Standard_Integer id) const { if (Draw_Batch) return Standard_False; if (myViews[id]) - return myViews[id]->Zoom; + return myViews[id]->GetZoom(); else - return 0; + return 0.0; } //======================================================================= @@ -618,7 +317,7 @@ Standard_Real Draw_Viewer::Focal (const Standard_Integer id) const { if (Draw_Batch) return 1.; if (myViews[id]) - return myViews[id]->FocalDist; + return myViews[id]->GetFocalDistance(); else return 0; } @@ -632,7 +331,7 @@ void Draw_Viewer::GetTrsf (const Standard_Integer id,gp_Trsf& T) const { if (Draw_Batch) return; if (myViews[id]) - T = myViews[id]->Matrix; + T = myViews[id]->GetMatrix(); } //======================================================================= @@ -644,7 +343,7 @@ Standard_Boolean Draw_Viewer::Is3D (const Standard_Integer id) const { if (Draw_Batch) return Standard_False; if (myViews[id]) - return !myViews[id]->Flag2d; + return !myViews[id]->Is2D(); else return Standard_False; } @@ -658,7 +357,7 @@ void Draw_Viewer::SetTrsf (const Standard_Integer id,gp_Trsf& T) { if (Draw_Batch) return; if (myViews[id]) - myViews[id]->Matrix = T; + myViews[id]->SetMatrix(T); } //======================================================================= @@ -691,10 +390,10 @@ void Draw_Viewer::GetFrame(const Standard_Integer id, if (myViews[id]) { Standard_Integer X,Y,H,W; GetPosSize(id,X,Y,W,H); - xminf = - myViews[id]->dX; - xmaxf = W - myViews[id]->dX; - yminf = - myViews[id]->dY - H; - ymaxf = - myViews[id]->dY; + xminf = - myViews[id]->GetDx(); + xmaxf = W - myViews[id]->GetDx(); + yminf = - myViews[id]->GetDy() - H; + ymaxf = - myViews[id]->GetDy(); } } @@ -709,11 +408,12 @@ void Draw_Viewer::FitView(const Standard_Integer id, const Standard_Integer fram if (myViews[id]) { // is this the only view in its category - Standard_Integer is2d = myViews[id]->Flag2d; + Standard_Boolean is2d = myViews[id]->Is2D(); Standard_Integer i,nbviews = 0; for (i = 1; i < MAXVIEW; i++) { if (myViews[i]) { - if (myViews[i]->Flag2d == is2d) nbviews++; + if (myViews[i]->Is2D() == is2d) + ++nbviews; } } Standard_Boolean only = (nbviews == 1); @@ -744,10 +444,10 @@ void Draw_Viewer::FitView(const Standard_Integer id, const Standard_Integer fram } } Standard_Real z; - umin = umin / curview->Zoom; - vmin = vmin / curview->Zoom; - umax = umax / curview->Zoom; - vmax = vmax / curview->Zoom; + umin = umin / curview->GetZoom(); + vmin = vmin / curview->GetZoom(); + umax = umax / curview->GetZoom(); + vmax = vmax / curview->GetZoom(); if ((umax - umin) < 1.e-6) { if ((vmax - vmin) < 1.e-6) return; @@ -761,9 +461,9 @@ void Draw_Viewer::FitView(const Standard_Integer id, const Standard_Integer fram if (z2 < z) z = z2; } } - curview->Zoom = z; - curview->dX = (Standard_Integer )( W / 2 - ((umin+umax) / 2) * z); - curview->dY = (Standard_Integer )( - H / 2 - ((vmin+vmax) / 2) * z); + curview->SetZoom(z); + curview->SetDx( static_cast( W / 2 - 0.5 * (umin+umax) * z) ); + curview->SetDy( static_cast(-H / 2 - 0.5 * (vmin+vmax) * z) ); } } @@ -777,8 +477,8 @@ void Draw_Viewer::PanView(const Standard_Integer id, { if (Draw_Batch) return; if (myViews[id]) { - myViews[id]->dX += DX; - myViews[id]->dY += DY; + myViews[id]->SetDx(myViews[id]->GetDx() + DX); + myViews[id]->SetDy(myViews[id]->GetDy() + DY); } } @@ -793,8 +493,8 @@ void Draw_Viewer::SetPan(const Standard_Integer id, { if (Draw_Batch) return; if (myViews[id]) { - myViews[id]->dX = DX; - myViews[id]->dY = DY; + myViews[id]->SetDx(DX); + myViews[id]->SetDy(DY); } } @@ -808,8 +508,8 @@ void Draw_Viewer::GetPan(const Standard_Integer id, { if (Draw_Batch) return; if (myViews[id]) { - DX = myViews[id]->dX; - DY = myViews[id]->dY; + DX = myViews[id]->GetDx(); + DY = myViews[id]->GetDy(); } } @@ -929,10 +629,10 @@ void Draw_Viewer::UpdateView (const Standard_Integer id, const Standard_Boolean void Draw_Viewer::ConfigView (const Standard_Integer id) const { if (Draw_Batch) return; - if (myViews[id]) { - myViews[id]->dX = myViews[id]->WidthWin() / 2; - myViews[id]->dY = - myViews[id]->HeightWin() / 2; - + if (myViews[id]) + { + myViews[id]->SetDx(myViews[id]->WidthWin() / 2); + myViews[id]->SetDy(-myViews[id]->HeightWin() / 2); } } @@ -965,7 +665,7 @@ void Draw_Viewer::PostScriptView (const Standard_Integer id, if (n == 0) return; CurrentMode = POSTSCRIPT; Draw_Display DF = MakeDisplay(id); - Standard_Boolean view2d = myViews[id]->Flag2d; + Standard_Boolean view2d = myViews[id]->Is2D(); for (Standard_Integer i = 1; i <= n; i++) if (myDrawables(i)->Is3D()) { if (!view2d) myDrawables(i)->DrawOn(DF); @@ -1035,7 +735,8 @@ void Draw_Viewer::Repaint2D () const if (Draw_Batch) return; for (Standard_Integer id = 0; id < MAXVIEW; id++) if (myViews[id]) { - if (myViews[id]->Flag2d) RepaintView(id); + if (myViews[id]->Is2D()) + RepaintView(id); } } @@ -1049,7 +750,8 @@ void Draw_Viewer::Repaint3D () const if (Draw_Batch) return; for (Standard_Integer id = 0; id < MAXVIEW; id++) if (myViews[id]) { - if (!myViews[id]->Flag2d) RepaintView(id); + if (!myViews[id]->Is2D()) + RepaintView(id); } } @@ -1101,8 +803,8 @@ void Draw_Viewer::Clear2D() } for (Standard_Integer id = 0; id < MAXVIEW; id++) { if (myViews[id]) { - if (myViews[id]->Flag2d) - ClearView(id); + if (myViews[id]->Is2D()) + ClearView(id); } } } @@ -1126,8 +828,8 @@ void Draw_Viewer::Clear3D() } for (Standard_Integer id = 0; id < MAXVIEW; id++) { if (myViews[id]) { - if (!myViews[id]->Flag2d) - ClearView(id); + if (!myViews[id]->Is2D()) + ClearView(id); } } } @@ -1157,14 +859,13 @@ void Draw_Viewer::DrawOnView(const Standard_Integer id, xmin = ymin = DRAWINFINITE; xmax = ymax = -DRAWINFINITE; - Standard_Boolean view2d = myViews[id]->Flag2d; + Standard_Boolean view2d = myViews[id]->Is2D(); myViews[id]->ResetFrame(); - if ((D->Is3D() && !view2d) || - (!D->Is3D() && view2d)) { + if ((D->Is3D() && !view2d) || (!D->Is3D() && view2d)) + { D->DrawOn(d); - if (CurrentMode == DRAW) - D->SetBounds(xmin,xmax,ymin,ymax); + D->SetBounds(xmin,xmax,ymin,ymax); d.Flush(); } } @@ -1304,8 +1005,8 @@ void Draw_Viewer::Select (Standard_Integer& id, Standard_Integer& X, Standard_In } if (id != -1) { - X = X - myViews[id]->dX; - Y = -Y - myViews[id]->dY; + X = X - myViews[id]->GetDx(); + Y = -Y - myViews[id]->GetDy(); } if (!wait) myViews[id]->Wait(!wait); #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) @@ -1315,7 +1016,7 @@ void Draw_Viewer::Select (Standard_Integer& id, Standard_Integer& X, Standard_In while (id >= MAXVIEW) { GetNextEvent(wait, aWindowNumber, X, Y, Button); - + if (Y < 0) { continue; // mouse clicked on window title @@ -1330,8 +1031,8 @@ void Draw_Viewer::Select (Standard_Integer& id, Standard_Integer& X, Standard_In } } - X = X - myViews[id]->dX; - Y = -Y - myViews[id]->dY; + X = X - myViews[id]->GetDx(); + Y = -Y - myViews[id]->GetDy(); #else HANDLE hWnd; @@ -1347,8 +1048,8 @@ void Draw_Viewer::Select (Standard_Integer& id, Standard_Integer& X, Standard_In for(int i=0 ; iwin == hWnd ) id = i; } - X = X - myViews[id]->dX; - Y = -Y - myViews[id]->dY; + X = X - myViews[id]->GetDx(); + Y = -Y - myViews[id]->GetDy(); #endif } @@ -1367,12 +1068,13 @@ Standard_Integer Draw_Viewer::Pick(const Standard_Integer id, return 0; // is this the only view in its category - Standard_Integer is2d = myViews[id]->Flag2d; + Standard_Boolean is2d = myViews[id]->Is2D(); Standard_Integer i,nbviews = 0; - for (i = 0; i < MAXVIEW; i++) { - if (myViews[i]) { - if (myViews[i]->Flag2d == is2d) nbviews++; - } + for (i = 0; i < MAXVIEW; i++) + { + if (myViews[i]) + if (myViews[i]->Is2D() == is2d) + ++nbviews; } Standard_Boolean only = (nbviews == 1); @@ -1526,7 +1228,7 @@ void Draw_Display::SetMode (const Standard_Integer M) const Standard_Real Draw_Display::Zoom() const { if (Draw_Batch) return 1.; - return curview->Zoom; + return curview->GetZoom(); } //======================================================================= @@ -1554,7 +1256,7 @@ void Draw_Display::DrawString(const gp_Pnt2d& ppt, if (ppt.X() > 1.e09 || ppt.X() < -1.e09 ) return; if (ppt.Y() > 1.e09 || ppt.Y() < -1.e09 ) return; - gp_Pnt2d pt(ppt.X()*curview->Zoom,ppt.Y()*curview->Zoom); + gp_Pnt2d pt(ppt.X()*curview->GetZoom(),ppt.Y()*curview->GetZoom()); if (pt.X() > 1.e09 || pt.X() < -1.e09 ) return; if (pt.Y() > 1.e09 || pt.Y() < -1.e09 ) return; @@ -1563,8 +1265,8 @@ void Draw_Display::DrawString(const gp_Pnt2d& ppt, case DRAW : { - int X = (int) ( pt.X() + moveX + curview->dX); - int Y = (int) (-pt.Y() + moveY - curview->dY); + int X = (int) ( pt.X() + moveX + curview->GetDx()); + int Y = (int) (-pt.Y() + moveY - curview->GetDy()); curview->DrawString(X,Y,(char *)S); if (Draw_Bounds) { if (pt.X() + moveX > xmax) xmax = pt.X(); @@ -1644,12 +1346,13 @@ void Draw_Display::Project(const gp_Pnt& p, gp_Pnt2d& p2d) const { if (Draw_Batch) return; gp_Pnt pt = p; - pt.Transform(curview->Matrix); + pt.Transform(curview->GetMatrix()); Standard_Real xp,yp,zp; pt.Coord(xp,yp,zp); - if (curview->FlagPers) { - xp = xp*curview->FocalDist/(curview->FocalDist-zp); - yp = yp*curview->FocalDist/(curview->FocalDist-zp); + if (curview->IsPerspective()) { + const Standard_Real aDistance = curview->GetFocalDistance(); + xp = xp * aDistance / (aDistance-zp); + yp = yp * aDistance / (aDistance-zp); } p2d.SetCoord(xp,yp); } @@ -1663,9 +1366,9 @@ Draw_Display::Draw_Display () { if (Draw_Batch) return; if (curview) { - PtPers.SetCoord(0,0,0); - PtPers.Transform(curview->Matrix); - PtCur.SetCoord(PtPers.X()*curview->Zoom,PtPers.Y()*curview->Zoom); + PtPers.SetCoord(0., 0., 0.); + PtPers.Transform(curview->GetMatrix()); + PtCur.SetCoord(PtPers.X()*curview->GetZoom(),PtPers.Y()*curview->GetZoom()); } } @@ -1677,7 +1380,8 @@ Draw_Display::Draw_Display () void Draw_Display::MoveTo (const gp_Pnt2d& pp) { if (Draw_Batch) return; - gp_Pnt2d pt(pp.X() * curview->Zoom, pp.Y() * curview->Zoom); + const Standard_Real aZoom = curview->GetZoom(); + gp_Pnt2d pt(pp.X() * aZoom, pp.Y() * aZoom); switch (CurrentMode) { case DRAW : @@ -1789,7 +1493,7 @@ void Draw_Display::DrawTo (const gp_Pnt2d& pp2) if (pp2.X() > 1.e09 || pp2.X() < -1.e09 ) return; if (pp2.Y() > 1.e09 || pp2.Y() < -1.e09 ) return; - gp_Pnt2d p2(pp2.X() * curview->Zoom, pp2.Y() * curview->Zoom); + gp_Pnt2d p2(pp2.X() * curview->GetZoom(), pp2.Y() * curview->GetZoom()); if (p2.X() > 1.e09 || p2.X() < -1.e09 ) return; if (p2.Y() > 1.e09 || p2.Y() < -1.e09 ) return; @@ -1820,20 +1524,19 @@ void Draw_Display::DrawTo (const gp_Pnt2d& pp2) gp_Pnt2d PI1(p1); gp_Pnt2d PI2(p2); - if(Trim(PI1,PI2,x0,y0,x1,y1)) { - segm[nbseg].Init((Standard_Integer )( PI1.X() + curview->dX), - (Standard_Integer )(-PI1.Y() - curview->dY), - (Standard_Integer )( PI2.X() + curview->dX), - (Standard_Integer )(-PI2.Y() - curview->dY)); - - nbseg++; + if(Trim(PI1,PI2,x0,y0,x1,y1)) + { + segm[nbseg].Init(static_cast( PI1.X() + curview->GetDx()), + static_cast(-PI1.Y() - curview->GetDy()), + static_cast( PI2.X() + curview->GetDx()), + static_cast(-PI2.Y() - curview->GetDy())); + ++nbseg; } #else - segm[nbseg].Init(( p1.X() + curview->dX), - (-p1.Y() - curview->dY), - ( p2.X() + curview->dX), - (-p2.Y() - curview->dY)); - + segm[nbseg].Init(static_cast( p1.X() + curview->GetDx()), + static_cast(-p1.Y() - curview->GetDy()), + static_cast( p2.X() + curview->GetDx()), + static_cast(-p2.Y() - curview->GetDy())); nbseg++; #endif if (nbseg == MAXSEGMENT) { @@ -1959,14 +1662,17 @@ void Draw_Display::MoveTo (const gp_Pnt& pt) else return; } PtPers = pt; - PtPers.Transform(curview->Matrix); + PtPers.Transform(curview->GetMatrix()); Standard_Real xp = PtPers.X(); Standard_Real yp = PtPers.Y(); - if (curview->FlagPers) { + if (curview->IsPerspective()) + { Standard_Real ZPers = PtPers.Z(); - if (ZPers < curview->FocalDist*precpers) { - xp=xp*curview->FocalDist/(curview->FocalDist-ZPers); - yp=yp*curview->FocalDist/(curview->FocalDist-ZPers); + const Standard_Real aDistance = curview->GetFocalDistance(); + if (ZPers < aDistance * precpers) + { + xp=xp * aDistance / (aDistance-ZPers); + yp=yp * aDistance / (aDistance-ZPers); } } MoveTo(gp_Pnt2d(xp,yp)); @@ -1982,35 +1688,41 @@ void Draw_Display::DrawTo (const gp_Pnt& pt) if (Draw_Batch) return; if ((CurrentMode == PICK) && found) return; - gp_Pnt pt2 = pt.Transformed(curview->Matrix); + gp_Pnt pt2 = pt.Transformed(curview->GetMatrix()); Standard_Real xp2 = pt2.X(); Standard_Real yp2 = pt2.Y(); - if (curview->FlagPers) { + if (curview->IsPerspective()) + { + const Standard_Real aZoom = curview->GetZoom(); + const Standard_Real aDistance = curview->GetFocalDistance(); + Standard_Real xp1 = PtPers.X(); Standard_Real yp1 = PtPers.Y(); Standard_Real zp1 = PtPers.Z(); Standard_Real zp2 = pt2.Z(); PtPers = pt2; - if ((zp1 >= curview->FocalDist*precpers) && - (zp2 >= curview->FocalDist*precpers) ) { + if ((zp1 >= aDistance*precpers) && (zp2 >= aDistance*precpers) ) + { return; // segment is not visible in perspective (behind the eye) } - else if (zp1 >= curview->FocalDist*precpers) { - xp1=xp1+(xp2-xp1)*(curview->FocalDist*precpers-zp1)/(zp2-zp1); - yp1=yp1+(yp2-yp1)*(curview->FocalDist*precpers-zp1)/(zp2-zp1); - zp1=curview->FocalDist*precpers; - xp1=xp1*curview->FocalDist/(curview->FocalDist-zp1); - yp1=yp1*curview->FocalDist/(curview->FocalDist-zp1); - MoveTo(gp_Pnt2d(xp1*curview->Zoom,yp1*curview->Zoom)); - } - else if (zp2 >= curview->FocalDist*precpers) { - xp2=xp2+(xp1-xp2)*(curview->FocalDist*precpers-zp2)/(zp1-zp2); - yp2=yp2+(yp1-yp2)*(curview->FocalDist*precpers-zp2)/(zp1-zp2); - zp2=curview->FocalDist*precpers; + else if (zp1 >= aDistance*precpers) + { + xp1=xp1+(xp2-xp1)*(aDistance*precpers-zp1)/(zp2-zp1); + yp1=yp1+(yp2-yp1)*(aDistance*precpers-zp1)/(zp2-zp1); + zp1=aDistance*precpers; + xp1=xp1*aDistance/(aDistance-zp1); + yp1=yp1*aDistance/(aDistance-zp1); + MoveTo( gp_Pnt2d(xp1 * aZoom, yp1 * aZoom) ); + } + else if (zp2 >= aDistance*precpers) + { + xp2=xp2+(xp1-xp2)*(aDistance*precpers-zp2)/(zp1-zp2); + yp2=yp2+(yp1-yp2)*(aDistance*precpers-zp2)/(zp1-zp2); + zp2=aDistance*precpers; } - xp2=xp2*curview->FocalDist/(curview->FocalDist-zp2); - yp2=yp2*curview->FocalDist/(curview->FocalDist-zp2); + xp2 = xp2 * aDistance / (aDistance - zp2); + yp2 = yp2 * aDistance / (aDistance - zp2); } DrawTo(gp_Pnt2d(xp2,yp2)); if (CurrentMode == PICK) { diff --git a/src/Draw/FILES b/src/Draw/FILES index 0ad398d66d..d7acf6cfec 100755 --- a/src/Draw/FILES +++ b/src/Draw/FILES @@ -9,9 +9,10 @@ Draw_UnitCommands.cxx Draw_Appli.hxx Draw_Interpretor.hxx Draw_Interpretor.cxx +Draw_View.hxx +Draw_View.cxx Draw_Viewer.cxx Draw_Viewer.hxx -Draw_Viewer.hxx Draw_Window.cxx Draw_Window.hxx Draw_PInterp.hxx diff --git a/src/HLRBRep/HLRBRep_Data.cxx b/src/HLRBRep/HLRBRep_Data.cxx index 8ea8f78cb8..4dd54f0142 100644 --- a/src/HLRBRep/HLRBRep_Data.cxx +++ b/src/HLRBRep/HLRBRep_Data.cxx @@ -188,6 +188,10 @@ public: Standard_Integer StNbLect,StNbEcr,StNbMax,StNbMoy,StNbMoyNonNul; //-- STAT #endif +private: + TableauRejection(const TableauRejection&); + TableauRejection& operator=(const TableauRejection&); + public: //-- ============================================================ TableauRejection() { diff --git a/src/Message/Message_MsgFile.cxx b/src/Message/Message_MsgFile.cxx index 735182c7dd..ef6163d635 100644 --- a/src/Message/Message_MsgFile.cxx +++ b/src/Message/Message_MsgFile.cxx @@ -15,6 +15,7 @@ #include +#include #include #include #include @@ -216,41 +217,35 @@ Standard_Boolean Message_MsgFile::LoadFile (const Standard_CString theFileName) // Open the file FILE *anMsgFile = OSD_OpenFile(theFileName,"rb"); - if (!anMsgFile) return Standard_False; + if (!anMsgFile) + return Standard_False; - // Read the file into memory - class Buffer - { - // self-destructing buffer - char *myBuf; - public: - Buffer (Standard_Integer theSize) : myBuf(new char [theSize]) {} - ~Buffer () { delete [] myBuf; } - operator char* () const { return myBuf; } - char& operator [] (Standard_Integer theInd) { return myBuf[theInd]; } - }; - Standard_Integer aFileSize = GetFileSize (anMsgFile); - if (aFileSize <= 0) + const Standard_Integer aFileSize = GetFileSize (anMsgFile); + NCollection_Buffer aBuffer(NCollection_BaseAllocator::CommonBaseAllocator()); + if (aFileSize <= 0 || !aBuffer.Allocate(aFileSize + 2)) { fclose (anMsgFile); return Standard_False; } - Buffer anMsgBuffer (aFileSize + 2); - Standard_Integer nbRead = - (Standard_Integer) fread (anMsgBuffer, 1, aFileSize, anMsgFile); + + char* anMsgBuffer = reinterpret_cast(aBuffer.ChangeData()); + const Standard_Integer nbRead = + static_cast( fread(anMsgBuffer, 1, aFileSize, anMsgFile) ); + fclose (anMsgFile); if (nbRead != aFileSize) return Standard_False; + anMsgBuffer[aFileSize] = 0; - anMsgBuffer[aFileSize+1] = 0; + anMsgBuffer[aFileSize + 1] = 0; // Read the messages in the file and append them to the global DataMap Standard_Boolean isLittleEndian = (anMsgBuffer[0] == '\xff' && anMsgBuffer[1] == '\xfe'); Standard_Boolean isBigEndian = (anMsgBuffer[0] == '\xfe' && anMsgBuffer[1] == '\xff'); if ( isLittleEndian || isBigEndian ) { - Standard_ExtCharacter * aUnicodeBuffer = - (Standard_ExtCharacter *) &anMsgBuffer[2]; + Standard_ExtCharacter* aUnicodeBuffer = + reinterpret_cast(&anMsgBuffer[2]); // Convert Unicode representation to order adopted on current platform #if defined(__sparc) && defined(__sun) if ( isLittleEndian ) @@ -259,17 +254,19 @@ Standard_Boolean Message_MsgFile::LoadFile (const Standard_CString theFileName) #endif { // Reverse the bytes throughout the buffer - for (Standard_ExtCharacter * aPtr = aUnicodeBuffer; - aPtr < (Standard_ExtCharacter *) &anMsgBuffer[aFileSize]; aPtr++) + const Standard_ExtCharacter* const anEnd = + reinterpret_cast(&anMsgBuffer[aFileSize]); + + for (Standard_ExtCharacter* aPtr = aUnicodeBuffer; aPtr < anEnd; aPtr++) { - unsigned short aWord = *aPtr; - *aPtr = (aWord & 0x00ff) << 8 | (aWord & 0xff00) >> 8; + unsigned short aWord = *aPtr; + *aPtr = (aWord & 0x00ff) << 8 | (aWord & 0xff00) >> 8; } } return ::loadFile (aUnicodeBuffer); } else - return ::loadFile ((char*) anMsgBuffer); + return ::loadFile (anMsgBuffer); } //======================================================================= diff --git a/src/NCollection/NCollection_Handle.hxx b/src/NCollection/NCollection_Handle.hxx index 26c93cd0ac..d33bcfbd4a 100644 --- a/src/NCollection/NCollection_Handle.hxx +++ b/src/NCollection/NCollection_Handle.hxx @@ -65,6 +65,14 @@ class NCollection_Handle : public Handle(Standard_Transient) const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(NCollection_Handle); } + protected: + + //! Copy constructor + Ptr(const Ptr&); + + //! Assignment operator + Ptr& operator=(const Ptr&); + public: T* myPtr; //!< Pointer to the object }; diff --git a/src/OSD/OSD_MAllocHook.cxx b/src/OSD/OSD_MAllocHook.cxx index be8f28e1d6..81dd2d6f58 100644 --- a/src/OSD/OSD_MAllocHook.cxx +++ b/src/OSD/OSD_MAllocHook.cxx @@ -249,37 +249,27 @@ void OSD_MAllocHook::LogFileHandler::Close() struct StorageInfo { - Standard_Size size; - int nbAlloc; - int nbFree; - int nbLeftPeak; - std::set* alive; - StorageInfo() - : size(0), nbAlloc(0), nbFree(0), nbLeftPeak(0), alive(NULL) {} - StorageInfo(Standard_Size theSize) - : size(theSize), nbAlloc(0), nbFree(0), nbLeftPeak(0), alive(NULL) {} - ~StorageInfo() + Standard_Size size; + Standard_Integer nbAlloc; + Standard_Integer nbFree; + Standard_Integer nbLeftPeak; + std::set alive; + + StorageInfo(Standard_Size theSize = 0) + : size (theSize), + nbAlloc (0), + nbFree (0), + nbLeftPeak(0), + alive() { - if (alive) - delete alive; } - std::set& Alive() - { - if (!alive) - alive = new std::set; - return *alive; - } - const std::set& Alive() const + + bool operator < (const StorageInfo& theOther) const { - return *alive; + return size < theOther.size; } }; -inline bool operator < (const StorageInfo& one, const StorageInfo& two) -{ - return one.size < two.size; -} - Standard_Boolean OSD_MAllocHook::LogFileHandler::MakeReport (const char* theLogFile, const char* theOutFile, @@ -345,17 +335,17 @@ Standard_Boolean OSD_MAllocHook::LogFileHandler::MakeReport int nbLeft = aInfo.nbAlloc - aInfo.nbFree; if (nbLeft > aInfo.nbLeftPeak) aInfo.nbLeftPeak = nbLeft; - aInfo.Alive().insert(aReqNum); + aInfo.alive.insert(aReqNum); } else { std::set::iterator aFoundReqNum = - aInfo.Alive().find(aReqNum); - if (aFoundReqNum == aInfo.Alive().end()) + aInfo.alive.find(aReqNum); + if (aFoundReqNum == aInfo.alive.end()) // freeing non-registered block, skip it continue; aTotalLeftSize -= aSize; - aInfo.Alive().erase(aFoundReqNum); + aInfo.alive.erase(aFoundReqNum); if (aInfo.nbAlloc + 1 > 0) aInfo.nbFree++; } @@ -400,10 +390,10 @@ Standard_Boolean OSD_MAllocHook::LogFileHandler::MakeReport aTotAlloc = SIZE_MAX; else aTotAlloc += aSizeAlloc; - if (theIncludeAlive && !aInfo.Alive().empty()) + if (theIncludeAlive && !aInfo.alive.empty()) { - for (std::set::const_iterator it1 = aInfo.alive->begin(); - it1 != aInfo.alive->end(); ++it1) + for (std::set::const_iterator it1 = aInfo.alive.begin(); + it1 != aInfo.alive.end(); ++it1) aRepFile << std::setw(10) << *it1; } } diff --git a/src/OSD/OSD_PerfMeter.hxx b/src/OSD/OSD_PerfMeter.hxx index e26b632a27..2a43f77f92 100644 --- a/src/OSD/OSD_PerfMeter.hxx +++ b/src/OSD/OSD_PerfMeter.hxx @@ -61,6 +61,11 @@ public: //! Assures stopping upon destruction ~OSD_PerfMeter() { if (myIMeter >= 0) Stop(); } +private: + + OSD_PerfMeter(const OSD_PerfMeter&); + OSD_PerfMeter& operator= (const OSD_PerfMeter&); + protected: int myIMeter; diff --git a/src/TestTopOpe/TestTopOpe_HDSCommands.cxx b/src/TestTopOpe/TestTopOpe_HDSCommands.cxx index f2bdd7f2ba..94d2c1a985 100644 --- a/src/TestTopOpe/TestTopOpe_HDSCommands.cxx +++ b/src/TestTopOpe/TestTopOpe_HDSCommands.cxx @@ -141,15 +141,12 @@ public: Standard_Boolean IsV() const { return (myETK == TopOpeBRepDS_VERTEX); } Standard_Boolean Is0() const { return IsP() || IsV(); } Standard_Integer Set(Standard_Integer na,const char** a,Standard_Integer iargK,Standard_Integer iargI); - void Delete() ; - Standard_EXPORT virtual ~tsee_entity() {Delete() ;} ; + + virtual ~tsee_entity() {} void virtual Dump() const; void virtual See() = 0; }; -void tsee_entity::Delete() -{} - Standard_Integer tsee_entity::Set(Standard_Integer na,const char** a,Standard_Integer iargK,Standard_Integer iargI) { myEOK = Standard_False; if (iargK>=na) return 1; if (iargI>=na) return 1; @@ -190,10 +187,8 @@ void tsee_entity::Dump() const { class tsee_entity0 : public tsee_entity { public: - - gp_Pnt Pnt() const; + gp_Pnt Pnt() const; void See(); - }; gp_Pnt tsee_entity0::Pnt() const