/********************************************************************/ /* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */ /* All rights reserved. */ /********************************************************************/ #ifndef _MGGroup_HH_ #define _MGGroup_HH_ #include "mg/Plist.h" #include "mg/Pvector.h" #include "mg/Object.h" #include "mg/Gel.h" #include "mg/AttribedGel.h" // //Define MGGroup Class. // class MGIfstream; class MGOfstream; class MGBox; class MGObject; class MGAttrib; class MGGLAttrib; class MGAppearance; class MGContext; /** @addtogroup GelRelated * @{ */ ///MGGroup is a class which constains MGGel elements. ///MGGroup provides functions: ///(1) a container of MGGel(MGAtrribedGel(MGObject or MGGroup), MGAttrib) elements. ///(2) To attach an appearance to the context of the group. class MG_DLL_DECLR MGGroup:public MGAttribedGel{ public: /// 別名定義 typedef MGPlist::iterator iterator ; typedef MGPlist::const_iterator const_iterator; typedef MGPlist::reverse_iterator reverse_iterator ; typedef MGPlist::const_reverse_iterator const_reverse_iterator; ////////////Constructor//////////// ///Void constructor(初期化なしでオブジェクトを作成する。) MGGroup(); MGGroup(MGGel* gel); ///Construct MGGroup from the file made by MGOfstream. ///error contains error flag as: ///=0: open succeeded. ///=1: file not found, or could not be opened. ///=2: file found, but, the format is not MGCL format. ///When error!=0, MGGroup contains no MGGel's. MGGroup(const TCHAR* file, int& error); ///Copy constructor. ///MGGroup(const MGGroup& obj2); ///Virtual Destructor ///virtual ~MGGroup(); //////////////////operator overloaded//////////////// ///Assignment. ///When the leaf object of this and gel2 are not equal, this assignment ///does nothing. virtual MGGroup& operator=(const MGGel& gel2); virtual MGGroup& operator=(const MGGroup& gel2); ///comparison virtual bool operator<(const MGGroup& gel2)const; virtual bool operator<(const MGGel& gel2)const; ////////////Member Function//////////// ///Get the MGAppearance pointer in this group. If not defined, null will be ///returned. MGAppearance* appearance(); const MGAppearance* appearance()const; ///Judge if the display list for vmode is made or not. //virtual bool displayList_is_made(MGCL::VIEWMODE vmode)const; /// Return(but does not remove) last element in the group. /// If list is empty, behavior is undefined. const MGGel* back() const{return m_gels.back();}; MGGel* back(){return m_gels.back();}; /// Return const_iterator at the beginning of list. const_iterator begin() const{return m_gels.begin();} iterator begin(){return m_gels.begin();} ///Get the box of the group. ///If no objects were included in this group, null box will be returned. MGBox box()const; /// clear list, that is, erase(delete) all the elements in the MGGel. void clear(){m_gels.clear();}; ///Generate copied gel of this gel. ///Returned is a newed object. User must delete the object. virtual MGGroup* clone()const; ///Get the MGContext pointer stored in this group. If not defined, null will be ///returned. MGContext* context(); const MGContext* context()const; ///////display member function. virtual void display_arrows(mgSysGL& sgl)const; virtual void display_break_points(mgSysGL& sgl)const; virtual void display_control_polygon(mgSysGL& sgl)const; virtual void display_curvatures( mgSysGL& sgl,///& gels_to_delete )const; ///Process of draw or render attributes. void drawAttrib( mgVBO& vbo,///& objs); void push_back(MGPlist& objs); void push_back(MGPvector& gels); void push_back(MGPlist& gels); /// push element x at the first. ///x must be a newed object, and the ownership will be transfered to thisMGGroup. void push_front(MGGel* x); /// Return const_reverse_iterator at the beginning of list. const_reverse_iterator rbegin() const{return m_gels.rbegin();}; reverse_iterator rbegin(){return m_gels.rbegin();}; /// Return const_reverse_iterator at the end of list. const_reverse_iterator rend() const{return m_gels.rend();}; reverse_iterator rend(){return m_gels.rend();}; ///Release the gel at the position i. ///Returned will be the position after the relesed gel. iterator release(iterator i){return m_gels.release(i);}; ///Release all the gelof this group. The released memebes are newed objects. ///User must take care to delete them. void releaseAll(); ///Remove the MGAppearance of this MGAttribedGel. void remove_appearance(); ///Remove the MGGel* and return the MGGel*. If i is not valid, /// behavior is undefined. ///現在の所有権を放棄し、ただのポインタを返す。 MGGel* removeAt(iterator x){return m_gels.removeAt(x);}; ///reverse sequence. void reverse(){m_gels.reverse();}; ///Execute polar-scaling to all the MGCurve and MGFace of this group. ///curve's (x,y) are updated. No other coordinates are unchanged. ///The updated result curve is always MGLBRep. ///For MGFace, the boundaries are polar-scaled. /// ///Rotation is performed from the angle range (angleBase,angle1) to ///(angleBase,angle2). ///That is, when angle1=angle2, no change is done. ///When angle2 is angleBase, all the data will lie on the straight of from origin to ///(cos(angleBase), sin(angleBase)). ///angle1-angleBase must be >MGTolerance::angle_zero(). ///IF a member gel is not MGCurve nor MGFace, it is unchanged. void scalePolar( double angleBase, ///& outputObjects ///グループ最下層のデータを入れる ); /// グループに含まれるすべてのobjectを取得する void getAllObjects( std::vector& allObjects ///オブジェクトデータ ); /// Equivalent to call std::list::sort(). void sort(){ m_gels.sort();} template void sort(Traits _Comp){m_gels.sort(_Comp);} ///Transform the gel by the argument. ///translation virtual void transform(const MGVector& v); ///scaling. virtual void transform(double scale); ///matrix transformation. virtual void transform(const MGMatrix& mat); ///general transformation. virtual void transform(const MGTransf& tr); virtual std::string whoami()const{return "Group";}; protected: ///Read all member data. virtual void ReadMembers(MGIfstream& buf); ///Write all member data virtual void WriteMembers(MGOfstream& buf)const; private: ///member data. A list of MGGel*. MGPlist m_gels; ///Find the 1st gel(MGGroup or MGObject) member in this MGGroup ///that has the given name. ///**********Searching IS performed into the member group recursively. void search_by_nameSub( const MGName& name, MGGroup*& groupIncluding,///