1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +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

@@ -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}}