mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0032709: Samples, MFC - remove samples Viewer2d, Viewer3d, Ocaf, Triangulation, Animation, Convert
This commit is contained in:
53
samples/mfc/standard/03_ImportExport/src/ColoredShapes.cpp
Normal file
53
samples/mfc/standard/03_ImportExport/src/ColoredShapes.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
// ColoredShapes.cpp: implementation of the CColoredShape class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <afxtempl.h>
|
||||
|
||||
#include "ColoredShapes.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CColoredShapes::CColoredShapes()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CColoredShapes::Add(const Quantity_NameOfColor aColor, const TopoDS_Shape& aShape)
|
||||
{
|
||||
m_shapeList.Append(aShape);
|
||||
m_colorMap.Bind(aShape, aColor);
|
||||
}
|
||||
|
||||
void CColoredShapes::Remove(const TopoDS_Shape& aShape)
|
||||
{
|
||||
m_colorMap.UnBind(aShape);
|
||||
for ( TopoDS_ListIteratorOfListOfShape iter(m_shapeList); iter.More(); iter.Next() ) {
|
||||
if(iter.Value() == aShape) {
|
||||
m_shapeList.Remove(iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IMPLEMENT_SERIAL(CColoredShapes, CObject,1);
|
||||
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
// Tools to put Persistent Object in an archive
|
||||
|
||||
void CColoredShapes::Display(Handle(AIS_InteractiveContext)& anAIScontext)
|
||||
{
|
||||
for ( TopoDS_ListIteratorOfListOfShape iter(m_shapeList); iter.More(); iter.Next() )
|
||||
{
|
||||
Handle(AIS_Shape) ais = new AIS_Shape(iter.Value());
|
||||
anAIScontext->SetColor(ais, (Quantity_NameOfColor)m_colorMap.Find(iter.Value()), Standard_False);
|
||||
anAIScontext->SetMaterial(ais, Graphic3d_NameOfMaterial_Gold, Standard_False);
|
||||
anAIScontext->Display(ais, Standard_False);
|
||||
}
|
||||
anAIScontext->UpdateCurrentViewer();
|
||||
}
|
33
samples/mfc/standard/03_ImportExport/src/ColoredShapes.h
Normal file
33
samples/mfc/standard/03_ImportExport/src/ColoredShapes.h
Normal file
@@ -0,0 +1,33 @@
|
||||
// ColoredShape.h: interface for the CColoredShape class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_COLOREDSHAPES_H__C6419AF3_A78A_11D1_8C93_00AA00D10994__INCLUDED_)
|
||||
#define AFX_COLOREDSHAPES_H__C6419AF3_A78A_11D1_8C93_00AA00D10994__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
class CColoredShapes : public CObject
|
||||
{
|
||||
public:
|
||||
CColoredShapes();
|
||||
void Add(const Quantity_NameOfColor aColor, const TopoDS_Shape& aShape);
|
||||
void Remove(const TopoDS_Shape& aShape);
|
||||
|
||||
void Display( Handle(AIS_InteractiveContext)& anAIScontext);
|
||||
|
||||
TopoDS_ListOfShape getShapes();
|
||||
Quantity_NameOfColor getShapeColor(TopoDS_Shape aShape);
|
||||
|
||||
protected:
|
||||
// Declare CArchive >> operator
|
||||
DECLARE_SERIAL(CColoredShapes);
|
||||
|
||||
private:
|
||||
TopTools_DataMapOfShapeInteger m_colorMap;
|
||||
TopoDS_ListOfShape m_shapeList;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_COLOREDSHAPES_H__C6419AF3_A78A_11D1_8C93_00AA00D10994__INCLUDED_)
|
158
samples/mfc/standard/03_ImportExport/src/ImportExportApp.cpp
Normal file
158
samples/mfc/standard/03_ImportExport/src/ImportExportApp.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
// ImportExportApp.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "ImportExportApp.h"
|
||||
|
||||
#include "OCC_MainFrame.h"
|
||||
#include "OCC_3dChildFrame.h"
|
||||
#include "ImportExportDoc.h"
|
||||
#include <OCC_3dView.h>
|
||||
#include <res/resource.h>
|
||||
|
||||
BEGIN_MESSAGE_MAP(CImportExportApp, OCC_App)
|
||||
//{{AFX_MSG_MAP(CSerializeApp)
|
||||
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CImportExportApp construction
|
||||
|
||||
CImportExportApp::CImportExportApp() : OCC_App()
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// The one and only CImportExportApp object
|
||||
|
||||
CImportExportApp theApp;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CImportExportApp initialization
|
||||
|
||||
BOOL CImportExportApp::InitInstance()
|
||||
{
|
||||
// Set the local system units
|
||||
try
|
||||
{
|
||||
UnitsAPI::SetLocalSystem (UnitsAPI_MDTV);
|
||||
}
|
||||
catch (Standard_Failure)
|
||||
{
|
||||
AfxMessageBox (L"Fatal Error in units initialisation");
|
||||
}
|
||||
|
||||
SampleName = "ImportExport"; //for about dialog
|
||||
SetSamplePath (L"..\\..\\05_ImportExport");
|
||||
|
||||
AfxEnableControlContainer();
|
||||
|
||||
// Standard initialization
|
||||
// If you are not using these features and wish to reduce the size
|
||||
// of your final executable, you should remove from the following
|
||||
// the specific initialization routines you do not need.
|
||||
|
||||
// Change the registry key under which our settings are stored.
|
||||
// You should modify this string to be something appropriate
|
||||
// such as the name of your company or organization.
|
||||
// Modified by CasCade :
|
||||
SetRegistryKey(_T("Local CasCade Applications"));
|
||||
|
||||
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
|
||||
|
||||
// Register the application's document templates. Document templates
|
||||
// serve as the connection between documents, frame windows and views.
|
||||
|
||||
CMultiDocTemplate* pDocTemplate;
|
||||
pDocTemplate = new CMultiDocTemplate(
|
||||
IDR_3DTYPE,
|
||||
RUNTIME_CLASS(CImportExportDoc),
|
||||
RUNTIME_CLASS(OCC_3dChildFrame),
|
||||
RUNTIME_CLASS(OCC_3dView));
|
||||
AddDocTemplate(pDocTemplate);
|
||||
|
||||
// create main MDI Frame window
|
||||
OCC_MainFrame* pMainFrame = new OCC_MainFrame(with_AIS_TB);
|
||||
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
|
||||
return FALSE;
|
||||
m_pMainWnd = pMainFrame;
|
||||
|
||||
// Parse command line for standard shell commands, DDE, file open
|
||||
CCommandLineInfo cmdInfo;
|
||||
ParseCommandLine(cmdInfo);
|
||||
|
||||
// Dispatch commands specified on the command line
|
||||
if (!ProcessShellCommand(cmdInfo))
|
||||
return FALSE;
|
||||
|
||||
// The main window has been initialized, so show and update it.
|
||||
pMainFrame->ShowWindow(m_nCmdShow);
|
||||
pMainFrame->UpdateWindow();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CDocument* CImportExportApp::OpenDocumentFile(LPCTSTR lpszFileName)
|
||||
{
|
||||
CFile cf;
|
||||
|
||||
if (!cf.Open(lpszFileName,CFile::modeReadWrite)){
|
||||
AfxMessageBox (L"File not found!");
|
||||
return NULL;
|
||||
}
|
||||
cf.Close();
|
||||
return CWinApp::OpenDocumentFile(lpszFileName);
|
||||
}
|
||||
|
||||
void CImportExportApp::OnFileOpen()
|
||||
{
|
||||
CFileDialog dlg(TRUE,
|
||||
NULL,
|
||||
NULL,
|
||||
OFN_HIDEREADONLY | OFN_FILEMUSTEXIST,
|
||||
NULL,
|
||||
NULL );
|
||||
|
||||
|
||||
CString initdir;
|
||||
initdir.GetEnvironmentVariable (L"CSF_OCCTDataPath");
|
||||
|
||||
dlg.m_ofn.lpstrInitialDir = initdir;
|
||||
|
||||
CString strFilter;
|
||||
CString strDefault;
|
||||
|
||||
POSITION pos = GetFirstDocTemplatePosition();
|
||||
|
||||
CDocTemplate* pTemplate = GetNextDocTemplate(pos);
|
||||
CString strFilterExt, strFilterName;
|
||||
if (pTemplate->GetDocString(strFilterExt, CDocTemplate::filterExt) &&
|
||||
!strFilterExt.IsEmpty() &&
|
||||
pTemplate->GetDocString(strFilterName, CDocTemplate::filterName) &&
|
||||
!strFilterName.IsEmpty()) {
|
||||
// add to filter
|
||||
strFilter += strFilterName;
|
||||
ASSERT(!strFilter.IsEmpty()); // must have a file type name
|
||||
strFilter += L'\0'; // next string please
|
||||
strFilter += L'*';
|
||||
strFilter += strFilterExt;
|
||||
strFilter += L'\0'; // next string please
|
||||
dlg.m_ofn.nMaxCustFilter++;
|
||||
}
|
||||
// append the "*.*" all files filter
|
||||
CString allFilter;
|
||||
VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER));
|
||||
strFilter += allFilter;
|
||||
strFilter += L'\0'; // next string please
|
||||
strFilter += L"*.*";
|
||||
strFilter += L'\0'; // last string
|
||||
dlg.m_ofn.nMaxCustFilter++;
|
||||
dlg.m_ofn.lpstrFilter = strFilter;
|
||||
|
||||
if (dlg.DoModal() == IDOK)
|
||||
{
|
||||
AfxGetApp()->OpenDocumentFile(dlg.GetPathName());
|
||||
}
|
||||
}
|
38
samples/mfc/standard/03_ImportExport/src/ImportExportApp.h
Normal file
38
samples/mfc/standard/03_ImportExport/src/ImportExportApp.h
Normal file
@@ -0,0 +1,38 @@
|
||||
// ImportExportApp.h : main header file for the IMPORTEXPORT application
|
||||
//
|
||||
|
||||
#if !defined(AFX_IMPORTEXPORT_H__88A21474_3B23_11D2_8E1E_0800369C8A03__INCLUDED_)
|
||||
#define AFX_IMPORTEXPORT_H__88A21474_3B23_11D2_8E1E_0800369C8A03__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include <OCC_App.h>
|
||||
|
||||
class CImportExportApp : public OCC_App
|
||||
{
|
||||
public:
|
||||
|
||||
CImportExportApp();
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CImportExportApp)
|
||||
public:
|
||||
virtual BOOL InitInstance();
|
||||
virtual CDocument* OpenDocumentFile(LPCTSTR lpszFileName);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
protected:
|
||||
|
||||
//{{AFX_MSG(CSerializeApp)
|
||||
afx_msg void OnFileOpen();
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // !defined(AFX_IMPORTEXPORT_H__88A21474_3B23_11D2_8E1E_0800369C8A03__INCLUDED_)
|
288
samples/mfc/standard/03_ImportExport/src/ImportExportDoc.cpp
Normal file
288
samples/mfc/standard/03_ImportExport/src/ImportExportDoc.cpp
Normal file
@@ -0,0 +1,288 @@
|
||||
// ImportExportDoc.cpp : implementation of the CImportExportDoc class
|
||||
//
|
||||
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "ImportExportApp.h"
|
||||
|
||||
#include "ImportExportDoc.h"
|
||||
|
||||
#include <ImportExport/ImportExport.h>
|
||||
|
||||
#include <AISDialogs.h>
|
||||
#include "res/resource.h"
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
//#define new DEBUG_NEW // by cascade
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CImportExportDoc
|
||||
|
||||
IMPLEMENT_DYNCREATE(CImportExportDoc, OCC_3dDoc)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CImportExportDoc, OCC_3dDoc)
|
||||
//{{AFX_MSG_MAP(CImportExportDoc)
|
||||
ON_COMMAND(ID_FILE_IMPORT_BREP, OnFileImportBrep)
|
||||
ON_COMMAND(ID_FILE_IMPORT_IGES, OnFileImportIges)
|
||||
ON_COMMAND(ID_FILE_EXPORT_IGES, OnFileExportIges)
|
||||
ON_COMMAND(ID_FILE_IMPORT_STEP, OnFileImportStep)
|
||||
ON_COMMAND(ID_FILE_EXPORT_STEP, OnFileExportStep)
|
||||
ON_COMMAND(ID_FILE_EXPORT_VRML, OnFileExportVrml)
|
||||
ON_COMMAND(ID_FILE_EXPORT_STL, OnFileExportStl)
|
||||
ON_COMMAND(ID_BOX, OnBox)
|
||||
ON_COMMAND(ID_Cylinder, OnCylinder)
|
||||
ON_COMMAND(ID_OBJECT_REMOVE, OnObjectRemove)
|
||||
ON_COMMAND(ID_OBJECT_ERASE, OnObjectErase)
|
||||
ON_COMMAND(ID_OBJECT_DISPLAYALL, OnObjectDisplayall)
|
||||
//}}AFX_MSG_MAP
|
||||
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CImportExportDoc construction/destruction
|
||||
|
||||
CImportExportDoc::CImportExportDoc()
|
||||
: OCC_3dDoc (false)
|
||||
{
|
||||
/*
|
||||
// TRIHEDRON
|
||||
Handle(AIS_Trihedron) aTrihedron;
|
||||
Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
|
||||
aTrihedron=new AIS_Trihedron(aTrihedronAxis);
|
||||
myAISContext->Display(aTrihedron);
|
||||
*/
|
||||
|
||||
m_pcoloredshapeList = new CColoredShapes();
|
||||
}
|
||||
|
||||
CImportExportDoc::~CImportExportDoc()
|
||||
{
|
||||
if( m_pcoloredshapeList ) delete m_pcoloredshapeList;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSerializeDoc serialization
|
||||
|
||||
void CImportExportDoc::Serialize(CArchive& ar)
|
||||
{
|
||||
if (ar.IsStoring())
|
||||
{
|
||||
// Put the current CColoredShape in the archive
|
||||
ar << m_pcoloredshapeList;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read from the archive the current CColoredShape
|
||||
ar >> m_pcoloredshapeList;
|
||||
|
||||
// Display the new object
|
||||
m_pcoloredshapeList->Display(myAISContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void CImportExportDoc::OnWindowNew3d()
|
||||
{
|
||||
((CImportExportApp*)AfxGetApp())->CreateView3D(this);
|
||||
}
|
||||
*/
|
||||
|
||||
// nCmdShow could be : ( default is SW_RESTORE )
|
||||
// SW_HIDE SW_SHOWNORMAL SW_NORMAL
|
||||
// SW_SHOWMINIMIZED SW_SHOWMAXIMIZED
|
||||
// SW_MAXIMIZE SW_SHOWNOACTIVATE
|
||||
// SW_SHOW SW_MINIMIZE
|
||||
// SW_SHOWMINNOACTIVE SW_SHOWNA
|
||||
// SW_RESTORE SW_SHOWDEFAULT
|
||||
// SW_MAX
|
||||
|
||||
// use pViewClass = RUNTIME_CLASS( CImportExportView3D ) for 3D Views
|
||||
|
||||
void CImportExportDoc::ActivateFrame(CRuntimeClass* pViewClass,int nCmdShow)
|
||||
{
|
||||
POSITION position = GetFirstViewPosition();
|
||||
while (position != (POSITION)NULL)
|
||||
{
|
||||
CView* pCurrentView = (CView*)GetNextView(position);
|
||||
if(pCurrentView->IsKindOf(pViewClass) )
|
||||
{
|
||||
ASSERT_VALID(pCurrentView);
|
||||
CFrameWnd* pParentFrm = pCurrentView->GetParentFrame();
|
||||
ASSERT(pParentFrm != (CFrameWnd *)NULL);
|
||||
// simply make the frame window visible
|
||||
pParentFrm->ActivateFrame(nCmdShow);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CImportExportDoc diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CImportExportDoc::AssertValid() const
|
||||
{
|
||||
CDocument::AssertValid();
|
||||
}
|
||||
|
||||
void CImportExportDoc::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CDocument::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CImportExportDoc commands
|
||||
|
||||
|
||||
void CImportExportDoc::OnFileImportBrep()
|
||||
{
|
||||
Handle(TopTools_HSequenceOfShape) aSeqOfShape = CImportExport::ReadBREP();
|
||||
for(int i=1;i<= aSeqOfShape->Length();i++)
|
||||
{
|
||||
m_pcoloredshapeList->Add(Quantity_NOC_YELLOW, aSeqOfShape->Value(i));
|
||||
m_pcoloredshapeList->Display(myAISContext);
|
||||
}
|
||||
Fit();
|
||||
}
|
||||
|
||||
void CImportExportDoc::OnFileImportIges()
|
||||
{
|
||||
Handle(TopTools_HSequenceOfShape) aSeqOfShape = CImportExport::ReadIGES();
|
||||
for(int i=1;i<= aSeqOfShape->Length();i++)
|
||||
{
|
||||
m_pcoloredshapeList->Add(Quantity_NOC_YELLOW, aSeqOfShape->Value(i));
|
||||
m_pcoloredshapeList->Display(myAISContext);
|
||||
}
|
||||
Fit();
|
||||
}
|
||||
void CImportExportDoc::OnFileExportIges()
|
||||
{ CImportExport::SaveIGES(myAISContext);}
|
||||
|
||||
void CImportExportDoc::OnFileImportStep()
|
||||
{
|
||||
Handle(TopTools_HSequenceOfShape) aSeqOfShape = CImportExport::ReadSTEP();
|
||||
for(int i=1;i<= aSeqOfShape->Length();i++)
|
||||
{
|
||||
m_pcoloredshapeList->Add(Quantity_NOC_YELLOW, aSeqOfShape->Value(i));
|
||||
m_pcoloredshapeList->Display(myAISContext);
|
||||
}
|
||||
Fit();
|
||||
}
|
||||
void CImportExportDoc::OnFileExportStep()
|
||||
{ CImportExport::SaveSTEP(myAISContext);}
|
||||
|
||||
|
||||
void CImportExportDoc::OnFileExportVrml()
|
||||
{ CImportExport::SaveVRML(myAISContext);}
|
||||
|
||||
void CImportExportDoc::OnFileExportStl()
|
||||
{ CImportExport::SaveSTL(myAISContext);}
|
||||
|
||||
void CImportExportDoc::Popup(const Standard_Integer x,
|
||||
const Standard_Integer y ,
|
||||
const Handle(V3d_View)& aView )
|
||||
{
|
||||
Standard_Integer PopupMenuNumber=0;
|
||||
myAISContext->InitSelected();
|
||||
if (myAISContext->MoreSelected())
|
||||
PopupMenuNumber=1;
|
||||
|
||||
CMenu menu;
|
||||
VERIFY(menu.LoadMenu(IDR_Popup3D));
|
||||
CMenu* pPopup = menu.GetSubMenu(PopupMenuNumber);
|
||||
|
||||
ASSERT(pPopup != NULL);
|
||||
if (PopupMenuNumber == 1) // more than 1 object.
|
||||
{
|
||||
bool OneOrMoreInShading = false;
|
||||
for (myAISContext->InitSelected();myAISContext->MoreSelected ();myAISContext->NextSelected ())
|
||||
if (myAISContext->IsDisplayed(myAISContext->SelectedInteractive(),1)) OneOrMoreInShading=true;
|
||||
if(!OneOrMoreInShading)
|
||||
pPopup->EnableMenuItem(5, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
|
||||
}
|
||||
|
||||
POINT winCoord = { x , y };
|
||||
Handle(WNT_Window) aWNTWindow=
|
||||
Handle(WNT_Window)::DownCast(aView->Window());
|
||||
ClientToScreen ( (HWND)(aWNTWindow->HWindow()),&winCoord);
|
||||
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON , winCoord.x, winCoord.y ,
|
||||
AfxGetMainWnd());
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CImportExportDoc::OnBox()
|
||||
{
|
||||
AIS_ListOfInteractive aList;
|
||||
myAISContext->DisplayedObjects(aList);
|
||||
AIS_ListIteratorOfListOfInteractive aListIterator;
|
||||
for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
|
||||
myAISContext->Remove (aListIterator.Value(), Standard_False);
|
||||
}
|
||||
|
||||
BRepPrimAPI_MakeBox B(200.,150.,100.);
|
||||
|
||||
m_pcoloredshapeList->Add(Quantity_NOC_YELLOW, B.Shape());
|
||||
|
||||
m_pcoloredshapeList->Display(myAISContext);
|
||||
Fit();
|
||||
|
||||
// document has been modified
|
||||
SetModifiedFlag(TRUE);
|
||||
}
|
||||
|
||||
void CImportExportDoc::OnCylinder()
|
||||
{
|
||||
AIS_ListOfInteractive aList;
|
||||
myAISContext->DisplayedObjects(aList);
|
||||
AIS_ListIteratorOfListOfInteractive aListIterator;
|
||||
for(aListIterator.Initialize(aList);aListIterator.More();aListIterator.Next()){
|
||||
myAISContext->Remove (aListIterator.Value(), Standard_False);
|
||||
}
|
||||
|
||||
BRepPrimAPI_MakeCylinder C(50.,200.);
|
||||
|
||||
m_pcoloredshapeList->Add(Quantity_NOC_GREEN, C.Shape());
|
||||
|
||||
m_pcoloredshapeList->Display(myAISContext);
|
||||
Fit();
|
||||
|
||||
// document has been modified
|
||||
SetModifiedFlag(TRUE);
|
||||
}
|
||||
void CImportExportDoc::OnObjectRemove()
|
||||
|
||||
{
|
||||
for(GetAISContext()->InitSelected();GetAISContext()->MoreSelected();GetAISContext()->NextSelected()) {
|
||||
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(GetAISContext()->SelectedInteractive());
|
||||
if(!aShape.IsNull()) {
|
||||
m_pcoloredshapeList->Remove(aShape->Shape());
|
||||
}
|
||||
}
|
||||
OCC_3dBaseDoc::OnObjectRemove();
|
||||
}
|
||||
|
||||
void CImportExportDoc::OnObjectErase()
|
||||
|
||||
{
|
||||
for(GetAISContext()->InitSelected();GetAISContext()->MoreSelected();GetAISContext()->NextSelected()) {
|
||||
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(GetAISContext()->SelectedInteractive());
|
||||
if(!aShape.IsNull()) {
|
||||
m_pcoloredshapeList->Remove(aShape->Shape());
|
||||
}
|
||||
}
|
||||
OCC_3dBaseDoc::OnObjectErase();
|
||||
}
|
||||
|
||||
void CImportExportDoc::OnObjectDisplayall()
|
||||
|
||||
{
|
||||
OCC_3dBaseDoc::OnObjectDisplayall();
|
||||
}
|
64
samples/mfc/standard/03_ImportExport/src/ImportExportDoc.h
Normal file
64
samples/mfc/standard/03_ImportExport/src/ImportExportDoc.h
Normal file
@@ -0,0 +1,64 @@
|
||||
// ImportExportDoc.h : interface of the CImportExportDoc class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_IMPORTEXPORTDOC_H__88A2147C_3B23_11D2_8E1E_0800369C8A03__INCLUDED_)
|
||||
#define AFX_IMPORTEXPORTDOC_H__88A2147C_3B23_11D2_8E1E_0800369C8A03__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#include <ColoredShapes.h>
|
||||
#include <OCC_3dDoc.h>
|
||||
|
||||
class CImportExportDoc : public OCC_3dDoc
|
||||
{
|
||||
DECLARE_DYNCREATE(CImportExportDoc)
|
||||
public:
|
||||
CImportExportDoc();
|
||||
virtual ~CImportExportDoc();
|
||||
virtual void Serialize(CArchive& ar);
|
||||
|
||||
void ActivateFrame(CRuntimeClass* pViewClass, int nCmdShow = SW_RESTORE );
|
||||
virtual void Popup (const Standard_Integer x ,
|
||||
const Standard_Integer y ,
|
||||
const Handle(V3d_View)& aView );
|
||||
|
||||
|
||||
// Implementation
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CImportExportDoc)
|
||||
afx_msg void OnFileImportIges();
|
||||
afx_msg void OnFileExportIges();
|
||||
afx_msg void OnFileImportStep();
|
||||
afx_msg void OnFileExportStep();
|
||||
afx_msg void OnFileImportBrep();
|
||||
// afx_msg void OnWindowNew3d();
|
||||
afx_msg void OnFileExportVrml();
|
||||
afx_msg void OnFileExportStl();
|
||||
afx_msg void OnBox();
|
||||
afx_msg void OnCylinder();
|
||||
afx_msg void OnObjectRemove();
|
||||
afx_msg void OnObjectErase();
|
||||
afx_msg void OnObjectDisplayall();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
//Attributes
|
||||
protected:
|
||||
CColoredShapes* m_pcoloredshapeList;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_IMPORTEXPORTDOC_H__88A2147C_3B23_11D2_8E1E_0800369C8A03__INCLUDED_)
|
6
samples/mfc/standard/03_ImportExport/src/StdAfx.cpp
Normal file
6
samples/mfc/standard/03_ImportExport/src/StdAfx.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// SampleImportExport.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
161
samples/mfc/standard/03_ImportExport/src/StdAfx.h
Normal file
161
samples/mfc/standard/03_ImportExport/src/StdAfx.h
Normal file
@@ -0,0 +1,161 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__88A21476_3B23_11D2_8E1E_0800369C8A03__INCLUDED_)
|
||||
#define AFX_STDAFX_H__88A21476_3B23_11D2_8E1E_0800369C8A03__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
|
||||
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <afxwin.h> // MFC core and standard components
|
||||
#include <afxext.h> // MFC extensions
|
||||
#include <afxdisp.h> // MFC OLE automation classes
|
||||
#ifndef _AFX_NO_AFXCMN_SUPPORT
|
||||
#include <afxcmn.h> // MFC support for Windows Common Controls
|
||||
#endif // _AFX_NO_AFXCMN_SUPPORT
|
||||
|
||||
#define DEFAULT_DEVIATIONCOEFFICIENT 0.001
|
||||
#define DEFAULT_DCBIG 0.005
|
||||
#define DEFAULT_DCVBIG 0.01
|
||||
#define DEFAULT_DCSMALL 0.0002
|
||||
#define DEFAULT_DCVSMALL 0.00004
|
||||
#define DEFAULT_COLOR Quantity_NOC_CYAN1
|
||||
#define DEFAULT_MATERIAL Graphic3d_NameOfMaterial_Plastered
|
||||
#define DEFAULT_BACKGROUNDCOLOR Quantity_NOC_MATRAGRAY
|
||||
#define DEFAULT_HILIGHTCOLOR Quantity_NOC_YELLOW
|
||||
|
||||
#pragma warning( disable : 4244 ) // Issue warning 4244
|
||||
#include <Standard_ShortReal.hxx>
|
||||
#pragma warning( default : 4244 ) // Issue warning 4244
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <AIS_ListOfInteractive.hxx>
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <AIS_Trihedron.hxx>
|
||||
|
||||
#include <Aspect_Background.hxx>
|
||||
#include <Aspect_TypeOfline.hxx>
|
||||
#include <Aspect_WidthOfline.hxx>
|
||||
#include <Aspect_Window.hxx>
|
||||
#include <Bnd_Box2d.hxx>
|
||||
#include <BndLib_Add2dCurve.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
|
||||
#include <BRepBuilderAPI.hxx>
|
||||
#include <BRepAlgo.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRepPrimAPI_MakeBox.hxx>
|
||||
#include <BRepPrimAPI_MakeCylinder.hxx>
|
||||
#include <Standard_DefineHandle.hxx>
|
||||
#include <DsgPrs_LengthPresentation.hxx>
|
||||
#include <GCE2d_MakeSegment.hxx>
|
||||
#include <GCPnts_TangentialDeflection.hxx>
|
||||
#include <Geom_CartesianPoint.hxx>
|
||||
#include <Geom_Axis2Placement.hxx>
|
||||
#include <Geom_CartesianPoint.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <Geom2d_BezierCurve.hxx>
|
||||
#include <Geom2d_BSplineCurve.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
#include <Geom2dAdaptor_Curve.hxx>
|
||||
#include <GeomAbs_CurveType.hxx>
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
#include <GeomTools_Curve2dSet.hxx>
|
||||
#include <gp_Ax2d.hxx>
|
||||
#include <gp_Circ2d.hxx>
|
||||
#include <gp_Dir2d.hxx>
|
||||
#include <gp_Lin2d.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
#include <OSD_Environment.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_IsoAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
#include <Quantity_NameOfColor.hxx>
|
||||
#include <Quantity_TypeOfColor.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <SelectMgr_SelectableObject.hxx>
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
#include <SelectMgr_SelectionManager.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_CString.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_IStream.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <StdPrs_Curve.hxx>
|
||||
#include <StdPrs_Point.hxx>
|
||||
#include <StdPrs_PoleCurve.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <TColgp_HArray1OfPnt2d.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TColStd_HSequenceOfTransient.hxx>
|
||||
#include <TColStd_MapIteratorOfMapOfTransient.hxx>
|
||||
#include <TColStd_MapOfTransient.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
#include <TopoDS_ListIteratorOfListOfShape.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Solid.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
#include <TopTools_HSequenceOfShape.hxx>
|
||||
#include <TopTools_DataMapOfShapeInteger.hxx>
|
||||
#include <UnitsAPI.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
#include <V3d_Viewer.hxx>
|
||||
#include <WNT_Window.hxx>
|
||||
|
||||
// specific STEP
|
||||
|
||||
#include <STEPControl_Controller.hxx>
|
||||
#include <STEPControl_Reader.hxx>
|
||||
#include <STEPControl_Writer.hxx>
|
||||
|
||||
|
||||
// specific IGES
|
||||
#include <Interface_InterfaceModel.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
|
||||
#include <IGESControl_Controller.hxx>
|
||||
#include <IGESControl_Writer.hxx>
|
||||
|
||||
#include <IGESToBRep_Actor.hxx>
|
||||
#include <IGESToBRep_Reader.hxx>
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
|
||||
#include <STEPControl_StepModelType.hxx>
|
||||
|
||||
//#include <TransferBRep_Analyzer.hxx>
|
||||
|
||||
// specific STL VRML
|
||||
#include "StlAPI_Writer.hxx"
|
||||
#include "VrmlAPI_Writer.hxx"
|
||||
|
||||
//End CasCade
|
||||
|
||||
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__88A21476_3B23_11D2_8E1E_0800369C8A03__INCLUDED_)
|
Reference in New Issue
Block a user