0023931: Incorrect image export code in MFC sample: Added OCC_BaseDoc::ExportView...
authoraba <aba@opencascade.com>
Thu, 5 Dec 2013 11:03:53 +0000 (15:03 +0400)
committerbugmaster <bugmaster@opencascade.com>
Fri, 6 Dec 2013 09:10:37 +0000 (13:10 +0400)
Compilation errors were corrected.

18 files changed:
samples/mfc/standard/01_Geometry/src/GeometryDoc.h
samples/mfc/standard/01_Geometry/src/GeometryView.cpp
samples/mfc/standard/03_Viewer2d/src/Viewer2dDoc.cpp
samples/mfc/standard/04_Viewer3d/src/ModelClippingDlg.cpp
samples/mfc/standard/04_Viewer3d/src/Viewer3d.rc
samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp
samples/mfc/standard/07_Triangulation/res/Triangulation.rc
samples/mfc/standard/07_Triangulation/src/TriangulationDoc.cpp
samples/mfc/standard/09_Animation/src/AnimationDoc.h
samples/mfc/standard/09_Animation/src/AnimationView3D.cpp
samples/mfc/standard/10_Convert/src/WNT/OCCDemo.rc
samples/mfc/standard/10_Convert/src/WNT/OCCDemoDoc.cpp
samples/mfc/standard/10_Convert/src/WNT/OCCDemoDoc.h
samples/mfc/standard/Common/OCC_2dView.cpp
samples/mfc/standard/Common/OCC_3dBaseDoc.h
samples/mfc/standard/Common/OCC_3dView.cpp
samples/mfc/standard/Common/OCC_BaseDoc.cpp
samples/mfc/standard/Common/OCC_BaseDoc.h

index 3b286b9..7ab5419 100755 (executable)
@@ -9,11 +9,12 @@
 #pragma once
 #endif // _MSC_VER >= 1000
 
 #pragma once
 #endif // _MSC_VER >= 1000
 
+#include "OCC_BaseDoc.h"
 #include "ResultDialog.h"
 
 class Handle_AIS_Point;
 
 #include "ResultDialog.h"
 
 class Handle_AIS_Point;
 
