1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0024372: HLR Sample: erased objects are shown in HLR

Compilation errors were corrected.
Removed .aps files
Sample paths fields were updated to read help file from sample folder.
This commit is contained in:
aba 2013-12-05 15:39:48 +04:00 committed by bugmaster
parent ef2d8af761
commit b3837d74e0
34 changed files with 315 additions and 187 deletions

View File

@ -17,7 +17,8 @@
CGeometryApp::CGeometryApp() : OCC_App()
{
SampleName = "Geometry"; //for about dialog
SampleName = "Geometry"; //for about dialog
SetSamplePath ("..\\..\\01_Geometry");
}
CGeometryApp::~CGeometryApp()

View File

@ -18,6 +18,7 @@
CModelingApp::CModelingApp() : OCC_App()
{
SampleName = "Modeling"; //for about dialog
SetSamplePath ("..\\..\\02_Modeling");
}
/////////////////////////////////////////////////////////////////////////////

View File

@ -1,9 +1,9 @@
Viewer2d sample demonstrates how the functionality of TKV3d package can be used
for 2D visualization. It provides samples of 2D objects visualization,
Viewer2d sample demonstrates how the functionality of TKV3d package can be
used for 2D visualization. It provides samples of 2D objects visualization,
dynamic selection and highlighting.
It illustratea how to:
1) implement 2D view behavior with V3d_View class, with interactive zooming and
panning of the 2D scene;
It illustrates how to:
1) implement 2D view behavior with V3d_View class, with interactive zooming
and panning of the 2D scene;
2) draw 2D primitives like rectangles, lines, curves;
3) draw different types of markers;
4) draw text defined by its font, height, style, angle;

View File

@ -22,6 +22,7 @@ static char THIS_FILE[] = __FILE__;
CViewer2dApp::CViewer2dApp() : OCC_App()
{
SampleName = "Viewer2d"; //for about dialog
SetSamplePath ("..\\..\\03_Viewer2d");
}
/////////////////////////////////////////////////////////////////////////////

View File

@ -59,7 +59,7 @@ TexturesExt_Presentation::TexturesExt_Presentation()
void TexturesExt_Presentation::DoSample()
{
((CViewer3dApp*) AfxGetApp())->SetSampleName("Viewer3d");
((CViewer3dApp*) AfxGetApp())->SetSamplePath("..\\..\\04_Viewer3d");
((CViewer3dApp*) AfxGetApp())->SetSamplePath ("..\\..\\04_Viewer3d");
getAISContext()->EraseAll();
if (myIndex >=0 && myIndex < myNbSamples)
{

View File

@ -29,6 +29,7 @@ END_MESSAGE_MAP()
CViewer3dApp::CViewer3dApp() : OCC_App()
{
SampleName = "Viewer3d"; //for about dialog
SetSamplePath ("..\\..\\03_Viewer3d");
}
/////////////////////////////////////////////////////////////////////////////

View File

@ -33,6 +33,7 @@ CImportExportApp::CImportExportApp() : OCC_App()
}
SampleName = "ImportExport"; //for about dialog
SetSamplePath ("..\\..\\05_ImportExport");
}
/////////////////////////////////////////////////////////////////////////////

View File

@ -35,9 +35,9 @@ END_MESSAGE_MAP()
COcafApp::COcafApp() : OCC_App()
{
SetSamplePath("06_Ocaf");
myApp = new TOcaf_Application();
SampleName = "OCAF"; //for about dialog
SetSamplePath ("..\\..\\06_Ocaf");
try
{

View File

@ -16,6 +16,7 @@
CTriangulationApp::CTriangulationApp() : OCC_App()
{
SampleName = "TopologyTriangulation"; //for about dialog
SetSamplePath("..\\..\\07_Triangulation");
}
/////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,12 @@
HLR sample demonstrates hidden line removal algorithm.
It supports exact and polygonal HLR algorihms.
To try HLR you need to follow some steps:
1) to import model, which will displayed in 3d view.
2) to choose "File->Process HLR" or press "HLR' button in the toolbar.
Dialog with options of HLR will be opened.
3) to press "Get shapes" button of the HLR dialog to
display results in the 2d view.
Optionally, this dialog allow to view chosen shapes
in his own view. Here you can choose needed direction
of view and press "Update 2d" button to update shapes HLR 2d view.

View File

