You can drag a rubber band to reuse an object such as draw a line or draw a circle. This rubber band can be in 8 directions and can indicate the direction at 45 degrees.
Class ceraseline // image rubber band class, which can be drawn in eight directions
{
Public:
Ceraseline ();
Virtual ~ Ceraseline ();
Public:
Void setbegin (cposition begin );
Void setend (cposition end );
Void setcancle (cposition POS );
Bool getpoints (cposition CEN); // obtain the coordinates of the second actual point
Void onlbuttondown (uint nflags, cposition POS );
Void onmousemove (uint nflags, cposition POS );
Void onrbuttondown (uint nflags, cposition POS );
Public:
Cposition m_begin;
Cposition m_end;
Int m_nstep;
};
Ceraseline: ceraseline ()
{
M_nstep = 1;
}
Ceraseline ::~ Ceraseline ()
{
}
Void ceraseline: setbegin (cposition begin)
{
Onlbuttondown (0, begin );
}
Void ceraseline: setend (cposition end)
{
Onmousemove (0, end );
Getpoints (end );
}
Bool ceraseline: getpoints (cposition CEN) // if the second point changes, the changed point is reversed.
{
Cline * line [8];
CDC * PDC = g_pview-> getdc ();
For (INT I = 0; I <8; I ++)
{
Line [I] = new Cline (m_begin, m_begin + cposition (COS (45 * I * PI/180), sin (45 * I * PI/180) * 1000 );
If (line [I]-> picksolid (m_end, g_pview-> m_scale * 5) & m_nstep = 2) // only draws
{
Line [I]-> drawsolid (PDC, select );
}
Else
{
Line [I]-> drawsolid (PDC, back );
}
Delete line [I];
}
G_pview-> releasedc (PDC );
Return true;
}
Void ceraseline: onlbuttondown (uint nflags, cposition POS)
{
Switch (m_nstep)
{
Case 1: // output prompt information
{
M_end = m_begin = Pos;
M_nstep ++;
Break;
}
Case 2:
{
M_end = Pos;
CDC * PDC = g_pview-> getdc ();
Cline * line1 = new Cline (m_begin, m_end); // portrait Leather line, eliminating the previous
Line1-> drawsolid (PDC, drag );
Delete line1;
G_pview-> releasedc (PDC );
M_nstep = 1;
}
Default:
Break;
}
}
Void ceraseline: onmousemove (uint nflags, cposition POS)
{
Switch (m_nstep)
{
Case 2:
CDC * PDC = g_pview-> getdc ();
Cline * line1 = new Cline (m_begin, m_end); // portrait Leather line, eliminating the previous
Line1-> drawsolid (PDC, drag );
Delete line1;
G_pview-> m_suject-> sort y ();
Cline * line = new Cline (m_begin, POS); // portrait leather Line, Last
Line-> drawsolid (PDC, normal );
Delete line;
M_end = Pos;
G_pview-> releasedc (PDC );
Break;
}
}
Void ceraseline: onrbuttondown (uint nflags, cposition POS)
{
CDC * PDC = g_pview-> getdc ();
Cline * line1 = new Cline (m_begin, POS); // portrait Leather line, eliminating the previous
Line1-> drawsolid (PDC, back );
Delete line1;
G_pview-> releasedc (PDC );
M_nstep = 1;
}
Void ceraseline: setcancle (cposition POS)
{
Onrbuttondown (0, POS );
}
Int g_refresh = 0; // record the number of screen refreshes
Int c_refresh = 0;
Ccreateline: ccreateline ()
{
M_nstep = 1;
C_refresh = g_refresh;
}
Ccreateline ::~ Ccreateline ()
{
}