-class CGeometryDoc : public CDocument
+class CGeometryDoc : public OCC_BaseDoc
 {
 public:
   void Put2DOnTop(bool isMax = true);
 {
 public:
   void Put2DOnTop(bool isMax = true);
@@ -210,26 +211,16 @@ protected:
   //}}AFX_MSG
   DECLARE_MESSAGE_MAP()
 
   //}}AFX_MSG
   DECLARE_MESSAGE_MAP()
 
-
-private:
-  Handle_V3d_Viewer myViewer;
-  Handle_V3d_Viewer myViewerCollector;
-  Handle_AIS_InteractiveContext myAISContext;
-public :
-  Handle_AIS_InteractiveContext& GetAISContext(){ return myAISContext; };
-  Handle_V3d_Viewer GetViewer()  { return myViewer; };
-  Handle_V3d_Viewer GetViewerCollector()  { return myViewerCollector; };
-
-
 private:
   Handle_V3d_Viewer myViewer2D;
   Handle_AIS_InteractiveContext myAISContext2D;
 private:
   Handle_V3d_Viewer myViewer2D;
   Handle_AIS_InteractiveContext myAISContext2D;
-public :
+
+public:
   int Current;
   void Minimize3D();
   void Minimize2D();
   int Current;
   void Minimize3D();
   void Minimize2D();
-  Handle_V3d_Viewer GetViewer2D()  { return myViewer2D; };
-  Handle_AIS_InteractiveContext& GetISessionContext(){ return myAISContext2D; };
+  Handle_V3d_Viewer GetViewer2D() { return myViewer2D; };
+  Handle_AIS_InteractiveContext& GetISessionContext() { return myAISContext2D; };
   BOOL FitMode;
 
 public :
   BOOL FitMode;
 
 public :
index 4232cef..2ca07f7 100755 (executable)
@@ -79,23 +79,7 @@ CGeometryDoc* CGeometryView::GetDocument() // non-debug version is inline
 
 void CGeometryView::OnFileExportImage()
 {
 
 void CGeometryView::OnFileExportImage()
 {
-  CFileDialog aDlg (FALSE, "*.BMP", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
-    "BMP  Files (*.BMP)|*.bmp|"
-    "GIF  Files (*.GIF)|*.gif|"
-    "PNG  Files (*.PNG)|*.png|"
-    "JPEG Files (*.JPG)|*.jpg|"
-    "PPM  Files (*.PPM)|*.ppm|"
-    "TIFF Files (*.TIFF)|*.tiff|"
-    "TGA  Files (*.TGA)|*.tga|"
-    "EXR  Files (*.EXR)|*.exr||", NULL);
-  if (aDlg.DoModal() != IDOK)
-  {
-    return;
-  }
-
-  SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
-  myView->Dump (aDlg.GetPathName());
-  SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
+  GetDocument()->ExportView (myView);
 }
 
 void CGeometryView::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
 }
 
 void CGeometryView::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
index 3efcbe4..d7d01f4 100755 (executable)
@@ -317,114 +317,110 @@ void CViewer2dDoc::OnBUTTONTestCurve()
 
 void CViewer2dDoc::OnBUTTONTestImage()
 {
 
 void CViewer2dDoc::OnBUTTONTestImage()
 {
-  CFileDialog dlg(TRUE,
-                  NULL,
-                  NULL,
-                  OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
-                  "image Files (*.bmp , *.gif , *.jpeg, *.bmp, *.ppm, *.exr, *.tga, *.tiff, *.pgf, *.pdf)"
-                  "|*.bmp; *.gif; *.jpeg;  *.bmp; *.ppm; *.exr; *.tga; *.tiff; *.pgf; *.pdf;"
-                  "| all files (*.*)|*.*;||",  
-                  NULL );
-
-  CString initdir(((OCC_App*) AfxGetApp())->GetInitDataDir());
-  initdir += "\\Data";
-
-  dlg.m_ofn.lpstrInitialDir = initdir;
-  if(dlg.DoModal() == IDOK)
+  CFileDialog anOpenImageDlg (TRUE,
+                              NULL,
+                              NULL,
+                              OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
+                              SupportedImageFormats() + "| all files (*.*)|*.*;||",
+                              NULL);
+
+  CString anInitDir (((OCC_App*) AfxGetApp())->GetInitDataDir());
+  anInitDir += "\\Data";
+
+  anOpenImageDlg.m_ofn.lpstrInitialDir = anInitDir;
+  if(anOpenImageDlg.DoModal() == IDOK)
   {
   {
-    SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
-    CString filename = dlg.GetPathName();
-    TCollection_AsciiString aFileName(filename);
+    SetCursor(AfxGetApp()->LoadStandardCursor (IDC_WAIT));
+    CString aFilePath = anOpenImageDlg.GetPathName();
+    TCollection_AsciiString aFileName (aFilePath);
 
     //erase viewer
     if(myAISContext->HasOpenedContext())
       myAISContext->CloseAllContexts();
     myAISContext->EraseAll();
 
 
     //erase viewer
     if(myAISContext->HasOpenedContext())
       myAISContext->CloseAllContexts();
     myAISContext->EraseAll();
 
-    Handle(Sample2D_Image) anImage = new Sample2D_Image(aFileName);
-    anImage->SetCoord(40,50) ;
-    anImage->SetScale(1.0);
-    myAISContext->Display(anImage, Standard_False);
-    myAISContext->SetDisplayMode(anImage,3,Standard_False);
-    FitAll2DViews(Standard_True);
+    Handle(Sample2D_Image) anImage = new Sample2D_Image (aFileName);
+    anImage->SetCoord (40,50) ;
+    anImage->SetScale (1.0);
+    myAISContext->Display (anImage, Standard_False);
+    myAISContext->SetDisplayMode (anImage,3,Standard_False);
+    FitAll2DViews (Standard_True);
   }
 }
 
 void CViewer2dDoc::OnBUTTONMultipleImage()
 {
   }
 }
 
 void CViewer2dDoc::OnBUTTONMultipleImage()
 {
-  CFileDialog dlg(TRUE,
-                  NULL,
-                  NULL,
-                  OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
-                  "image Files (*.bmp , *.gif , *.jpeg, *.bmp, *.ppm, *.exr, *.tga, *.tiff, *.pgf, *.pdf)"
-                  "|*.bmp; *.gif; *.jpeg;  *.bmp; *.ppm; *.exr; *.tga; *.tiff; *.pgf; *.pdf;"
-                  "| all files (*.*)|*.*;||",  
-                  NULL );
+  CFileDialog anOpenImageDlg (TRUE,
+                              NULL,
+                              NULL,
+                              OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
+                              SupportedImageFormats() + "| all files (*.*)|*.*;||",
+                              NULL);
 
 
-  CString initdir(((OCC_App*) AfxGetApp())->GetInitDataDir());
-  initdir += "\\Data";
+  CString anInitDir (((OCC_App*) AfxGetApp())->GetInitDataDir());
+  anInitDir += "\\Data";
 
 
-  dlg.m_ofn.lpstrInitialDir = initdir;
+  anOpenImageDlg.m_ofn.lpstrInitialDir = anInitDir;
 
 
-  if (dlg.DoModal() == IDOK) 
+  if (anOpenImageDlg.DoModal() == IDOK) 
   {
   {
-    SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
-    CString filename = dlg.GetPathName();
-    TCollection_AsciiString aFileName(filename);
+    SetCursor(AfxGetApp()->LoadStandardCursor (IDC_WAIT));
+    CString aFilePath = anOpenImageDlg.GetPathName();
+    TCollection_AsciiString aFileName (aFilePath);
+
     //erase viewer
     if(myAISContext->HasOpenedContext())
       myAISContext->CloseAllContexts();
     myAISContext->EraseAll();
     //erase viewer
     if(myAISContext->HasOpenedContext())
       myAISContext->CloseAllContexts();
     myAISContext->EraseAll();
+
     //create images
     {  // 1
     //create images
     {  // 1
-    Handle(Sample2D_Image) anImage = new Sample2D_Image(aFileName);
-    anImage->SetCoord(40,50) ;
-    anImage->SetScale(0.5);
-    myAISContext->Display(anImage, Standard_False);
-    myAISContext->SetDisplayMode(anImage,3,Standard_False);
+    Handle(Sample2D_Image) anImage = new Sample2D_Image (aFileName);
+    anImage->SetCoord (40, 50);
+    anImage->SetScale (0.5);
+    myAISContext->Display (anImage, Standard_False);
+    myAISContext->SetDisplayMode (anImage, 3, Standard_False);
     }
     {  // 2
     }
     {  // 2
-    Handle(Sample2D_Image) anImage = new Sample2D_Image(aFileName);
-
-    anImage->SetCoord(100,50) ;
-         anImage->SetScale(0.9);
-    myAISContext->Display(anImage,Standard_False);
-    myAISContext->SetDisplayMode(anImage,3,Standard_False);
+    Handle(Sample2D_Image) anImage = new Sample2D_Image (aFileName);
+    anImage->SetCoord (100, 50);
+    anImage->SetScale (0.9);
+    myAISContext->Display (anImage, Standard_False);
+    myAISContext->SetDisplayMode (anImage, 3, Standard_False);
     }
     {  // 3
     }
     {  // 3
-    Handle(Sample2D_Image) anImage = new Sample2D_Image(aFileName);
-    anImage->SetCoord(40,40) ;
-    anImage->SetScale(0.3);
-    myAISContext->Display(anImage, Standard_False);
-    myAISContext->SetDisplayMode(anImage,3,Standard_False);
+    Handle(Sample2D_Image) anImage = new Sample2D_Image (aFileName);
+    anImage->SetCoord (40, 40);
+    anImage->SetScale (0.3);
+    myAISContext->Display (anImage, Standard_False);
+    myAISContext->SetDisplayMode (anImage, 3, Standard_False);
     }
     {  // 4
     }
     {  // 4
-    Handle(Sample2D_Image) anImage = new Sample2D_Image(aFileName);
-    anImage->SetCoord(50,40) ;
-    myAISContext->Display(anImage, Standard_False);
-    myAISContext->SetDisplayMode(anImage,3,Standard_False);
+    Handle(Sample2D_Image) anImage = new Sample2D_Image (aFileName);
+    anImage->SetCoord (50, 40);
+    myAISContext->Display (anImage, Standard_False);
+    myAISContext->SetDisplayMode (anImage, 3, Standard_False);
     }
     {  // 5
     }
     {  // 5
-    Handle(Sample2D_Image) anImage = new Sample2D_Image(aFileName);
-    anImage->SetCoord(80,45) ;
-         anImage->SetScale(2);
-    myAISContext->Display(anImage,  Standard_False);
-    myAISContext->SetDisplayMode(anImage,3,Standard_False);
+    Handle(Sample2D_Image) anImage = new Sample2D_Image (aFileName);
+    anImage->SetCoord (80, 45);
+    anImage->SetScale (2);
+    myAISContext->Display (anImage, Standard_False);
+    myAISContext->SetDisplayMode (anImage, 3, Standard_False);
     }
     {  // 6
     }
     {  // 6
-    Handle(Sample2D_Image) anImage = new Sample2D_Image(aFileName);
-    anImage->SetCoord(20,-20) ;
-    myAISContext->Display(anImage, Standard_False);
-    myAISContext->SetDisplayMode(anImage,3,Standard_False);
+    Handle(Sample2D_Image) anImage = new Sample2D_Image (aFileName);
+    anImage->SetCoord (20, -20);
+    myAISContext->Display (anImage, Standard_False);
+    myAISContext->SetDisplayMode (anImage, 3, Standard_False);
     }
     {  // 7
     }
     {  // 7
-    Handle(Sample2D_Image) anImage = new Sample2D_Image(aFileName);
-    anImage->SetCoord(0,0) ;
-         anImage->SetScale(0.5);
-    myAISContext->Display(anImage, Standard_False);
-    myAISContext->SetDisplayMode(anImage,3,Standard_False);
+    Handle(Sample2D_Image) anImage = new Sample2D_Image (aFileName);
+    anImage->SetCoord (0, 0);
+    anImage->SetScale (0.5);
+    myAISContext->Display (anImage, Standard_False);
+    myAISContext->SetDisplayMode (anImage, 3, Standard_False);
     }
     }
-    FitAll2DViews(Standard_True); // Update Viewer
+    FitAll2DViews (Standard_True); // Update Viewer
   }
 }
   }
 }
index 7aa3274..9023600 100755 (executable)
@@ -120,7 +120,18 @@ BOOL CModelClippingDlg::OnInitDialog()
   if (m_ModelClippingONOFF)
   {
     // register and activate clipping plane
   if (m_ModelClippingONOFF)
   {
     // register and activate clipping plane
-    if (!myView->GetClipPlanes().Contains (myClippingPlane))
+    Standard_Boolean toAddPlane = Standard_True;
+    Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (myView->GetClipPlanes());
+    for (; aPlaneIt.More(); aPlaneIt.Next())
+    {
+      if (aPlaneIt.Value() == myClippingPlane)
+      {
+        toAddPlane = Standard_False;
+        break;
+      }
+    }
+
+    if (toAddPlane)
     {
       myView->AddClipPlane (myClippingPlane);
     }
     {
       myView->AddClipPlane (myClippingPlane);
     }
@@ -188,7 +199,18 @@ void CModelClippingDlg::OnCheckModelclippingonoff()
   if (m_ModelClippingONOFF)
   {
     // register and activate clipping plane
   if (m_ModelClippingONOFF)
   {
     // register and activate clipping plane
-    if (!myView->GetClipPlanes().Contains (myClippingPlane))
+    Standard_Boolean toAddPlane = Standard_True;
+    Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (myView->GetClipPlanes());
+    for (; aPlaneIt.More(); aPlaneIt.Next())
+    {
+      if (aPlaneIt.Value() == myClippingPlane)
+      {
+        toAddPlane = Standard_False;
+        break;
+      }
+    }
+
+    if (toAddPlane)
     {
       myView->AddClipPlane (myClippingPlane);
     }
     {
       myView->AddClipPlane (myClippingPlane);
     }
index 94113f4..66bb00d 100755 (executable)
@@ -511,7 +511,7 @@ END
 
 STRINGTABLE 
 BEGIN
 
 STRINGTABLE 
 BEGIN
-    ID_DUMP_VIEW            "Save current frame into a GIF file\nExport view to GIF (F12)"
+    ID_DUMP_VIEW            "Save current frame into an image file\nExport view (F12)"
     ID_TEXTURE_ON           "Run texture example\nRun texture example"
 END
 
     ID_TEXTURE_ON           "Run texture example\nRun texture example"
 END
 
index a749ca2..6aa782f 100755 (executable)
@@ -1057,30 +1057,17 @@ void CViewer3dDoc::OnUpdateBUTTONEnd(CCmdUI* pCmdUI)
        pCmdUI->Enable (isTextureSampleStarted);
 }
 
        pCmdUI->Enable (isTextureSampleStarted);
 }
 
-void CViewer3dDoc::OnDumpView() 
-{
-  CFileDialog aDlg (false, "gif", "OCCView.gif", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
-    "GIF  Files (*.GIF)|*.gif|"
-    "BMP  Files (*.BMP)|*.bmp|"
-    "PNG  Files (*.PNG)|*.png|"
-    "JPEG Files (*.JPG)|*.jpg|"
-    "PPM  Files (*.PPM)|*.ppm|"
-    "TIFF Files (*.TIFF)|*.tiff|"
-    "TGA  Files (*.TGA)|*.tga|"
-    "EXR  Files (*.EXR)|*.exr||", NULL);
-  if (aDlg.DoModal() != IDOK)
-  {
-    return;
-  }
-
+void CViewer3dDoc::OnDumpView()
+{
   for (POSITION aPos = GetFirstViewPosition(); aPos != NULL;)
   {
     CViewer3dView* pView = (CViewer3dView* )GetNextView (aPos);
     pView->UpdateWindow();
   }
   for (POSITION aPos = GetFirstViewPosition(); aPos != NULL;)
   {
     CViewer3dView* pView = (CViewer3dView* )GetNextView (aPos);
     pView->UpdateWindow();
   }
+
   myViewer->InitActiveViews();
   Handle(V3d_View) aView = myViewer->ActiveView();
   myViewer->InitActiveViews();
   Handle(V3d_View) aView = myViewer->ActiveView();
-  aView->Dump (aDlg.GetPathName());
+  ExportView (aView);
 }
 
 void CViewer3dDoc::Start()
 }
 
 void CViewer3dDoc::Start()
index ee150fa..ab6b27c 100755 (executable)
@@ -202,7 +202,7 @@ BEGIN
     ID_BUTTONStart          "Press to go to the first sample\nFirst sample (Home)"
     ID_BUTTONNext           "Press to go to the next sample\nNext sample (PgDn)"
     ID_BUTTONEnd            "Press to go to the last sample\nLast sample (End)"
     ID_BUTTONStart          "Press to go to the first sample\nFirst sample (Home)"
     ID_BUTTONNext           "Press to go to the next sample\nNext sample (PgDn)"
     ID_BUTTONEnd            "Press to go to the last sample\nLast sample (End)"
-    ID_DUMP_VIEW            "Save current frame into a GIF file\nExport view to GIF (F12)"
+    ID_DUMP_VIEW            "Save current frame into an image file\nExport view (F12)"
 END
 
 #endif    // English (U.S.) resources
 END
 
 #endif    // English (U.S.) resources
index b05539f..67d9008 100755 (executable)
@@ -405,30 +405,17 @@ void CTriangulationDoc::OnUpdateBUTTONPrev(CCmdUI* pCmdUI)
        pCmdUI->Enable (!myPresentation->AtFirstSample());
 }
 
        pCmdUI->Enable (!myPresentation->AtFirstSample());
 }
 
-void CTriangulationDoc::OnDumpView() 
+void CTriangulationDoc::OnDumpView()
 {
 {
-  CFileDialog aDlg (false, "gif", "OCCView.gif", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
-    "GIF  Files (*.GIF)|*.gif|"
-    "BMP  Files (*.BMP)|*.bmp|"
-    "PNG  Files (*.PNG)|*.png|"
-    "JPEG Files (*.JPEG)|*.jpeg|"
-    "PPM  Files (*.PPM)|*.ppm|"
-    "TIFF Files (*.TIFF)|*.tiff|"
-    "TGA  Files (*.TGA)|*.tga|"
-    "EXR  Files (*.EXR)|*.exr||", NULL);
-  if (aDlg.DoModal() != IDOK)
-  {
-    return;
-  }
-
   for (POSITION aPos = GetFirstViewPosition(); aPos != NULL;)
   {
     OCC_3dView* pView = (OCC_3dView* )GetNextView (aPos);
     pView->UpdateWindow();
   }
   for (POSITION aPos = GetFirstViewPosition(); aPos != NULL;)
   {
     OCC_3dView* pView = (OCC_3dView* )GetNextView (aPos);
     pView->UpdateWindow();
   }
+
   myViewer->InitActiveViews();
   Handle(V3d_View) aView = myViewer->ActiveView();
   myViewer->InitActiveViews();
   Handle(V3d_View) aView = myViewer->ActiveView();
-  aView->Dump (aDlg.GetPathName());
+  ExportView (aView);
 }
 
 void CTriangulationDoc::Fit()
 }
 
 void CTriangulationDoc::Fit()
index 1312b90..c847d79 100755 (executable)
 #pragma once
 #endif // _MSC_VER >= 1000
 
 #pragma once
 #endif // _MSC_VER >= 1000
 
-
+#include "OCC_BaseDoc.h"
 #include "AIS_ConnectedInteractive.hxx"
 #include "Geom_Transformation.hxx"
 
 
 #include "AIS_ConnectedInteractive.hxx"
 #include "Geom_Transformation.hxx"
 
 
-class CAnimationDoc : public CDocument
+class CAnimationDoc : public OCC_BaseDoc
 {
 public:
 
 {
 public:
 
-    void DragEvent      (const Standard_Integer  x       ,
-                                    const Standard_Integer  y       ,
-                                    const Standard_Integer  TheState,
-                         const Handle(V3d_View)& aView   );
-    void InputEvent     (const Standard_Integer  x       ,
-                                    const Standard_Integer  y       ,
-                         const Handle(V3d_View)& aView   );  
-    void MoveEvent      (const Standard_Integer  x       ,
-                         const Standard_Integer  y       ,
-                         const Handle(V3d_View)& aView   ); 
-    void ShiftMoveEvent (const Standard_Integer  x       ,
-                         const Standard_Integer  y       ,
-                         const Handle(V3d_View)& aView   ); 
-    void ShiftDragEvent (const Standard_Integer  x       ,
-                                        const Standard_Integer  y       ,
-                                        const Standard_Integer  TheState,
-                         const Handle(V3d_View)& aView   ); 
-    void ShiftInputEvent(const Standard_Integer  x       ,
-                                        const Standard_Integer  y       ,
-                         const Handle(V3d_View)& aView   ); 
-    void Popup          (const Standard_Integer  x       ,
-                                        const Standard_Integer  y       ,
-                         const Handle(V3d_View)& aView   ); 
+  void DragEvent (const Standard_Integer x,
+                  const Standard_Integer y,
+                  const Standard_Integer TheState,
+                  const Handle(V3d_View)& aView);
 
 
-protected: // create from serialization only
-       CAnimationDoc();
-       DECLARE_DYNCREATE(CAnimationDoc)
+  void InputEvent (const Standard_Integer x,
+                   const Standard_Integer y,
+                   const Handle(V3d_View)& aView);
 
 
-// Attributes
-public:
+  void MoveEvent (const Standard_Integer x,
+                  const Standard_Integer y,
+                  const Handle(V3d_View)& aView);
 
 
-// Operations
-public:
+  void ShiftMoveEvent (const Standard_Integer x,
+                       const Standard_Integer y,
+                       const Handle(V3d_View)& aView);
 
 
-// Overrides
-       // ClassWizard generated virtual function overrides
-       //{{AFX_VIRTUAL(CAnimationDoc)
-       public:
-       //}}AFX_VIRTUAL
+  void ShiftDragEvent (const Standard_Integer x,
+                       const Standard_Integer y,
+                       const Standard_Integer TheState,
+                       const Handle(V3d_View)& aView);
+
+  void ShiftInputEvent (const Standard_Integer x,
+                        const Standard_Integer y,
+                        const Handle(V3d_View)& aView);
+
+  void Popup (const Standard_Integer x,
+              const Standard_Integer y,
+              const Handle(V3d_View)& aView);
+
+protected: // create from serialization only
+  CAnimationDoc();
+  DECLARE_DYNCREATE(CAnimationDoc)
 
 // Implementation
 public:
 
 // Implementation
 public:
-       virtual ~CAnimationDoc();
+  virtual ~CAnimationDoc();
 #ifdef _DEBUG
 #ifdef _DEBUG
-       virtual void AssertValid() const;
-       virtual void Dump(CDumpContext& dc) const;
+  virtual void AssertValid() const;
+  virtual void Dump(CDumpContext& dc) const;
 #endif
 
 #endif
 
-protected:
-
 // Generated message map functions
 protected:
 // Generated message map functions
 protected:
-       //{{AFX_MSG(CAnimationDoc)
-       afx_msg void OnShading();
-       afx_msg void OnThread();
-       afx_msg void OnFileLoadgrid();
-       afx_msg void OnUpdateWalkWalkthru(CCmdUI* pCmdUI);
-       //}}AFX_MSG
-       DECLARE_MESSAGE_MAP()
-public :
+  //{{AFX_MSG(CAnimationDoc)
+  afx_msg void OnShading();
+  afx_msg void OnThread();
+  afx_msg void OnFileLoadgrid();
+  afx_msg void OnUpdateWalkWalkthru(CCmdUI* pCmdUI);
+  //}}AFX_MSG
+  DECLARE_MESSAGE_MAP()
 
 
+private:
+  Handle_AIS_Shape myAisCrankArm     ;
+  Handle_AIS_Shape myAisCylinderHead ;
+  Handle_AIS_Shape myAisPropeller    ;
+  Handle_AIS_Shape myAisPiston       ;
+  Handle_AIS_Shape myAisEngineBlock  ;
 
 
+  Standard_Real     myDeviation;
+  Standard_Integer  myAngle;
 
 
-private:
-  Handle_V3d_Viewer myViewer;
-  Handle_AIS_InteractiveContext myAISContext;
-public :
-       Handle_AIS_InteractiveContext& GetAISContext(){ return myAISContext; };
-       Handle_V3d_Viewer GetViewer()  { return myViewer; };
-
-
-
-private :
-       Handle_AIS_Shape myAisCrankArm     ;
-       Handle_AIS_Shape myAisCylinderHead ;
-       Handle_AIS_Shape myAisPropeller    ;
-       Handle_AIS_Shape myAisPiston       ;
-       Handle_AIS_Shape myAisEngineBlock  ;
-
-       Standard_Real     myDeviation;
-       Standard_Integer  myAngle;
-
-public :
-       void OnMyTimer();
-       Standard_Integer myCount;
-       Standard_Integer thread;
-       double m_Xmin, m_Ymin, m_Zmin, m_Xmax, m_Ymax, m_Zmax;
-       BOOL m_bIsGridLoaded;
+public:
+  void OnMyTimer();
+  Standard_Integer myCount;
+  Standard_Integer thread;
+  double m_Xmin, m_Ymin, m_Zmin, m_Xmax, m_Ymax, m_Zmax;
+  BOOL m_bIsGridLoaded;
 };
 
 /////////////////////////////////////////////////////////////////////////////
 };
 
 /////////////////////////////////////////////////////////////////////////////
index aa3ef38..18d0804 100755 (executable)
@@ -225,24 +225,7 @@ CAnimationDoc* CAnimationView3D::GetDocument() // non-debug version is inline
 // CAnimationView3D message handlers
 void CAnimationView3D::OnFileExportImage()
 {
 // CAnimationView3D message handlers
 void CAnimationView3D::OnFileExportImage()
 {
-  CFileDialog aDlg (FALSE, "*.BMP", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
-    "BMP  Files (*.BMP)|*.bmp|"
-    "GIF  Files (*.GIF)|*.gif|"
-    "PNG  Files (*.PNG)|*.png|"
-    "JPEG Files (*.JPEG)|*.jpeg|"
-    "PPM  Files (*.PPM)|*.ppm|"
-    "TIFF Files (*.TIFF)|*.tiff|"
-    "TGA  Files (*.TGA)|*.tga|"
-    "EXR  Files (*.EXR)|*.exr||",
-    NULL);
-  if (aDlg.DoModal() != IDOK)
-  {
-    return;
-  }
-
-  SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
-  myView->Dump (aDlg.GetPathName());
-  SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
+  GetDocument()->ExportView (myView);
 }
 
 void CAnimationView3D::OnSize(UINT /*nType*/, int cx, int cy) 
 }
 
 void CAnimationView3D::OnSize(UINT /*nType*/, int cx, int cy) 
index 26c102b..352d2b6 100755 (executable)
@@ -352,7 +352,7 @@ BEGIN
     ID_BUTTONStart          "Press to go to the first sample\nFirst sample (Home)"
     ID_BUTTONNext           "Press to go to the next sample\nNext sample (PgDn)"
     ID_BUTTONShowResult     "Press to toggle show of source code on/off\nSource code (F11)"
     ID_BUTTONStart          "Press to go to the first sample\nFirst sample (Home)"
     ID_BUTTONNext           "Press to go to the next sample\nNext sample (PgDn)"
     ID_BUTTONShowResult     "Press to toggle show of source code on/off\nSource code (F11)"
-    ID_DUMP_VIEW            "Save current frame into a GIF file\nExport view to GIF (F12)"
+    ID_DUMP_VIEW            "Save current frame into an image file\nExport view (F12)"
     ID_BUTTONEnd            "Press to go to the last sample\nLast sample (End)"
     ID_BUTTONPrev           "Press to go to the previous sample\nPrevious sample (PgUp)"
     ID_BUTTONRepeat         "Press to repeat the current sample\nRepeat sample (Space)"
     ID_BUTTONEnd            "Press to go to the last sample\nLast sample (End)"
     ID_BUTTONPrev           "Press to go to the previous sample\nPrevious sample (PgUp)"
     ID_BUTTONRepeat         "Press to repeat the current sample\nRepeat sample (Space)"
index f813941..c63713c 100755 (executable)
@@ -225,28 +225,15 @@ void COCCDemoDoc::OnUpdateBUTTONShowResult(CCmdUI* pCmdUI)
 
 void COCCDemoDoc::OnDumpView() 
 {
 
 void COCCDemoDoc::OnDumpView() 
 {
-  CFileDialog aDlg (false, "gif", "OCCView.gif", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
-    "GIF  Files (*.GIF)|*.gif|"
-    "BMP  Files (*.BMP)|*.bmp|"
-    "PNG  Files (*.PNG)|*.png|"
-    "JPEG Files (*.JPEG)|*.jpeg|"
-    "PPM  Files (*.PPM)|*.ppm|"
-    "TIFF Files (*.TIFF)|*.tiff|"
-    "TGA  Files (*.TGA)|*.tga|"
-    "EXR  Files (*.EXR)|*.exr||", NULL);
-  if (aDlg.DoModal() != IDOK)
-  {
-    return;
-  }
-
   for (POSITION aPos = GetFirstViewPosition(); aPos != NULL;)
   {
     COCCDemoView* pView = (COCCDemoView* )GetNextView (aPos);
     pView->UpdateWindow();
   }
   for (POSITION aPos = GetFirstViewPosition(); aPos != NULL;)
   {
     COCCDemoView* pView = (COCCDemoView* )GetNextView (aPos);
     pView->UpdateWindow();
   }
+
   myViewer->InitActiveViews();
   Handle(V3d_View) aView = myViewer->ActiveView();
   myViewer->InitActiveViews();
   Handle(V3d_View) aView = myViewer->ActiveView();
-  aView->Dump (aDlg.GetPathName());
+  ExportView (aView);
 }
 
 void COCCDemoDoc::Fit()
 }
 
 void COCCDemoDoc::Fit()
index 6493883..0907c14 100755 (executable)
@@ -9,14 +9,13 @@
 #pragma once
 #endif // _MSC_VER > 1000
 
 #pragma once
 #endif // _MSC_VER > 1000
 
+#include <OCC_BaseDoc.h>
 #include "ResultDialog.h"
 class OCCDemo_Presentation;
 
 #include "ResultDialog.h"
 class OCCDemo_Presentation;
 
-class COCCDemoDoc : public CDocument
+class COCCDemoDoc : public OCC_BaseDoc
 {
 public:
 {
 public:
-  Handle_V3d_Viewer GetViewer() const { return myViewer; };
-  Handle_AIS_InteractiveContext GetAISContext() const { return myAISContext; };
   CResultDialog* GetResultDialog () {return &myCResultDialog;}
   Standard_CString GetDataDir() {return myDataDir;}
 
   CResultDialog* GetResultDialog () {return &myCResultDialog;}
   Standard_CString GetDataDir() {return myDataDir;}
 
@@ -72,8 +71,6 @@ protected:
        DECLARE_MESSAGE_MAP()
 
 private:
        DECLARE_MESSAGE_MAP()
 
 private:
-  Handle_V3d_Viewer myViewer;
-  Handle_AIS_InteractiveContext myAISContext;
   OCCDemo_Presentation *myPresentation;
   CResultDialog myCResultDialog;
   BOOL myShowResult;
   OCCDemo_Presentation *myPresentation;
   CResultDialog myCResultDialog;
   BOOL myShowResult;
index 74ff4e2..439c7e0 100755 (executable)
@@ -121,36 +121,7 @@ void OCC_2dView::OnInitialUpdate()
 
 void OCC_2dView::OnFileExportImage()
 {
 
 void OCC_2dView::OnFileExportImage()
 {
-  LPCTSTR filter;
-  filter = _T("EXR Files (*.EXR)|*.exr|TGA Files (*.TGA)|*.tga|TIFF Files (*.TIFF)|*.tiff|"
-              "PPM Files (*.PPM)|*.ppm|JPEG Files(*.JPEG)|*.jpeg|PNG Files (*.PNG)|*.png|"
-              "GIF Files (*.GIF)|*.gif|BMP Files (*.BMP)|*.bmp|PS Files (*.PS)|*.ps|"
-              "EPS Files (*.EPS)|*.eps|TEX Files (*.TEX)|*.tex|PDF Files (*.PDF)|*.pdf"
-              "|SVG Files (*.SVG)|*.svg|PGF Files (*.PGF)|*.pgf|EMF Files (*.EMF)|*.emf||");
-  CFileDialog dlg(FALSE,_T("*.BMP"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
-                  filter, 
-                  NULL );
-
-
-if (dlg.DoModal() == IDOK) 
-{
-  SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
-  CString aFileName = dlg.GetPathName();
-  CString ext = dlg.GetFileExt();
-  if (!(ext.CompareNoCase("ps")) || !(ext.CompareNoCase("emf"))
-    || !(ext.CompareNoCase("pdf")) || !(ext.CompareNoCase("eps"))
-    || !(ext.CompareNoCase("tex")) || !(ext.CompareNoCase("svg"))
-    || !(ext.CompareNoCase("pgf")))
-  {
-    Graphic3d_ExportFormat exFormat;
-    if (!(ext.CompareNoCase("ps"))) exFormat = Graphic3d_EF_PostScript;
-    else             exFormat = Graphic3d_EF_EnhPostScript;
-    myV2dView->View()->Export( aFileName, exFormat );
-    return;
-  }
-  myV2dView->Dump(aFileName);
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
-}
+  GetDocument()->ExportView (myV2dView);
 }
 
 /////////////////////////////////////////////////////////////////////////////
 }
 
 /////////////////////////////////////////////////////////////////////////////
index d0bba86..5c179b2 100755 (executable)
@@ -13,7 +13,7 @@
 #include "DimensionDlg.h"
 #include <Standard_Macro.hxx>
 
 #include "DimensionDlg.h"
 #include <Standard_Macro.hxx>
 
-class AFX_EXT_CLASS OCC_3dBaseDoc : public OCC_BaseDoc  
+class AFX_EXT_CLASS OCC_3dBaseDoc : public OCC_BaseDoc
 {
 protected:
   CDimensionDlg myDimensionDlg;
 {
 protected:
   CDimensionDlg myDimensionDlg;
index e53fbf1..9f1f7e9 100755 (executable)
@@ -146,33 +146,7 @@ OCC_3dDoc* OCC_3dView::GetDocument() // non-debug version is inline
 // OCC_3dView message handlers
 void OCC_3dView::OnFileExportImage()
 {
 // OCC_3dView message handlers
 void OCC_3dView::OnFileExportImage()
 {
-  LPCTSTR filter;
-  filter = _T("EXR Files (*.EXR)|*.exr|TGA Files (*.TGA)|*.tga|TIFF Files (*.TIFF)|*.tiff|"
-              "PPM Files (*.PPM)|*.ppm|JPEG Files(*.JPEG)|*.jpeg|PNG Files (*.PNG)|*.png|"
-              "GIF Files (*.GIF)|*.gif|BMP Files (*.BMP)|*.bmp|PS Files (*.PS)|*.ps|"
-              "EPS Files (*.EPS)|*.eps|TEX Files (*.TEX)|*.tex|PDF Files (*.PDF)|*.pdf"
-              "|SVG Files (*.SVG)|*.svg|PGF Files (*.PGF)|*.pgf|EMF Files (*.EMF)|*.emf||");
-  CFileDialog dlg(FALSE,_T("*.BMP"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
-                  filter, 
-                  NULL );
-
-  if (dlg.DoModal() == IDOK) 
-  {
-    CString aFileName = dlg.GetPathName();
-    CString ext = dlg.GetFileExt();
-    if (!(ext.CompareNoCase("ps")) || !(ext.CompareNoCase("emf"))
-        || !(ext.CompareNoCase("pdf")) || !(ext.CompareNoCase("eps"))
-        || !(ext.CompareNoCase("tex")) || !(ext.CompareNoCase("svg"))
-        || !(ext.CompareNoCase("pgf")))
-    {
-      Graphic3d_ExportFormat exFormat;
-      if (!(ext.CompareNoCase("ps"))) exFormat = Graphic3d_EF_PostScript;
-      else             exFormat = Graphic3d_EF_EnhPostScript;
-      myView->View()->Export( aFileName, exFormat );
-      return;
-    }
-    myView->Dump(aFileName);
-  }
+  GetDocument()->ExportView (myView);
 }
 
 void OCC_3dView::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/) 
 }
 
 void OCC_3dView::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/) 
index 4ce15a7..46c9e74 100755 (executable)
@@ -5,6 +5,55 @@
 #include <stdafx.h>
 #include "OCC_BaseDoc.h"
 
 #include <stdafx.h>
 #include "OCC_BaseDoc.h"
 
+const CString OCC_BaseDoc::SupportedImageFormats() const
+{
+  return ("BMP Files (*.BMP)|*.bmp|GIF Files (*.GIF)|*.gif|TIFF Files (*.TIFF)|*.tiff|"
+          "PPM Files (*.PPM)|*.ppm|JPEG Files(*.JPEG)|*.jpeg|PNG Files (*.PNG)|*.png|"
+          "EXR Files (*.EXR)|*.exr|TGA Files (*.TGA)|*.tga|PS Files (*.PS)|*.ps|"
+          "EPS Files (*.EPS)|*.eps|TEX Files (*.TEX)|*.tex|PDF Files (*.PDF)|*.pdf"
+          "|SVG Files (*.SVG)|*.svg|PGF Files (*.PGF)|*.pgf");
+}
+
+void OCC_BaseDoc::ExportView (const Handle(V3d_View)& theView) const
+{
+   CFileDialog anExportDlg (FALSE,_T("*.BMP"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
+                            SupportedImageFormats() + "||", NULL );
+
+  if (anExportDlg.DoModal() == IDOK)
+  {
+    // Set waiting cursor
+    SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
+
+    CString aFileName = anExportDlg.GetPathName();
+    CString aFileExt = anExportDlg.GetFileExt();
+
+    // For vector formats use V3d_View::Export() method
+    if (!(aFileExt.CompareNoCase ("ps")) || !(aFileExt.CompareNoCase ("pdf"))
+        || !(aFileExt.CompareNoCase ("eps")) || !(aFileExt.CompareNoCase ("tex"))
+        || !(aFileExt.CompareNoCase ("svg")) || !(aFileExt.CompareNoCase ("pgf")))
+    {
+      Graphic3d_ExportFormat anExportFormat;
+
+      if (!(aFileExt.CompareNoCase ("ps"))) anExportFormat = Graphic3d_EF_PostScript;
+      else if (!(aFileExt.CompareNoCase ("eps"))) anExportFormat = Graphic3d_EF_EnhPostScript;
+      else if (!(aFileExt.CompareNoCase ("pdf"))) anExportFormat = Graphic3d_EF_PDF;
+      else if (!(aFileExt.CompareNoCase ("tex"))) anExportFormat = Graphic3d_EF_TEX;
+      else if (!(aFileExt.CompareNoCase ("svg"))) anExportFormat = Graphic3d_EF_SVG;
+      else anExportFormat = Graphic3d_EF_PGF;
+
+      theView->View()->Export (aFileName, anExportFormat);
+    }
+    else
+    {
+      // For pixel formats use V3d_View:Dump() method
+      theView->Dump (aFileName);
+    }
+
+    // Restore cursor
+    SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
+  }
+}
+
 //////////////////////////////////////////////////////////////////////
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
index ebff305..46a0b2b 100755 (executable)
@@ -9,9 +9,18 @@
 #pragma once
 #endif // _MSC_VER > 1000
 
 #pragma once
 #endif // _MSC_VER > 1000
 
-#include <stdafx.h>
-
-class OCC_BaseDoc : public CDocument  
+#include <AIS_InteractiveContext.hxx>
+#include <V3d_Viewer.hxx>
+
+// Base class for all documents in the sample.
+// Declares base functionlaity and interface for the sample documents.
+// Common properties:
+// - interactive context
+// - 3d viewer
+// Common methods:
+// - base events
+// - export into one of supported export formats.
+class AFX_EXT_CLASS OCC_BaseDoc : public CDocument
 {
 public:
 
 {
 public:
 
@@ -21,7 +30,13 @@ public:
 
   Handle(AIS_InteractiveContext)& GetAISContext() { return myAISContext; }
 
 
   Handle(AIS_InteractiveContext)& GetAISContext() { return myAISContext; }
 
-  Handle(V3d_Viewer) GetViewer()  { return myViewer; }
+  Handle(V3d_Viewer) GetViewer() { return myViewer; }
+
+  // Returns string with supported export pixel and vector images formats.
+  const CString SupportedImageFormats() const;
+
+  // Exports the given view into of the supported formats.
+  void ExportView (const Handle(V3d_View)& theView) const;
 
   //Events
   virtual void DragEvent (const Standard_Integer /*theMouseX*/,
 
   //Events
   virtual void DragEvent (const Standard_Integer /*theMouseX*/,