@ -343,6 +343,7 @@ BEGIN
MENUITEM "&New\tCtrl+N", ID_FILE_NEW
MENUITEM "&Close", ID_FILE_CLOSE
MENUITEM SEPARATOR
MENUITEM "Process HLR", ID_FILE_HLR
POPUP "Import"
BEGIN
MENUITEM "BRep...", ID_FILE_IMPORT_BREP
@ -443,7 +444,8 @@ END
STRINGTABLE
BEGIN
ID_BUTTON_HLRDialog "Display The HLR Dialog \nHLR Dialog"
ID_BUTTON_HLRDialog "Open the HLR dialog \nHLR dialog"
ID_FILE_HLR "Open the HLR dialog \nHLR dialog"
END
#endif // English (U.S.) resources

View File

@ -111,7 +111,8 @@
#define IDC_BackView 1534
#define IDC_FrontView 1535
#define IDC_AxoView 1536
#define ID_BUTTON_HLRDialog 32795
#define ID_BUTTON_HLRDialog 1537
#define ID_FILE_HLR 1539
// Next default values for new objects
//
@ -119,7 +120,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 173
#define _APS_NEXT_COMMAND_VALUE 32796
#define _APS_NEXT_COMMAND_VALUE 32797
#define _APS_NEXT_CONTROL_VALUE 1538
#define _APS_NEXT_SYMED_VALUE 170
#endif

View File

@ -28,6 +28,7 @@ static char THIS_FILE[] = __FILE__;
CHLRApp::CHLRApp() : OCC_App()
{
SampleName = "HLR"; //for about dialog
SetSamplePath ("..\\..\\08_HLR");
}
CHLRApp::~CHLRApp()

View File

@ -30,8 +30,10 @@ BEGIN_MESSAGE_MAP(CHLRDoc, OCC_3dBaseDoc)
//{{AFX_MSG_MAP(CHLRDoc)
ON_COMMAND(ID_WINDOW_NEW3D, OnWindowNew3d)
ON_COMMAND(ID_WINDOW_NEW2D, OnWindowNew2d)
ON_COMMAND(ID_FILE_HLR, OnBUTTONHLRDialog)
ON_COMMAND(ID_FILE_IMPORT_BREP, OnFileImportBrep)
ON_COMMAND(ID_BUTTON_HLRDialog, OnBUTTONHLRDialog)
ON_COMMAND(ID_OBJECT_ERASE, OnObjectErase)
//}}AFX_MSG_MAP
@ -83,17 +85,17 @@ CHLRDoc::~CHLRDoc()
}
}
void CHLRDoc::OnWindowNew2d()
void CHLRDoc::OnWindowNew2d()
{
((CHLRApp*)AfxGetApp())->CreateView2D(this);
((CHLRApp*)AfxGetApp())->CreateView2D(this);
}
void CHLRDoc::OnWindowNew3d()
void CHLRDoc::OnWindowNew3d()
{
((CHLRApp*)AfxGetApp())->CreateView3D(this);
((CHLRApp*)AfxGetApp())->CreateView3D(this);
}
// nCmdShow could be : ( default is SW_RESTORE )
// nCmdShow could be : ( default is SW_RESTORE )
// SW_HIDE SW_SHOWNORMAL SW_NORMAL
// SW_SHOWMINIMIZED SW_SHOWMAXIMIZED
// SW_MAXIMIZE SW_SHOWNOACTIVATE
@ -154,7 +156,7 @@ void CHLRDoc::Dump(CDumpContext& dc) const
/////////////////////////////////////////////////////////////////////////////
// CHLRDoc commands
void CHLRDoc::OnBUTTONHLRDialog()
void CHLRDoc::OnBUTTONHLRDialog()
{
if (!myCSelectionDialogIsCreated)
{
@ -162,7 +164,7 @@ void CHLRDoc::OnBUTTONHLRDialog()
myCSelectionDialog->Create(CSelectionDialog::IDD, AfxGetMainWnd());
myCSelectionDialogIsCreated = true;
}
myCSelectionDialog->ShowWindow(SW_RESTORE);
myCSelectionDialog->ShowWindow(SW_RESTORE);
}
void CHLRDoc::OnFileImportBrep()
@ -181,3 +183,25 @@ void CHLRDoc::Fit()
}
}
}
void CHLRDoc::OnObjectErase()
{
Standard_Boolean toUpdateDisplayable = Standard_False;
for (myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent())
{
myAISContext->Erase (myAISContext->Current(), Standard_True);
if (myAISContext->Current()->Type() == AIS_KOI_Shape && myCSelectionDialogIsCreated)
{
myCSelectionDialog->DiplayableShape()->Remove (Handle(AIS_Shape)::DownCast (myAISContext->Current())->Shape());
toUpdateDisplayable = Standard_True;
}
}
myAISContext->ClearCurrents();
if (toUpdateDisplayable)
{
// Update view in the HLR dialog if list of displayable shapes has been changed.
myCSelectionDialog->UpdateViews();
}
}

