mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0025338: MFC standard samples: 3D selection rectangle blinking
- Added new interactive object AIS_RubberBand to draw rubber rectangle or polygon - Added using of AIS_RubberBand in DRAW view for rectangular selection - Added using of AIS_RubberBand in MFC samples for rectangular selection
This commit is contained in:
@@ -67,16 +67,13 @@ END_MESSAGE_MAP()
|
||||
// OCC_2dView construction/destruction
|
||||
|
||||
OCC_2dView::OCC_2dView()
|
||||
: myCurrentMode (CurAction2d_Nothing)
|
||||
{
|
||||
// TODO: add construction code here
|
||||
myCurrentMode = CurAction2d_Nothing;
|
||||
m_Pen = NULL;
|
||||
}
|
||||
|
||||
OCC_2dView::~OCC_2dView()
|
||||
{
|
||||
myV2dView->Remove();
|
||||
if (m_Pen) delete m_Pen;
|
||||
}
|
||||
|
||||
BOOL OCC_2dView::PreCreateWindow(CREATESTRUCT& cs)
|
||||
@@ -154,7 +151,7 @@ void OCC_2dView::OnBUTTONGridRectLines()
|
||||
aViewer->SetRectangularGridGraphicValues(aWidth,aHeight,anOffset);
|
||||
aViewer->ActivateGrid(Aspect_GT_Rectangular, Aspect_GDM_Lines);
|
||||
FitAll();
|
||||
|
||||
|
||||
if (TheCircularGridDialog.IsWindowVisible())
|
||||
{
|
||||
TheCircularGridDialog.ShowWindow(SW_HIDE);
|
||||
@@ -302,6 +299,7 @@ void OCC_2dView::OnLButtonUp(UINT nFlags, CPoint point)
|
||||
}
|
||||
else // if ( Ctrl )
|
||||
{
|
||||
const Handle(AIS_InteractiveContext)& aContext = GetDocument()->GetAISContext();
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction2d_Nothing :
|
||||
@@ -315,7 +313,7 @@ void OCC_2dView::OnLButtonUp(UINT nFlags, CPoint point)
|
||||
InputEvent2D (point.x,point.y);
|
||||
} else
|
||||
{
|
||||
DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False);
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext, Standard_False);
|
||||
myXmax=point.x;
|
||||
myYmax=point.y;
|
||||
if (nFlags & MULTISELECTIONKEY)
|
||||
@@ -330,7 +328,7 @@ void OCC_2dView::OnLButtonUp(UINT nFlags, CPoint point)
|
||||
break;
|
||||
case CurAction2d_WindowZooming :
|
||||
myXmax=point.x; myYmax=point.y;
|
||||
DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext, Standard_False);
|
||||
if ((abs(myXmin-myXmax)>ValZWMin) || (abs(myYmin-myYmax)>ValZWMin))
|
||||
// Test if the zoom window is greater than a minimale window.
|
||||
{
|
||||
@@ -410,13 +408,13 @@ void OCC_2dView::OnMouseMove(UINT nFlags, CPoint point)
|
||||
}
|
||||
else // if ( CASCADESHORTCUTKEY )
|
||||
{
|
||||
const Handle(AIS_InteractiveContext)& aContext = GetDocument()->GetAISContext();
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case CurAction2d_Nothing :
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False);
|
||||
DragEvent2D(myXmax,myYmax,0);
|
||||
DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_True);
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext);
|
||||
break;
|
||||
case CurAction2d_DynamicZooming :
|
||||
myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
|
||||
@@ -424,15 +422,15 @@ void OCC_2dView::OnMouseMove(UINT nFlags, CPoint point)
|
||||
myXmax=point.x; myYmax=point.y;
|
||||
break;
|
||||
case CurAction2d_WindowZooming :
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
|
||||
DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_True,LongDash);
|
||||
myXmax = point.x;
|
||||
myYmax = point.y;
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, aContext);
|
||||
break;
|
||||
case CurAction2d_DynamicPanning :
|
||||
myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
|
||||
myXmax = point.x; myYmax = point.y;
|
||||
break;
|
||||
case CurAction2d_GlobalPanning : // nothing
|
||||
case CurAction2d_GlobalPanning : // nothing
|
||||
break;
|
||||
default :
|
||||
Standard_Failure::Raise(" incompatible Current Mode ");
|
||||
@@ -558,60 +556,6 @@ void OCC_2dView::OnUpdateBUTTON2DZoomWin(CCmdUI* pCmdUI)
|
||||
pCmdUI->Enable (myCurrentMode != CurAction2d_WindowZooming);
|
||||
}
|
||||
|
||||
|
||||
void OCC_2dView::DrawRectangle2D(const Standard_Integer MinX,
|
||||
const Standard_Integer MinY,
|
||||
const Standard_Integer MaxX,
|
||||
const Standard_Integer MaxY,
|
||||
const Standard_Boolean Draw,
|
||||
const LineStyle aLineStyle)
|
||||
{
|
||||
static int m_DrawMode;
|
||||
if (!m_Pen && aLineStyle ==Solid )
|
||||
{m_Pen = new CPen(PS_SOLID, 1, RGB(0,0,0)); m_DrawMode = R2_MERGEPENNOT;}
|
||||
else if (!m_Pen && aLineStyle ==Dot )
|
||||
{m_Pen = new CPen(PS_DOT, 1, RGB(0,0,0)); m_DrawMode = R2_XORPEN;}
|
||||
else if (!m_Pen && aLineStyle == ShortDash)
|
||||
{m_Pen = new CPen(PS_DASH, 1, RGB(255,0,0)); m_DrawMode = R2_XORPEN;}
|
||||
else if (!m_Pen && aLineStyle == LongDash)
|
||||
{m_Pen = new CPen(PS_DASH, 1, RGB(0,0,0)); m_DrawMode = R2_NOTXORPEN;}
|
||||
else if (aLineStyle == Default)
|
||||
{ m_Pen = NULL; m_DrawMode = R2_MERGEPENNOT;}
|
||||
|
||||
CPen* aOldPen = NULL;
|
||||
CClientDC clientDC(this);
|
||||
if (m_Pen) aOldPen = clientDC.SelectObject(m_Pen);
|
||||
clientDC.SetROP2(m_DrawMode);
|
||||
|
||||
static Standard_Integer StoredMinX, StoredMaxX, StoredMinY, StoredMaxY;
|
||||
static Standard_Boolean m_IsVisible;
|
||||
|
||||
if ( m_IsVisible && !Draw) // move or up : erase at the old position
|
||||
{
|
||||
clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY);
|
||||
clientDC.LineTo(StoredMaxX,StoredMaxY);
|
||||
clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY);
|
||||
m_IsVisible = false;
|
||||
}
|
||||
|
||||
StoredMinX = Min ( MinX, MaxX );
|
||||
StoredMinY = Min ( MinY, MaxY );
|
||||
StoredMaxX = Max ( MinX, MaxX );
|
||||
StoredMaxY = Max ( MinY, MaxY);
|
||||
|
||||
if (Draw) // move : draw
|
||||
{
|
||||
clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY);
|
||||
clientDC.LineTo(StoredMaxX,StoredMaxY);
|
||||
clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY);
|
||||
m_IsVisible = true;
|
||||
}
|
||||
|
||||
if (m_Pen) clientDC.SelectObject(aOldPen);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// =====================================================================
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user