(6) develop a simple CAD solution step by step

Source: Internet
Author: User

To achieve pick-up, you only need to select the objects in the entity set to pick up the collection.

The mouse goes through the object set is a brilliant color, and the mouse selects the object is

Select an object from the object, and then add it to the selection set.

Therefore, a class is developed to operate on entity tokens and selection sets.

 

Typedef struct // Index Related to object pointer
{
Csolid * m_picksolid;
Int index; // The Index associated with the pointer

} Pindex;

Typedef ctypedptrarray <cobarray, csolid *> tagcarray;

// This class operates on the object set and select set, including
Class chandlecg // operation dataset. You can extract specific elements from a set and put them in another set.
{
Public:
Chandlecg (){};
Chandlecg (tagcarray * solid, tagcarray * select );
Virtual ~ Chandlecg (){};
Public:
Bool isselect (csolid * Solid );
Void drawselect (CDC * PDC, cposition POs, float DIS, int dnormal, int dselect); // move the drawing
Void addselect (); // select the object placement set
Void deletesolid (CDC * PDC); // Delete the selected object
Void deleteall (CDC * PDC); // delete all data
Void mirror (cposition & first, cposition & Second, int mode); // image. The last variable indicates whether to delete the original object.
Void addmirror (cposition & first, cposition & Second, int mode );
PRIVATE:
Tagcarray * m_solid;
Tagcarray * m_select;
Pindex m_pindex;

Tagcarray me;

Tagcarray m_select_mirror;

};

 

 

Chandlecg: chandlecg (tagcarray * solid, tagcarray * select )//
{
M_solid = solid;
M_select = select;
M_pindex.m_picksolid = NULL;
M_pindex.index =-1;
}

Bool chandlecg: isselect (csolid * Solid) // checks whether the element is in the dataset.
{
 

If (solid)
{< br> for (INT I = 0; I getsize (); I ++)
{< br> If (solid = (* m_select) [I])
{< br> return true;
}< BR >}< br> return false;

}< br> void chandlecg :: drawselect (CDC * PDC, cposition POs, float DIS, int dnormal, int dselect)
{< br> If (m_pindex.m_picksolid &&! Isselect (m_pindex.m_picksolid) // isselect prevents the last selected image from flashing
{< br> m_pindex.m_picksolid-> drawsolid (PDC, dnormal );
}

For (INT I = 0; I <m_solid-> getsize (); I ++)
{
 
If (* m_solid) [I]-> picksolid (Pos, DIS) // isselect () to avoid blinking of Selected images
{
(* M_solid) [I]-> drawsolid (PDC, dselect );
M_pindex.m_picksolid = (* m_solid) [I];
M_pindex.index = I;
Break;
}

}
}

Void chandlecg: addselect ()
{

If (m_pindex.m_picksolid)
{
If (m_solid-> getsize ())
{
M_select-> Add (m_pindex.m_picksolid); // select to the selection set
M_solid-> removeat (m_pindex.index );
M_pindex.m_picksolid = NULL;

}
 
}
}

Void chandlecg: deletesolid (CDC * PDC) // Delete the selected element. m_solid points to the pointer of the selected set.
{
If (m_pindex.m_picksolid)
{
M_pindex.m_picksolid-> drawsolid (PDC, back); // eliminate the entity on the screen
Delete m_pindex.m_picksolid;
M_solid-> removeat (m_pindex.index );

M_pindex.m_picksolid = NULL;
}
}

Void chandlecg: deleteall (CDC * PDC) // delete all
{
 
For (INT I = 0; I <m_select-> getsize (); I ++)
{

(* M_select) [I]-> drawsolid (PDC, back );
Delete (* m_select) [I];




}
M_select-> removeall ();
}

Void chandlecg: Mirror (cposition & first, cposition & Second, int mode) // pointer Transfer
{

//
CDC * PDC = g_pview-> getdc ();

Int M = m_select-> getsize ();
For (Int J = 0; j <m; j ++)
{
(* M_select) [J]-> mirror (first, second)-> drawsolid (PDC, mode );

}
G_pview-> releasedc (PDC );
}

Void chandlecg: addmirror (cposition & first, cposition & Second, int Mode)
{
Int M = m_select-> getsize ();
For (Int J = 0; j <m; j ++)
{
M_select_mirror.add (* m_select) [J]-> mirror (first, second ));
}

Mirror (first, second, mode );
M_select_mirror.removeall ();
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.