View File

@ -39,6 +39,7 @@ protected:
afx_msg void OnWindowNew2d();
afx_msg void OnFileImportBrep();
afx_msg void OnBUTTONHLRDialog();
afx_msg void OnObjectErase();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

View File

@ -22,11 +22,11 @@ static char THIS_FILE[] = __FILE__;
/////////////////////////////////////////////////////////////////////////////
// CSelectionDialog dialog
CSelectionDialog::CSelectionDialog(CHLRDoc* aDoc,CWnd* pParent /*=NULL*/)
CSelectionDialog::CSelectionDialog (CHLRDoc* aDoc,CWnd* pParent /*=NULL*/)
: CDialog(CSelectionDialog::IDD, pParent)
{
myDoc = aDoc;
myDisplay = false;
myIsDisplayed = false;
//{{AFX_DATA_INIT(CSelectionDialog)
m_Algo = 0;
m_DisplayMode = 0;
@ -36,7 +36,7 @@ CSelectionDialog::CSelectionDialog(CHLRDoc* aDoc,CWnd* pParent /*=NULL*/)
//}}AFX_DATA_INIT
}
void CSelectionDialog::DoDataExchange(CDataExchange* pDX)
void CSelectionDialog::DoDataExchange (CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSelectionDialog)
@ -51,7 +51,7 @@ void CSelectionDialog::DoDataExchange(CDataExchange* pDX)
BEGIN_MESSAGE_MAP(CSelectionDialog, CDialog)
//{{AFX_MSG_MAP(CSelectionDialog)
ON_BN_CLICKED(ID_GetShape, OnGetShape)
ON_BN_CLICKED(ID_GetShape, OnGetSelectedShapes)
ON_BN_CLICKED(IDC_DisplayDefault, OnDisplayDefault)
ON_BN_CLICKED(IDC_VIsoParametrics, OnVIsoParametrics)
ON_BN_CLICKED(IDC_VApparentContour, OnVApparentContour)
@ -89,136 +89,171 @@ END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSelectionDialog message handlers
BOOL CSelectionDialog::OnInitDialog()
BOOL CSelectionDialog::OnInitDialog()
{
CDialog::OnInitDialog();
VERIFY(TopView.AutoLoad(IDC_TopView, this));
VERIFY(BottomView.AutoLoad(IDC_BottomView, this)) ;
VERIFY(LeftView .AutoLoad(IDC_LeftView , this)) ;
VERIFY(RightView .AutoLoad(IDC_RightView , this)) ;
VERIFY(FrontView .AutoLoad(IDC_FrontView , this)) ;
VERIFY(BackView .AutoLoad(IDC_BackView , this)) ;
VERIFY(AxoView .AutoLoad(IDC_AxoView , this)) ;
VERIFY(TopView.AutoLoad (IDC_TopView, this));
VERIFY(BottomView.AutoLoad (IDC_BottomView, this)) ;
VERIFY(LeftView .AutoLoad (IDC_LeftView , this)) ;
VERIFY(RightView .AutoLoad (IDC_RightView , this)) ;
VERIFY(FrontView .AutoLoad (IDC_FrontView , this)) ;
VERIFY(BackView .AutoLoad (IDC_BackView , this)) ;
VERIFY(AxoView .AutoLoad (IDC_AxoView , this)) ;
// get the View Window position to managed mouse move
CRect BoxRect,ViewRect;
GetWindowRect(BoxRect);
CWnd * TheViewerWindow = GetDlgItem(IDC_DUMMYBUTTON);
TheViewerWindow->GetWindowRect(ViewRect);
GetWindowRect (BoxRect);
CWnd * TheViewerWindow = GetDlgItem (IDC_DUMMYBUTTON);
TheViewerWindow->GetWindowRect (ViewRect);
myPosMinX = ViewRect.TopLeft().x - BoxRect.TopLeft().x;
myPosMaxX = ViewRect.Width()+myPosMinX;
myPosMinY = ViewRect.TopLeft().y - BoxRect.TopLeft().y;
myPosMaxY = myPosMinY + ViewRect.Height();
ShowHideButton(Standard_False);
OnDisplay(true);
ShowHideButton (Standard_False);
OnDisplay (true);
return TRUE; // return TRUE unless you set the focus to a control
// return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
return TRUE;
}
void CSelectionDialog::OnDisplay(bool isFit)
void CSelectionDialog::OnDisplay (bool isFit)
{
GetDlgItem(IDC_DUMMYBUTTON)->SetRedraw(true);
if(!myDisplay) {
GetDlgItem(IDC_DUMMYBUTTON)->SetRedraw (true);
if (!myIsDisplayed)
{
Handle(Graphic3d_GraphicDriver) aGraphicDriver =
((CHLRApp*)AfxGetApp())->GetGraphicDriver();
myActiveViewer = new V3d_Viewer(aGraphicDriver,(short *) "Visu3D");
myActiveViewer = new V3d_Viewer (aGraphicDriver, (short *) "Visu3D");
myActiveViewer->SetDefaultLights();
myActiveViewer->SetLightOn();
myActiveView = myActiveViewer->CreateView();
Handle(WNT_Window) aWNTWindow = new WNT_Window (GetDlgItem(IDC_DUMMYBUTTON)->GetSafeHwnd(),
Handle(WNT_Window) aWNTWindow = new WNT_Window (GetDlgItem (IDC_DUMMYBUTTON)->GetSafeHwnd(),
Quantity_NOC_GRAY);
myActiveView->SetComputedMode (m_HlrModeIsOn);
myActiveView->SetWindow(aWNTWindow);
myInteractiveContext = new AIS_InteractiveContext(myActiveViewer);
myInteractiveContext = new AIS_InteractiveContext (myActiveViewer);
// TRIHEDRON
Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
myTrihedron=new AIS_Trihedron(aTrihedronAxis);
Handle(Geom_Axis2Placement) aTrihedronAxis = new Geom_Axis2Placement (gp::XOY());
myTrihedron = new AIS_Trihedron (aTrihedronAxis);
myInteractiveContext->Display(myTrihedron);
myInteractiveContext->Display (myTrihedron);
}
if(isFit) {
if(isFit)
{
myActiveView->ZFitAll();
myActiveView->FitAll();
}
myActiveView->Redraw();
myDisplay = Standard_True;
GetDlgItem(IDC_DUMMYBUTTON)->SetRedraw(false);
myIsDisplayed = Standard_True;
GetDlgItem (IDC_DUMMYBUTTON)->SetRedraw (false);
}
void CSelectionDialog::SetTitle(CString & aTitle)
void CSelectionDialog::SetTitle (const CString & aTitle)
{
SetWindowText(aTitle);
SetWindowText (aTitle);
}
void CSelectionDialog::OnGetShape()
void CSelectionDialog::UpdateViews()
{
UpdateData(true);
myDoc->GetInteractiveContext2D()->RemoveAll();
myDisplayableShape = new ISession2D_Shape( );
// Clear HLR dialog view
myInteractiveContext->RemoveAll();
myInteractiveContext->Display (myTrihedron);
UpdateProjector();
myDisplayableShape->SetNbIsos(m_NbIsos);
myInteractiveContext->EraseAll();
myInteractiveContext->Display(myTrihedron);
// Display chosen shapes in the HLR dialog view.
Standard_Boolean OneOrMoreFound = Standard_False;
for (myDoc->GetAISContext()->InitCurrent();
myDoc->GetAISContext()->MoreCurrent();
myDoc->GetAISContext()->NextCurrent())
{
Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast (myDoc->GetAISContext()->Current());
if (!anAISShape.IsNull())
{
OneOrMoreFound = Standard_True;
myInteractiveContext->Display (anAISShape);
}
}
// Apply HLR to chosen shapes and display result into the 2d view.
Apply();
// Update viewer
myDoc->FitAll2DViews (Standard_False);
// Check the selection: if no object : disable all possiblity.
ShowHideButton (OneOrMoreFound);
OnDisplay (true);
}
void CSelectionDialog::OnGetSelectedShapes()
{
// Create new displayable shape.
myDisplayableShape = new ISession2D_Shape();
UpdateProjector();
myDisplayableShape->SetNbIsos (m_NbIsos);
// Clear HLR dialog view
myInteractiveContext->RemoveAll();
myInteractiveContext->Display (myTrihedron);
Standard_Boolean OneOrMoreFound = Standard_False;
for (myDoc->GetAISContext()->InitCurrent();
myDoc->GetAISContext()->MoreCurrent ();
myDoc->GetAISContext()->NextCurrent ())
myDoc->GetAISContext()->MoreCurrent();
myDoc->GetAISContext()->NextCurrent())
{
Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(myDoc->GetAISContext()->Current());
Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast (myDoc->GetAISContext()->Current());
if (!anAISShape.IsNull())
{
OneOrMoreFound = Standard_True;
TopoDS_Shape aShape = anAISShape->Shape();
myDisplayableShape->Add( aShape );
myInteractiveContext->Display(anAISShape);
}
{
OneOrMoreFound = Standard_True;
TopoDS_Shape aShape = anAISShape->Shape();
myDisplayableShape->Add (aShape);
myInteractiveContext->Display (anAISShape);
}
}
Standard_Integer DisplayMode = m_DisplayMode;
if (m_Algo == 1) DisplayMode+=100;
if (!m_DrawHiddenLine) DisplayMode+=1000;
// Apply HLR to chosen shapes and display result into the 2d view.
Apply();
// Update viewer
myDoc->FitAll2DViews (Standard_False);
myDoc->GetInteractiveContext2D()->Display(myDisplayableShape, // object
DisplayMode, // display mode
DisplayMode, // selection mode
Standard_True); // Redraw
myDoc->FitAll2DViews(Standard_False); // Update Viewer
// check the selection :
// if no object : disable all possiblity!!
ShowHideButton(OneOrMoreFound);
OnDisplay(true);
// Check the selection: if no object : disable all possiblity.
ShowHideButton (OneOrMoreFound);
OnDisplay (true);
}
void CSelectionDialog::Apply()
void CSelectionDialog::Apply()
{
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
SetCursor(AfxGetApp()->LoadStandardCursor (IDC_WAIT));
myDoc->GetInteractiveContext2D()->RemoveAll();
UpdateData(true);
UpdateData (true);
Standard_Integer DisplayMode = m_DisplayMode;
if (m_Algo == 1) DisplayMode+=100;
Standard_Integer aDisplayMode = m_DisplayMode;
if (!m_DrawHiddenLine) DisplayMode+=1000;
if (m_Algo == 1)
{
aDisplayMode += 100;
}
myDoc->GetInteractiveContext2D()->Display(myDisplayableShape, // object
DisplayMode,
DisplayMode,
Standard_True); // Redraw
if (!m_DrawHiddenLine)
{
aDisplayMode += 1000;
}
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
myDoc->GetInteractiveContext2D()->Display (myDisplayableShape, // object
aDisplayMode,
aDisplayMode,
Standard_True); // Redraw
SetCursor(AfxGetApp()->LoadStandardCursor (IDC_ARROW));
}
void CSelectionDialog::UpdateProjector()
@ -265,8 +300,10 @@ void CSelectionDialog::ShowHideButton(Standard_Boolean EnableButton)
if(m_Algo == 0)
{
if (m_DisplayMode == 5) m_DisplayMode=0;
if (m_DisplayMode == 10) m_DisplayMode=0;
if (m_DisplayMode == 5 || m_DisplayMode == 10)
{
m_DisplayMode=0;
}
GetDlgItem(IDC_VIsoParametrics)->EnableWindow(false);
GetDlgItem(IDC_HIsoParametrics)->EnableWindow(false);
@ -458,7 +495,7 @@ void CSelectionDialog::OnRButtonUp(UINT nFlags, CPoint point)
}
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
// reset tyhe good HLR mode according to the strored one
// reset the good HLR mode according to the stored one
// --> dynamic rotation may have change it
myActiveView->SetComputedMode (m_HlrModeIsOn);
OnDisplay(false);

View File

@ -18,18 +18,26 @@ class CSelectionDialog : public CDialog
{
// Construction
public:
void SetTitle(CString& aTitle);
CSelectionDialog(CHLRDoc* aDoc,CWnd* pParent = NULL); // standard constructor
void OnDisplay(bool isfit);
// standard constructor
CSelectionDialog (CHLRDoc* aDoc,CWnd* pParent = NULL);
void SetTitle (const CString& aTitle);
void OnDisplay (bool isFit);
const Handle(ISession2D_Shape) DiplayableShape() { return myDisplayableShape; }
// Updates in dialog view and main 2d nad 3d views shapes for which HLR presentations are going to be displayed in 2d view.
void UpdateViews();
// Dialog Data
//{{AFX_DATA(CSelectionDialog)
enum { IDD = IDD_SelectionDialog };
int m_Algo;
int m_DisplayMode;
int m_NbIsos;
BOOL m_DrawHiddenLine;
BOOL m_HlrModeIsOn;
int m_Algo;
int m_DisplayMode;
int m_NbIsos;
BOOL m_DrawHiddenLine;
BOOL m_HlrModeIsOn;
//}}AFX_DATA
// Overrides
@ -45,7 +53,7 @@ protected:
// Generated message map functions
//{{AFX_MSG(CSelectionDialog)
virtual BOOL OnInitDialog();
afx_msg void OnGetShape();
afx_msg void OnGetSelectedShapes();
afx_msg void OnDisplayDefault();
afx_msg void OnVIsoParametrics();
afx_msg void OnVApparentContour();
@ -85,26 +93,32 @@ private :
void Apply();
CHLRDoc* myDoc;
Handle(AIS_InteractiveContext) myInteractiveContext;
Handle(V3d_Viewer) myActiveViewer;
Handle(V3d_View) myActiveView;
Standard_Integer myPosMaxX, myPosMinX ,myBoxX;
Standard_Integer myPosMinY, myPosMaxY ,myBoxY;
Handle(AIS_Trihedron) myTrihedron;
Handle(ISession2D_Shape) myDisplayableShape;
Standard_Integer myPosMaxX;
Standard_Integer myPosMinX;
Standard_Integer myBoxX;
Standard_Integer myPosMinY;
Standard_Integer myPosMaxY;
Standard_Integer myBoxY;
Standard_Integer myXmax;
Standard_Integer myYmax;
Handle(AIS_InteractiveContext) myInteractiveContext;
Handle(AIS_Trihedron) myTrihedron;
Handle(ISession2D_Shape) myDisplayableShape;
protected:
CBitmapButton TopView ;
CBitmapButton BottomView ;
CBitmapButton LeftView ;
CBitmapButton RightView ;
CBitmapButton FrontView ;
CBitmapButton BackView ;
CBitmapButton AxoView ;
bool myDisplay;
CBitmapButton TopView;
CBitmapButton BottomView;
CBitmapButton LeftView;
CBitmapButton RightView;
CBitmapButton FrontView;
CBitmapButton BackView;
CBitmapButton AxoView;
bool myIsDisplayed;
};
//{{AFX_INSERT_LOCATION}}

View File

@ -26,6 +26,7 @@ END_MESSAGE_MAP()
CAnimationApp::CAnimationApp() : OCC_App()
{
SampleName = "Animation"; //for about dialog
SetSamplePath ("..\\..\\09_Animation");
}
/////////////////////////////////////////////////////////////////////////////

View File

@ -360,7 +360,7 @@ void CAnimationDoc::OnFileLoadgrid()
NULL );
CString initdir(((OCC_App*) AfxGetApp())->GetInitDataDir());
initdir += "\\..\\..\\Data\\";
initdir += "\\Data\\";
dlg.m_ofn.lpstrInitialDir = initdir;

View File

@ -78,6 +78,7 @@ Convert_Presentation::Convert_Presentation()
void Convert_Presentation::DoSample()
{
((COCCDemoApp*) AfxGetApp())->SetSampleName("Convert");
((COCCDemoApp*) AfxGetApp())->SetSamplePath("..\\..\\10_Convert");
getAISContext()->EraseAll();
if (myIndex >=0 && myIndex < myNbFuncs)
(this->*SampleFuncs[myIndex])();

View File

@ -21,7 +21,24 @@ void ISession2D_Shape::Add(const TopoDS_Shape& aShape)
Update(); // protected method used to specify that the presentation are not up to date
}
void ISession2D_Shape::SetProjector(HLRAlgo_Projector& aProjector)
void ISession2D_Shape::Remove (const TopoDS_Shape& theShape)
{
if (myListOfShape.Size() == 0)
{
return;
}
for (NCollection_List<TopoDS_Shape>::Iterator anIt (myListOfShape); anIt.More(); anIt.Next())
{
if (anIt.Value() == theShape)
{
myListOfShape.Remove (anIt);
return;
}
}
}
void ISession2D_Shape::SetProjector (HLRAlgo_Projector& aProjector)
{
myProjector= aProjector;
myAlgo.Nullify();
@ -48,7 +65,7 @@ void ISession2D_Shape::SetNbIsos(Standard_Integer& aNbIsos)
void ISession2D_Shape::BuildAlgo()
{
myAlgo = new HLRBRep_Algo();
TopTools_ListIteratorOfListOfShape anIterator(myListOfShape);
NCollection_List<TopoDS_Shape>::Iterator anIterator(myListOfShape);
for (;anIterator.More();anIterator.Next()) myAlgo->Add(anIterator.Value(),myNbIsos);
myAlgo->Projector(myProjector);
myAlgo->Update();
@ -58,7 +75,7 @@ void ISession2D_Shape::BuildAlgo()
void ISession2D_Shape::BuildPolyAlgo()
{
myPolyAlgo = new HLRBRep_PolyAlgo();
TopTools_ListIteratorOfListOfShape anIterator(myListOfShape);
NCollection_List<TopoDS_Shape>::Iterator anIterator(myListOfShape);
for (;anIterator.More();anIterator.Next()) myPolyAlgo->Load(anIterator.Value());
myPolyAlgo->Projector(myProjector);
myPolyAlgo->Update();

View File

@ -1,65 +1,71 @@
#ifndef _ISession2D_Shape_HeaderFile
#define _ISession2D_Shape_HeaderFile
#include "AIS_InteractiveObject.hxx"
#include "Graphic3d_ArrayOfPolylines.hxx"
#include <HLRAlgo_Projector.hxx>
#include <HLRBRep_Algo.hxx>
#include <HLRBRep_PolyAlgo.hxx>
#include <NCollection_List.hxx>
#include "SelectMgr_SelectableObject.hxx"
#include <Standard_Macro.hxx>
#include <Standard_DefineHandle.hxx>
#include "TopoDS_Shape.hxx"
#include "SelectMgr_SelectableObject.hxx"
#include "Graphic3d_ArrayOfPolylines.hxx"
#include "AIS_InteractiveObject.hxx"
#include <HLRAlgo_Projector.hxx>
#include <HLRBRep_Algo.hxx>
#include <HLRBRep_PolyAlgo.hxx>
DEFINE_STANDARD_HANDLE(ISession2D_Shape,AIS_InteractiveObject)
class ISession2D_Shape : public AIS_InteractiveObject {
class ISession2D_Shape : public AIS_InteractiveObject
{
public:
Standard_EXPORT ISession2D_Shape ();
// Adds shape to the list of topological shapes
void Standard_EXPORT Add (const TopoDS_Shape& aShape);
// Removes shape from the list of shapes.
// It is used in case of shapes erasing.
void Standard_EXPORT Remove (const TopoDS_Shape& theShape);
// Returns myProjector
HLRAlgo_Projector& Projector() { return myProjector;};
Standard_EXPORT void SetProjector (HLRAlgo_Projector& aProjector);
Standard_Integer& NbIsos() { return myNbIsos;};
Standard_EXPORT void SetNbIsos (Standard_Integer& aNbIsos);
Standard_Boolean AcceptShapeDecomposition() {return Standard_True;}
virtual Standard_Boolean AcceptSelectionMode (const Standard_Integer /*aMode*/) const
{ return Standard_True; }
public:
Standard_EXPORT ISession2D_Shape ();
void Standard_EXPORT Add(const TopoDS_Shape& aShape);
HLRAlgo_Projector& Projector() { return myProjector; }
Standard_EXPORT void SetProjector(HLRAlgo_Projector& aProjector);
DEFINE_STANDARD_RTTI(ISession2D_Shape)
private:
Standard_Integer myNbIsos;
void BuildAlgo();
void BuildPolyAlgo();
public :
Standard_Integer& NbIsos() { return myNbIsos;};
Standard_EXPORT void SetNbIsos(Standard_Integer& aNbIsos) ;
void DrawCompound (const Handle(Prs3d_Presentation)& thePresentation,
const TopoDS_Shape& theCompound,
const Handle(Prs3d_LineAspect) theAspect);
Standard_Boolean AcceptShapeDecomposition() {return Standard_True;}
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode = 0);
virtual Standard_Boolean AcceptSelectionMode(const Standard_Integer /*aMode*/) const
{return Standard_True; }
virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode);
DEFINE_STANDARD_RTTI(ISession2D_Shape)
private:
private:
void BuildAlgo();
void BuildPolyAlgo();
void DrawCompound(const Handle(Prs3d_Presentation)& thePresentation,
const TopoDS_Shape& theCompound,
const Handle(Prs3d_LineAspect) theAspect);
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode = 0);
virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,const Standard_Integer aMode) ;
private :
TopTools_ListOfShape myListOfShape;
HLRAlgo_Projector myProjector;
Handle(HLRBRep_Algo) myAlgo;
Handle(HLRBRep_PolyAlgo) myPolyAlgo;
Standard_Integer myNbIsos;
NCollection_List<TopoDS_Shape> myListOfShape;
HLRAlgo_Projector myProjector;
Handle(HLRBRep_Algo) myAlgo;
Handle(HLRBRep_PolyAlgo) myPolyAlgo;
};
// other inCurve functions and methods (like "C++: function call" methods)
//

View File

@ -274,21 +274,26 @@ void OCC_3dBaseDoc::OnUpdateObjectColor(CCmdUI* pCmdUI)
if (myAISContext->IsDisplayed(myAISContext->Current(),0)
||myAISContext->IsDisplayed(myAISContext->Current(),1))
OneOrMoreIsShadingOrWireframe=true;
pCmdUI->Enable (OneOrMoreIsShadingOrWireframe);
pCmdUI->Enable (OneOrMoreIsShadingOrWireframe);
}
void OCC_3dBaseDoc::OnObjectErase()
{
for(myAISContext->InitCurrent();myAISContext->MoreCurrent();myAISContext->NextCurrent())
myAISContext->Erase(myAISContext->Current(),Standard_True);
myAISContext->ClearCurrents();
for (myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent())
{
myAISContext->Erase (myAISContext->Current(), Standard_True);
}
myAISContext->ClearCurrents();
}
void OCC_3dBaseDoc::OnUpdateObjectErase(CCmdUI* pCmdUI)
{
bool OneOrMoreIsDisplayed = false;
for (myAISContext->InitCurrent();myAISContext->MoreCurrent ();myAISContext->NextCurrent ())
if (myAISContext->IsDisplayed(myAISContext->Current())) OneOrMoreIsDisplayed=true;
pCmdUI->Enable (OneOrMoreIsDisplayed);
for (myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent())
{
if (myAISContext->IsDisplayed (myAISContext->Current()))
OneOrMoreIsDisplayed = true;
}
pCmdUI->Enable (OneOrMoreIsDisplayed);
}
void OCC_3dBaseDoc::OnObjectWireframe()

