CViewer3dView, CAnimationView3D, COCCDemoView now use AIS_RubberBand.
#include "ModelClippingDlg.h"
#include "TrihedronDlg.h"
+#include <AIS_RubberBand.hxx>
#include <V3d_AmbientLight.hxx>
#include <V3d_DirectionalLight.hxx>
#include <V3d_PositionalLight.hxx>
myCurZoom (0.0),
NbActiveLights (2), // There are 2 default active lights
myHlrModeIsOn (Standard_False),
- m_Pen (NULL),
+ myRect (new AIS_RubberBand (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0)),
myAxisKey (0),
myScaleDirection (0)
{
CViewer3dView::~CViewer3dView()
{
myView->Remove();
- if (m_Pen) delete m_Pen;
}
BOOL CViewer3dView::PreCreateWindow(CREATESTRUCT& cs)
{
case CurAction3d_Nothing :
- DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
myXmax = point.x; myYmax = point.y;
if (nFlags & MK_SHIFT)
GetDocument()->ShiftDragEvent(myXmax,myYmax,0,myView);
break;
case CurAction3d_WindowZooming :
myXmax = point.x; myYmax = point.y;
- DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
- DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True,LongDash);
+ DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True, Aspect_TOL_DASH);
break;
case CurAction3d_DynamicPanning :
pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicRotation);
}
-void CViewer3dView::DrawRectangle(const Standard_Integer MinX ,
- const Standard_Integer MinY ,
- const Standard_Integer MaxX ,
- const Standard_Integer MaxY ,
- const Standard_Boolean Draw ,
- const LineStyle aLineStyle)
+void CViewer3dView::DrawRectangle (Standard_Integer theMinX,
+ Standard_Integer theMinY,
+ Standard_Integer theMaxX,
+ Standard_Integer theMaxY,
+ Standard_Boolean theToDraw,
+ Aspect_TypeOfLine theLineType)
{
- 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);
+ const Handle(AIS_InteractiveContext)& aCtx = GetDocument()->GetAISContext();
+ if (!theToDraw)
+ {
+ aCtx->Remove (myRect, false);
+ aCtx->CurrentViewer()->RedrawImmediate();
+ return;
+ }
- 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);
+ CRect aRect;
+ GetWindowRect (aRect);
+ myRect->SetLineType (theLineType);
+ myRect->SetRectangle (theMinX, aRect.Height() - theMinY, theMaxX, aRect.Height() - theMaxY);
+ if (!aCtx->IsDisplayed (myRect))
+ {
+ aCtx->Display (myRect, false);
+ }
+ else
+ {
+ aCtx->Redisplay (myRect, false);
+ }
+ aCtx->CurrentViewer()->RedrawImmediate();
}
void CViewer3dView::OnModifyChangeBackground()
CurAction3d_EndDirectionalLight
};
+class AIS_RubberBand;
+
class CViewer3dView : public CView
{
protected: // create from serialization only
Handle(V3d_DirectionalLight) myCurrent_DirectionalLight;
Handle(Graphic3d_ClipPlane) myClippingPlane;
Handle(AIS_Shape) myShape;
+ Handle(AIS_RubberBand) myRect; //!< Rubber rectangle for selection
private:
- enum LineStyle { Solid, Dot, ShortDash, LongDash, Default };
- CPen* m_Pen;
- virtual void DrawRectangle (const Standard_Integer MinX ,
- const Standard_Integer MinY ,
- const Standard_Integer MaxX ,
- const Standard_Integer MaxY ,
- const Standard_Boolean Draw ,
- const LineStyle aLineStyle = Default );
+
+ void DrawRectangle (Standard_Integer theMinX, Standard_Integer theMinY, Standard_Integer theMaxX, Standard_Integer theMaxY,
+ Standard_Boolean theToDraw, Aspect_TypeOfLine theLineType = Aspect_TOL_SOLID);
+
UINT myAxisKey;
UINT myScaleDirection;
void RedrawVisMode();
#include "Sensitivity.h"
+#include <AIS_RubberBand.hxx>
+
#ifdef _DEBUG
//#define new DEBUG_NEW by CasCade
#undef THIS_FILE
myCurrentMode (CurrentAction3d_Nothing),
m_FlySens (500.0),
m_TurnSens (M_PI / 40.0),
- m_Pen (NULL)
+ myRect (new AIS_RubberBand (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0))
{
// TODO: add construction code here
}
CAnimationView3D::~CAnimationView3D()
{
myView->Remove();
- if (m_Pen) delete m_Pen;
}
BOOL CAnimationView3D::PreCreateWindow(CREATESTRUCT& cs)
break;
case CurrentAction3d_WindowZooming :
myXmax=point.x; myYmax=point.y;
- DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
+ DrawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_False, Aspect_TOL_DASH);
if ((abs(myXmin-myXmax)>ValZWMin) || (abs(myYmin-myYmax)>ValZWMin))
// Test if the zoom window is greater than a minimale window.
{
{
case CurrentAction3d_Nothing :
myXmax = point.x; myYmax = point.y;
- DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
if (nFlags & MK_SHIFT)
GetDocument()->ShiftDragEvent(myXmax,myYmax,0,myView);
else
break;
case CurrentAction3d_WindowZooming :
myXmax = point.x; myYmax = point.y;
- DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
- DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True,LongDash);
+ DrawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_True, Aspect_TOL_DASH);
break;
case CurrentAction3d_DynamicPanning :
myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
//-----------------------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------------------
-void CAnimationView3D::DrawRectangle(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;
- }
+void CAnimationView3D::DrawRectangle (Standard_Integer theMinX,
+ Standard_Integer theMinY,
+ Standard_Integer theMaxX,
+ Standard_Integer theMaxY,
+ Standard_Boolean theToDraw,
+ Aspect_TypeOfLine theLineType)
+{
+ const Handle(AIS_InteractiveContext)& aCtx = GetDocument()->GetAISContext();
+ if (!theToDraw)
+ {
+ aCtx->Remove (myRect, false);
+ aCtx->CurrentViewer()->RedrawImmediate();
+ return;
+ }
- if (m_Pen)
- clientDC.SelectObject(aOldPen);
+ CRect aRect;
+ GetWindowRect (aRect);
+ myRect->SetLineType (theLineType);
+ myRect->SetRectangle (theMinX, aRect.Height() - theMinY, theMaxX, aRect.Height() - theMaxY);
+ if (!aCtx->IsDisplayed (myRect))
+ {
+ aCtx->Display (myRect, false);
+ }
+ else
+ {
+ aCtx->Redisplay (myRect, false);
+ }
+ aCtx->CurrentViewer()->RedrawImmediate();
}
+
void CAnimationView3D::OnStop()
{
KillTimer(GetDocument()->myCount);
#include "AnimationDoc.h"
#include "..\..\Common\res\OCC_Resource.h"
+class AIS_RubberBand;
+
enum View3D_CurrentAction {
CurrentAction3d_Nothing,
CurrentAction3d_DynamicZooming,
double m_Focus ;
private:
- enum LineStyle { Solid, Dot, ShortDash, LongDash, Default };
- CPen* m_Pen;
- virtual void DrawRectangle (const Standard_Integer MinX ,
- const Standard_Integer MinY ,
- const Standard_Integer MaxX ,
- const Standard_Integer MaxY ,
- const Standard_Boolean Draw ,
- const LineStyle aLineStyle = Default );
+ Handle(AIS_RubberBand) myRect; //!< Rubber rectangle for selection
+ void DrawRectangle (Standard_Integer theMinX, Standard_Integer theMinY, Standard_Integer theMaxX, Standard_Integer theMaxY,
+ Standard_Boolean theToDraw, Aspect_TypeOfLine theLineType = Aspect_TOL_SOLID);
};
#ifndef _DEBUG // debug version in AnimationView.cpp
#include "OCCDemoDoc.h"
#include "OCCDemoView.h"
+#include <AIS_RubberBand.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#define ValZWMin 1
myCurZoom=0;
myCurrentMode = CurAction3d_Nothing;
myVisMode = VIS_SHADE;
- m_Pen = NULL;
+ myRect = new AIS_RubberBand (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0);
myGraphicDriver = ((COCCDemoApp*)AfxGetApp())->GetGraphicDriver();
}
{
if (!myView.IsNull())
myView->Remove();
- if (m_Pen)
- delete m_Pen;
}
BOOL COCCDemoView::PreCreateWindow(CREATESTRUCT& cs)
break;
case CurAction3d_WindowZooming :
myXmax = point.x; myYmax = point.y;
- DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
- DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True,LongDash);
+ DrawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_True, Aspect_TOL_DASH);
break;
case CurAction3d_DynamicPanning :
myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicRotation);
}
-void COCCDemoView::DrawRectangle(const Standard_Integer MinX,
- const Standard_Integer MinY,
- const Standard_Integer MaxX,
- const Standard_Integer MaxY,
- const Standard_Boolean Draw,
- const LineStyle aLineStyle)
+void COCCDemoView::DrawRectangle (Standard_Integer theMinX,
+ Standard_Integer theMinY,
+ Standard_Integer theMaxX,
+ Standard_Integer theMaxY,
+ Standard_Boolean theToDraw,
+ Aspect_TypeOfLine theLineType)
{
- static int m_DrawMode;
- if (!m_Pen && aLineStyle ==Solid )
+ const Handle(AIS_InteractiveContext)& aCtx = GetDocument()->GetAISContext();
+ if (!theToDraw)
{
- m_Pen = new CPen(PS_SOLID, 1, RGB(0,0,0)); m_DrawMode = R2_MERGEPENNOT;
+ aCtx->Remove (myRect, false);
+ aCtx->CurrentViewer()->RedrawImmediate();
+ return;
}
- 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 = Standard_False;
-
- if ( m_IsVisible && !Draw) // move or up : erase at the old position
+ CRect aRect;
+ GetWindowRect (aRect);
+ myRect->SetLineType (theLineType);
+ myRect->SetRectangle (theMinX, aRect.Height() - theMinY, theMaxX, aRect.Height() - theMaxY);
+ if (!aCtx->IsDisplayed (myRect))
{
- clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY);
- clientDC.LineTo(StoredMaxX,StoredMaxY);
- clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY);
- m_IsVisible = false;
+ aCtx->Display (myRect, false);
}
-
- StoredMinX = Min ( MinX, MaxX );
- StoredMinY = Min ( MinY, MaxY );
- StoredMaxX = Max ( MinX, MaxX );
- StoredMaxY = Max ( MinY, MaxY);
-
- if (Draw) // move : draw
+ else
{
- clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY);
- clientDC.LineTo(StoredMaxX,StoredMaxY);
- clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY);
- m_IsVisible = true;
+ aCtx->Redisplay (myRect, false);
}
-
- if (m_Pen)
- clientDC.SelectObject(aOldPen);
+ aCtx->CurrentViewer()->RedrawImmediate();
}
void COCCDemoView::InitButtons()
CurAction3d_DynamicRotation
};
+class AIS_RubberBand;
+
class COCCDemoView : public CView
{
protected: // create from serialization only
Standard_Real myCurZoom;
private:
- enum LineStyle { Solid, Dot, ShortDash, LongDash, Default };
- CPen* m_Pen;
+ Handle(AIS_RubberBand) myRect; //!< Rubber rectangle for selection
virtual void DrawRectangle (const Standard_Integer MinX ,
const Standard_Integer MinY ,
const Standard_Integer MaxX ,
const Standard_Integer MaxY ,
const Standard_Boolean Draw ,
- const LineStyle aLineStyle = Default );
+ Aspect_TypeOfLine theLineType = Aspect_TOL_SOLID);
};