(12) develop a simple CAD observer Mode Step by Step

Source: Internet
Author: User

Changes in model data may cause changes in views, which can be implemented in the Observer mode, while the relationship between multiple views can be used

Combined Mode implementation

 

Class csubject // observer Mode
{
Public:
Csubject (tagcarray * solid, tagcarray * select) {m_solid = solid, m_select = select ;}
Virtual ~ Csubject (){}
Void setobserver (cmcadview * view) {m_view = view;} // sets the observer
Void notify ()
{
If (m_view)
{
M_view-> updateview ();
}
}

Void drawsolid (CDC * PDC, int drawmode); // redraws an object and a selection set, which is saved in double storage.
 

PRIVATE:
Cmcadview * m_view;

Tagcarray * m_solid;
Tagcarray * m_select;

 

 

Void csubject: drawsolid (CDC * PDC, int drawmode)
{

 
For (INT I = 0; I <m_solid-> getsize (); I ++)
{
(* M_solid) [I]-> drawsolid (PDC, drawmode );
 
}

For (INT m = 0; m <m_select-> getsize (); m ++)
{
(* M_select) [m]-> drawsolid (PDC, select );
}

 

}

 

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.