View File

@ -129,24 +129,24 @@ BOOL CAboutDlgStd::OnInitDialog(){
Title->SetWindowText(strTitle);
SetWindowText(dlgTitle);
if(SampleName.Find("Viewer2d")==-1)
CWnd* aReadmeEdit = GetDlgItem(IDC_README);
CFile aFile;
CString aHelpFilePath = CString (((OCC_App*)AfxGetApp())->GetInitDataDir()) + "\\README.txt";
if(aFile.Open (aHelpFilePath, CFile::modeRead))
{
CWnd* aReadmeEdit = GetDlgItem(IDC_README);
aReadmeEdit->ShowWindow(FALSE);
aReadmeEdit->ShowWindow(TRUE);
UINT aFileLength = (UINT)aFile.GetLength();
char* buffer=new char[aFileLength];
aFile.Read(buffer,aFileLength);
ReadmeText.SetString(buffer);
ReadmeText.SetAt(aFileLength,'\0');
ReadmeText.Replace("\n","\r\n");
UpdateData(FALSE);
}
else
{
CFile aFile;
if(aFile.Open("..//..//..//README.txt",CFile::modeRead))
{
UINT aFileLength = (UINT)aFile.GetLength();
char* buffer=new char[aFileLength];
aFile.Read(buffer,aFileLength);
ReadmeText.SetString(buffer);
ReadmeText.SetAt(aFileLength,'\0');
ReadmeText.Replace("\n","\r\n");
UpdateData(FALSE);
}
aReadmeEdit->ShowWindow(FALSE);
}
CenterWindow();

View File

@ -129,7 +129,7 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,101,233,88,14,WS_GROUP
CTEXT "http://www.opencascade.com",IDC_STATIC,92,116,98,8,SS_CENTERIMAGE
CONTROL 1300,IDC_STATIC,"Static",SS_BITMAP,73,28,132,64,WS_EX_CLIENTEDGE
EDITTEXT IDC_README,7,131,270,94,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL,WS_EX_LEFTSCROLLBAR
EDITTEXT IDC_README,7,131,270,94,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL
END
IDD_ResultDialog DIALOG 0, 0, 212, 202