00001 // Copyright (c) 1998-2014 by Tech Soft 3D, Inc. 00002 // 00003 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., 00004 // and considered a trade secret as defined under civil and criminal statutes. 00005 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of 00006 // unauthorized use or misappropriation of its trade secrets. Use of this information 00007 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under 00008 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use. 00009 00016 #ifndef _HSELECTIONSET_H 00017 #define _HSELECTIONSET_H 00018 00019 #ifdef H_PACK_8 00020 #pragma pack(push) 00021 #pragma pack(8) 00022 #endif 00023 00024 #include "HTools.h" 00025 #include "HGlobals.h" 00026 00027 00033 enum HSelectLevel 00034 { 00035 HSelectSegment, 00036 HSelectEntity, 00037 HSelectRegion, 00038 HSelectSubentity 00039 }; 00044 //forward declaration 00045 class HBaseView; 00046 class HSelectionItem; 00047 class HShellObject; 00048 class HVHashPShowCache; 00049 class HSelHash; 00050 class HSelList; 00051 class HSelectionSegmentConditionInfo; 00052 class HConditionStyleKeyInfoHash; 00053 00054 00055 00056 00058 00066 class MVO_API HSelectionSet 00067 { 00068 friend class HBaseView; 00069 00070 00071 protected: 00072 HBaseView * m_pView; 00073 HSelList * m_pSelItemsList; 00074 struct vhash_s *m_pHighlightSegsHash; 00075 HC_KEY m_SelectionSegment; 00076 HC_KEY m_TransparencyStyle; 00077 00078 HPixelRGBA m_selectedFaceColor; 00079 HPixelRGBA m_selectedEdgeColor; 00080 HPixelRGBA m_selectedCutEdgeColor; 00081 HPixelRGBA m_selectedCutFaceColor; 00082 HPixelRGBA m_selectedMarkerColor; 00083 00084 float m_fselectedEdgeWeight; 00085 float m_fselectedMarkerSize; 00086 00087 bool m_bForceGrayScale; 00088 bool m_bForceInvisible; 00089 bool m_bAllowDisplacement; 00090 bool m_bHighlightRegionEdges; 00091 bool m_bHighlightAnnotations; 00092 HRegionEdgeHighlightMode m_bHighlightRegionEdgesAutoVisibility; 00093 HRegionFaceHighlightMode m_bHighlightRegionFacesAutoVisibility; 00094 00095 HSelectionHighlightMode m_HighlightMode; 00096 float m_fTransmission; 00097 bool m_bSortSelectionList; 00098 00099 bool m_bNotify; 00100 00101 bool m_bUseDefinedHighlight; 00102 00103 00107 virtual void UpdateTransparency(bool force_flush=false); 00108 00109 public: 00111 HSelectionSet(HBaseView* view, bool bReferenceSelection = false); 00112 00113 virtual ~HSelectionSet(); 00114 00118 virtual void Init(); 00119 00120 00139 virtual void Select(HC_KEY key, int num_include_keys, HC_KEY include_keys[], bool emit_message = false); 00140 00154 virtual void Select(HSelectionItem * new_sel, bool emit_message = false); 00155 00173 virtual void SelectRegion(HShellObject const & oShell, int num_include_keys, HC_KEY include_keys[], int region, bool emit_message); 00174 00175 00199 virtual void SelectSubentity(HC_KEY key, int num_include_keys, HC_KEY include_keys[], 00200 int count, const int faces[]=0, const int vertex1[]=0, const int vertex2[]=0, bool emit_message=false); 00201 00215 virtual void Select(HC_KEY key, const char* segpath, HC_KEY include_key, HC_KEY includer_key, bool emit_message = false); 00216 00232 virtual void DeSelect(HC_KEY key, bool emit_message = false); 00233 00251 virtual void DeSelect(HC_KEY key, int num_include_keys, HC_KEY include_keys[], bool emit_message = false); 00252 00263 virtual void DeSelect(HSelectionItem * remove_sel, bool emit_message = false); 00264 00279 virtual void DeSelectRegion(HShellObject const & oShell, int region, bool emit_messag); 00280 00300 virtual void DeSelectRegion(HShellObject const & oShell, int num_include_keys, HC_KEY include_keys[], int region, bool emit_message = false); 00301 00302 00309 virtual void DeSelectSubentity(HC_KEY key, int num_include_keys, HC_KEY include_keys[], 00310 int count, const int faces[], const int vertex1[], const int vertex2[], bool emit_message = false); 00311 00312 00313 00314 00315 00316 virtual bool SelectSubentityOOC ( 00317 HC_KEY key, int num_include_keys, HC_KEY include_keys[], 00318 int count, int const faces[] = 0, int const vertex1[] = 0, int const vertex2[] = 0, 00319 bool emit_message = false); 00320 00321 virtual bool DeSelectOOC ( 00322 HC_KEY key, int num_include_keys, HC_KEY include_keys[], 00323 bool emit_message = false); 00324 00325 00326 00327 00329 virtual bool HighlightRegionEdges() {return m_bHighlightRegionEdges;}; 00330 00332 virtual void HighlightRegionEdges(bool yesno) {m_bHighlightRegionEdges = yesno;}; 00333 00335 virtual bool HighlightAnnotations() {return m_bHighlightAnnotations;}; 00336 00338 virtual void HighlightAnnotations(bool yesno) {m_bHighlightAnnotations = yesno;}; 00339 00341 virtual HRegionEdgeHighlightMode HighlightRegionEdgesAutoVisibility() {return m_bHighlightRegionEdgesAutoVisibility;}; 00342 00344 virtual void HighlightRegionEdgesAutoVisibility(bool yesno) {m_bHighlightRegionEdgesAutoVisibility = yesno ? AllEdges : NoEdges;}; 00345 00347 virtual void HighlightRegionEdgesAutoVisibility(HRegionEdgeHighlightMode edge_state) {m_bHighlightRegionEdgesAutoVisibility = edge_state;}; 00348 00350 virtual void HighlightRegionFacesAutoVisibility(HRegionFaceHighlightMode face_state) {m_bHighlightRegionFacesAutoVisibility = face_state;}; 00351 00353 virtual HRegionFaceHighlightMode HighlightRegionFacesAutoVisibility() {return m_bHighlightRegionFacesAutoVisibility;}; 00354 00362 virtual void DeSelectAll(); 00363 00374 virtual bool IsSelected(HC_KEY key) const; 00375 00393 virtual bool IsSelected(HC_KEY key, int num_include_keys, const HC_KEY include_keys[]) const; 00394 00406 virtual bool IsSelected(const HSelectionItem * item) const; 00407 00426 virtual bool IsRegionSelected(HC_KEY key, int num_include_keys, const HC_KEY include_keys[], int region) const; 00427 00433 virtual bool IsHighlightSegment(HC_KEY segment_key) const; 00434 00439 virtual void SetSelectionFaceColor(HPixelRGBA &rgba){m_selectedFaceColor = rgba; UpdateHighlightStyle();} 00440 00445 virtual void SetGrayScale(bool grayScale); 00446 00447 00452 virtual void SetInvisible(bool Invisible); 00453 00457 virtual bool GetInvisible() { return m_bForceInvisible; } 00458 00459 00463 virtual void SetAllowDisplacement(bool allowDisplacement) { m_bAllowDisplacement = allowDisplacement; } 00464 00468 virtual bool GetAllowDisplacement() { return m_bAllowDisplacement; } 00469 00474 virtual HSelList * GetSelectionList(); 00475 00480 virtual void GetSelectionFaceColor(HPixelRGBA &rgba){ rgba = m_selectedFaceColor; }; 00481 00482 00487 virtual void SetSelectionEdgeColor(HPixelRGBA &rgb){m_selectedEdgeColor = rgb; UpdateHighlightStyle();} 00488 00493 virtual void GetSelectionEdgeColor(HPixelRGBA &rgba){ rgba = m_selectedEdgeColor; }; 00494 00495 00500 virtual void SetSelectionCutEdgeColor(HPixelRGBA &rgb){m_selectedCutEdgeColor = rgb; UpdateHighlightStyle();} 00501 00506 virtual void GetSelectionCutEdgeColor(HPixelRGBA &rgba){ rgba = m_selectedCutEdgeColor; }; 00507 00512 virtual void SetSelectionCutFaceColor(HPixelRGBA &rgb){m_selectedCutFaceColor = rgb; UpdateHighlightStyle();} 00513 00518 virtual void GetSelectionCutFaceColor(HPixelRGBA &rgba){ rgba = m_selectedCutFaceColor; }; 00519 00524 virtual void SetSelectionMarkerColor(HPixelRGBA &rgb){m_selectedMarkerColor = rgb; UpdateHighlightStyle();} 00525 00526 00531 virtual void GetSelectionMarkerColor(HPixelRGBA &rgba){ rgba = m_selectedMarkerColor; }; 00532 00537 virtual void SetSelectionEdgeWeight(float weight){m_fselectedEdgeWeight= weight; UpdateHighlightStyle();} 00538 00539 00544 virtual float GetSelectionEdgeWeight(){return m_fselectedEdgeWeight;} 00545 00546 00551 virtual void SetSelectionMarkerSize(float size){m_fselectedMarkerSize = size; UpdateHighlightStyle();} 00552 00557 virtual float GetSelectionMarkerSize(){return m_fselectedMarkerSize;} 00558 00564 virtual HC_KEY GetAt(unsigned int index); 00565 00571 virtual bool GetAll(HC_KEY out_array[]); 00572 00573 00578 const HSelectionItem * GetSelectionItemAt(unsigned int index); 00579 00580 00585 const HSelectionItem * GetSelectionItem(HC_KEY key); 00586 00587 00589 unsigned int GetSize() const; 00590 00594 virtual void Reset(); 00595 00596 00602 virtual bool DeleteSelection(bool emit_message=false); 00603 00607 HC_KEY GetHighlightStyle() const{ return m_keyHighlightStyle; }; 00608 00609 00610 void SetHighlightStyle(HC_KEY key) { m_keyHighlightStyle = key; }; 00611 00612 const char * GetHighlightStyleName() const{ return m_keyHighlightStyleName; }; 00613 00628 bool DeInstance(HSelectionItem * sel_item); 00629 00630 00635 bool DeInstance(unsigned int index); 00636 00641 virtual bool GetSubwindowPenetration() { return m_bSubwindowPenetration; } 00642 00650 virtual void SetSubwindowPenetration(bool allow); 00651 00653 virtual bool GetAllowSubentitySelection() { return m_selection_level == HSelectSubentity; } 00654 00659 virtual void SetAllowSubentitySelection(bool allow); 00660 00662 virtual HSelectLevel GetSelectionLevel() const { return m_selection_level; } 00663 00666 virtual void SetSelectionLevel(HSelectLevel level); 00667 00669 virtual bool GetAllowEntitySelection() { return m_selection_level == HSelectEntity; } 00670 00671 00676 virtual void SetAllowEntitySelection(bool allow); 00677 00679 virtual bool GetAllowRegionSelection() const { return m_selection_level == HSelectRegion; } 00680 00685 virtual void SetAllowRegionSelection(bool allow); 00686 00691 void RegisterHighlightSeg(HC_KEY seg_key); 00692 00697 void UnRegisterHighlightSeg(HC_KEY seg_key); 00698 00702 virtual const HSelectionHighlightMode GetHighlightMode() { return m_HighlightMode; } 00703 00730 virtual void SetHighlightMode(HSelectionHighlightMode m); 00731 00735 virtual void SetHighlightTransparency(float trans); 00736 00741 virtual HC_KEY GetSelectionSegment() {return m_SelectionSegment;} 00742 00748 void ToggleHighlightStyle(); 00749 00754 virtual bool GetIsSelection(HC_KEY key); 00755 00761 virtual bool GetReferenceSelection() const {return m_HighlightMode!=HighlightDefault 00762 || m_selection_level == HSelectSubentity;} 00763 00769 virtual void SetReferenceSelection(bool ref_sel) { 00770 m_HighlightMode = ref_sel ? HighlightQuickmoves : HighlightDefault; 00771 } 00772 00777 void SetUseDefinedHighlight(bool use_defined_highlight); 00778 00783 bool GetUseDefinedHighlight() { 00784 return m_bUseDefinedHighlight; 00785 } 00786 00787 00792 virtual void SetReferenceSelectionType(HRefSelType type); 00793 virtual HRefSelType GetReferenceSelectionType() {return m_quickmoves_type;} 00794 00798 virtual void UpdateHighlightStyle(); 00799 00805 HVHashPShowCache * GetPShowCache(){ return m_pshow_cache; } 00806 00812 void SetPShowCache(HVHashPShowCache * new_cache){ m_pshow_cache=new_cache; } 00813 00817 void FlushPShowCache(); 00818 00822 void UpdateHighlighting(); 00823 00824 HBaseView * GetView() { return m_pView; } 00825 00829 void SetSortSelectionList(bool sort) { m_list_last_updated=0; m_bSortSelectionList=sort;} 00830 00834 bool GetSortSelectionList() {return m_bSortSelectionList;} 00835 00839 virtual bool GetSubentityFaceSelection() { return m_subentity_face; } 00840 00844 virtual void SetSubentityFaceSelection(bool select) { m_subentity_face=select; } 00845 00849 virtual bool GetSubentityEdgeSelection() { return m_subentity_edge; } 00850 00854 virtual void SetSubentityEdgeSelection(bool select) { m_subentity_edge=select; } 00855 00859 virtual bool GetSubentityVertexSelection() { return m_subentity_vertex; } 00860 00864 virtual void SetSubentityVertexSelection(bool select) { m_subentity_vertex=select; } 00865 00869 virtual void SetAllowSubentityDeselection(bool allow) { SetSubentityTracking(allow); } 00870 00874 virtual bool GetAllowSubentityDeselection() { return GetSubentityTracking(); } 00875 00883 virtual void SetSubentityTracking(bool allow) { m_subentity_maintain_maps = allow; } 00884 00888 virtual bool GetSubentityTracking() { return m_subentity_maintain_maps; } 00889 00895 void GetSelectionBounding(HPoint * minimum, HPoint * maximum) const; 00896 00897 00901 virtual void SetSelectWillNotify(bool notify) {m_bNotify = notify;} 00902 00904 virtual bool GetSelectWillNotify() const { return m_bNotify; } 00905 00906 00907 // internal use only 00908 int GetAttrLookupID(const char * attribute_string); 00909 HSelectionSegmentConditionInfo * GetSelectionSegmentConditionInfo(); 00910 HConditionStyleKeyInfoHash * GetConditionStyleKeyInfo(); 00911 00912 00913 private: 00914 void HoopsRemove( HC_KEY key ); 00915 void DeselectSegment( HC_KEY key, char const *keytype ); 00916 void DeselectGeometry( HC_KEY key ); 00917 00921 inline bool is_selected(HC_KEY key) const; 00922 00923 void ensure_is_segment(HC_KEY &key) const; 00924 00925 00926 int m_AttrID; 00927 struct vhash_s *m_pAttrLookupHash; 00928 00929 HSelectionSegmentConditionInfo * m_pSelectionSegmentConditionInfo; 00930 HConditionStyleKeyInfoHash * m_pConditionStyleKeyInfoHash; 00931 00932 00933 HVHashPShowCache * m_pshow_cache; 00934 HSelHash * m_selected_hash; 00935 float m_hash_last_updated; 00936 float m_list_last_updated; 00937 HRefSelType m_quickmoves_type; 00938 00939 HC_KEY m_keyHighlightStyle; 00940 char m_keyHighlightStyleName[32]; 00941 00942 HSelectLevel m_selection_level; 00943 00944 bool m_subentity_face; 00945 bool m_subentity_edge; 00946 bool m_subentity_vertex; 00947 bool m_subentity_maintain_maps; 00948 00949 bool m_bSubwindowPenetration; 00950 00951 bool m_currently_in_DeleteSelection; 00952 }; 00953 00954 00955 #ifdef H_PACK_8 00956 #pragma pack(pop) 00957 #endif 00958 00959 #endif 00960 00961 00962