00001 // 00002 // Copyright (c) 2000 by Tech Soft 3D, LLC. 00003 // The information contained herein is confidential and proprietary to 00004 // Tech Soft 3D, LLC., and considered a trade secret as defined under 00005 // civil and criminal statutes. Tech Soft 3D shall pursue its civil 00006 // and criminal remedies in the event of unauthorized use or misappropriation 00007 // of its trade secrets. Use of this information by anyone other than 00008 // authorized employees of Tech Soft 3D, LLC. is granted only under a 00009 // written non-disclosure agreement, expressly prescribing the scope and 00010 // manner of such use. 00011 // 00012 // $Id$ 00013 // 00014 00021 #ifndef _HSELECTIONSET_H 00022 #define _HSELECTIONSET_H 00023 00024 #ifdef H_PACK_8 00025 #pragma pack(push) 00026 #pragma pack(8) 00027 #endif 00028 00029 #include "HTools.h" 00030 #include "HGlobals.h" 00031 00032 00038 enum HSelectLevel 00039 { 00040 HSelectSegment, 00041 HSelectEntity, 00042 HSelectRegion, 00043 HSelectSubentity 00044 }; 00049 //forward declaration 00050 class HBaseView; 00051 class HSelectionItem; 00052 class HShellObject; 00053 class HVHashPShowCache; 00054 class HSelHash; 00055 class HSelList; 00056 class HSelectionSegmentConditionInfo; 00057 class HConditionStyleKeyInfoHash; 00058 00059 00060 00061 00063 00071 class MVO_API HSelectionSet 00072 { 00073 friend class HBaseView; 00074 00075 00076 protected: 00077 HBaseView * m_pView; 00078 HSelList * m_pSelItemsList; 00079 struct vhash_s *m_pHighlightSegsHash; 00080 HC_KEY m_SelectionSegment; 00081 HC_KEY m_TransparencyStyle; 00082 00083 HPixelRGBA m_selectedFaceColor; 00084 HPixelRGBA m_selectedEdgeColor; 00085 HPixelRGBA m_selectedCutEdgeColor; 00086 HPixelRGBA m_selectedCutFaceColor; 00087 HPixelRGBA m_selectedMarkerColor; 00088 00089 float m_fselectedEdgeWeight; 00090 float m_fselectedMarkerSize; 00091 00092 bool m_bForceGrayScale; 00093 bool m_bForceInvisible; 00094 bool m_bAllowDisplacement; 00095 bool m_bHighlightRegionEdges; 00096 bool m_bHighlightAnnotations; 00097 HRegionEdgeHighlightMode m_bHighlightRegionEdgesAutoVisibility; 00098 HRegionFaceHighlightMode m_bHighlightRegionFacesAutoVisibility; 00099 00100 HSelectionHighlightMode m_HighlightMode; 00101 float m_fTransmission; 00102 bool m_bSortSelectionList; 00103 00104 bool m_bNotify; 00105 00106 00110 virtual void UpdateTransparency(bool force_flush=false); 00111 00112 public: 00114 HSelectionSet(HBaseView* view, bool bReferenceSelection = false); 00115 00116 virtual ~HSelectionSet(); 00117 00121 virtual void Init(); 00122 00123 00142 virtual void Select(HC_KEY key, int num_include_keys, HC_KEY include_keys[], bool emit_message = false); 00143 00157 virtual void Select(HSelectionItem * new_sel, bool emit_message = false); 00158 00176 virtual void SelectRegion(HShellObject const & oShell, int num_include_keys, HC_KEY include_keys[], int region, bool emit_message); 00177 00178 00202 virtual void SelectSubentity(HC_KEY key, int num_include_keys, HC_KEY include_keys[], 00203 int count, const int faces[]=0, const int vertex1[]=0, const int vertex2[]=0, bool emit_message=false); 00204 00218 virtual void Select(HC_KEY key, const char* segpath, HC_KEY include_key, HC_KEY includer_key, bool emit_message = false); 00219 00235 virtual void DeSelect(HC_KEY key, bool emit_message = false); 00236 00254 virtual void DeSelect(HC_KEY key, int num_include_keys, HC_KEY include_keys[], bool emit_message = false); 00255 00266 virtual void DeSelect(HSelectionItem * remove_sel, bool emit_message = false); 00267 00282 virtual void DeSelectRegion(HShellObject const & oShell, int region, bool emit_messag); 00283 00303 virtual void DeSelectRegion(HShellObject const & oShell, int num_include_keys, HC_KEY include_keys[], int region, bool emit_message = false); 00304 00305 00312 virtual void DeSelectSubentity(HC_KEY key, int num_include_keys, HC_KEY include_keys[], 00313 int count, const int faces[], const int vertex1[], const int vertex2[], bool emit_message = false); 00314 00316 virtual bool HighlightRegionEdges() {return m_bHighlightRegionEdges;}; 00317 00319 virtual void HighlightRegionEdges(bool yesno) {m_bHighlightRegionEdges = yesno;}; 00320 00322 virtual bool HighlightAnnotations() {return m_bHighlightAnnotations;}; 00323 00325 virtual void HighlightAnnotations(bool yesno) {m_bHighlightAnnotations = yesno;}; 00326 00328 virtual HRegionEdgeHighlightMode HighlightRegionEdgesAutoVisibility() {return m_bHighlightRegionEdgesAutoVisibility;}; 00329 00331 virtual void HighlightRegionEdgesAutoVisibility(bool yesno) {m_bHighlightRegionEdgesAutoVisibility = yesno ? AllEdges : NoEdges;}; 00332 00334 virtual void HighlightRegionEdgesAutoVisibility(HRegionEdgeHighlightMode edge_state) {m_bHighlightRegionEdgesAutoVisibility = edge_state;}; 00335 00337 virtual void HighlightRegionFacesAutoVisibility(HRegionFaceHighlightMode face_state) {m_bHighlightRegionFacesAutoVisibility = face_state;}; 00338 00340 virtual HRegionFaceHighlightMode HighlightRegionFacesAutoVisibility() {return m_bHighlightRegionFacesAutoVisibility;}; 00341 00349 virtual void DeSelectAll(); 00350 00361 virtual bool IsSelected(HC_KEY key) const; 00362 00380 virtual bool IsSelected(HC_KEY key, int num_include_keys, const HC_KEY include_keys[]) const; 00381 00393 virtual bool IsSelected(const HSelectionItem * item) const; 00394 00413 virtual bool IsRegionSelected(HC_KEY key, int num_include_keys, const HC_KEY include_keys[], int region) const; 00414 00420 virtual bool IsHighlightSegment(HC_KEY segment_key) const; 00421 00426 virtual void SetSelectionFaceColor(HPixelRGBA &rgba){m_selectedFaceColor = rgba; UpdateHighlightStyle();} 00427 00432 virtual void SetGrayScale(bool grayScale); 00433 00434 00439 virtual void SetInvisible(bool Invisible); 00440 00444 virtual bool GetInvisible() { return m_bForceInvisible; } 00445 00446 00450 virtual void SetAllowDisplacement(bool allowDisplacement) { m_bAllowDisplacement = allowDisplacement; } 00451 00455 virtual bool GetAllowDisplacement() { return m_bAllowDisplacement; } 00456 00461 virtual HSelList * GetSelectionList(); 00462 00467 virtual void GetSelectionFaceColor(HPixelRGBA &rgba){ rgba = m_selectedFaceColor; }; 00468 00469 00474 virtual void SetSelectionEdgeColor(HPixelRGBA &rgb){m_selectedEdgeColor = rgb; UpdateHighlightStyle();} 00475 00480 virtual void GetSelectionEdgeColor(HPixelRGBA &rgba){ rgba = m_selectedEdgeColor; }; 00481 00482 00487 virtual void SetSelectionCutEdgeColor(HPixelRGBA &rgb){m_selectedCutEdgeColor = rgb; UpdateHighlightStyle();} 00488 00493 virtual void GetSelectionCutEdgeColor(HPixelRGBA &rgba){ rgba = m_selectedCutEdgeColor; }; 00494 00499 virtual void SetSelectionCutFaceColor(HPixelRGBA &rgb){m_selectedCutFaceColor = rgb; UpdateHighlightStyle();} 00500 00505 virtual void GetSelectionCutFaceColor(HPixelRGBA &rgba){ rgba = m_selectedCutFaceColor; }; 00506 00511 virtual void SetSelectionMarkerColor(HPixelRGBA &rgb){m_selectedMarkerColor = rgb; UpdateHighlightStyle();} 00512 00513 00518 virtual void GetSelectionMarkerColor(HPixelRGBA &rgba){ rgba = m_selectedMarkerColor; }; 00519 00524 virtual void SetSelectionEdgeWeight(float weight){m_fselectedEdgeWeight= weight; UpdateHighlightStyle();} 00525 00526 00531 virtual float GetSelectionEdgeWeight(){return m_fselectedEdgeWeight;} 00532 00533 00538 virtual void SetSelectionMarkerSize(float size){m_fselectedMarkerSize = size; UpdateHighlightStyle();} 00539 00544 virtual float GetSelectionMarkerSize(){return m_fselectedMarkerSize;} 00545 00551 virtual HC_KEY GetAt(unsigned int index); 00552 00553 00558 const HSelectionItem * GetSelectionItemAt(unsigned int index); 00559 00560 00565 const HSelectionItem * GetSelectionItem(HC_KEY key); 00566 00567 00569 unsigned int GetSize() const; 00570 00574 virtual void Reset(); 00575 00576 00582 virtual bool DeleteSelection(bool emit_message=false); 00583 00587 HC_KEY GetHighlightStyle() const{ return m_keyHighlightStyle; }; 00588 void SetHighlightStyle(HC_KEY key) { m_keyHighlightStyle = key; }; 00589 00590 00605 bool DeInstance(HSelectionItem * sel_item); 00606 00607 00612 bool DeInstance(unsigned int index); 00613 00618 virtual bool GetSubwindowPenetration() { return m_bSubwindowPenetration; } 00619 00627 virtual void SetSubwindowPenetration(bool allow); 00628 00630 virtual bool GetAllowSubentitySelection() { return m_selection_level == HSelectSubentity; } 00631 00636 virtual void SetAllowSubentitySelection(bool allow); 00637 00639 virtual HSelectLevel GetSelectionLevel() const { return m_selection_level; } 00640 00643 virtual void SetSelectionLevel(HSelectLevel level); 00644 00646 virtual bool GetAllowEntitySelection() { return m_selection_level == HSelectEntity; } 00647 00648 00653 virtual void SetAllowEntitySelection(bool allow); 00654 00656 virtual bool GetAllowRegionSelection() const { return m_selection_level == HSelectRegion; } 00657 00662 virtual void SetAllowRegionSelection(bool allow); 00663 00668 void RegisterHighlightSeg(HC_KEY seg_key); 00669 00674 void UnRegisterHighlightSeg(HC_KEY seg_key); 00675 00679 virtual const HSelectionHighlightMode GetHighlightMode() { return m_HighlightMode; } 00680 00707 virtual void SetHighlightMode(HSelectionHighlightMode m); 00708 00712 virtual void SetHighlightTransparency(float trans); 00713 00718 virtual HC_KEY GetSelectionSegment() {return m_SelectionSegment;} 00719 00725 void ToggleHighlightStyle(); 00726 00731 virtual bool GetIsSelection(HC_KEY key); 00732 00738 virtual bool GetReferenceSelection() const {return (m_HighlightMode!=HighlightDefault 00739 || m_selection_level == HSelectSubentity);} 00740 00746 virtual void SetReferenceSelection(bool ref_sel) { 00747 m_HighlightMode = ref_sel ? HighlightQuickmoves : HighlightDefault; 00748 } 00749 00754 virtual void SetReferenceSelectionType(HRefSelType type); 00755 00756 00760 virtual void UpdateHighlightStyle(); 00761 00767 HVHashPShowCache * GetPShowCache(){ return m_pshow_cache; } 00768 00774 void SetPShowCache(HVHashPShowCache * new_cache){ m_pshow_cache=new_cache; } 00775 00779 void FlushPShowCache(); 00780 00784 void UpdateHighlighting(); 00785 00786 HBaseView * GetView() { return m_pView; } 00787 00791 void SetSortSelectionList(bool sort) { m_list_last_updated=0; m_bSortSelectionList=sort;} 00792 00796 bool GetSortSelectionList() {return m_bSortSelectionList;} 00797 00801 virtual bool GetSubentityFaceSelection() { return m_subentity_face; } 00802 00806 virtual void SetSubentityFaceSelection(bool select) { m_subentity_face=select; } 00807 00811 virtual bool GetSubentityEdgeSelection() { return m_subentity_edge; } 00812 00816 virtual void SetSubentityEdgeSelection(bool select) { m_subentity_edge=select; } 00817 00821 virtual bool GetSubentityVertexSelection() { return m_subentity_vertex; } 00822 00826 virtual void SetSubentityVertexSelection(bool select) { m_subentity_vertex=select; } 00827 00831 virtual void SetAllowSubentityDeselection(bool allow) { SetSubentityTracking(allow); } 00832 00836 virtual bool GetAllowSubentityDeselection() { return GetSubentityTracking(); } 00837 00845 virtual void SetSubentityTracking(bool allow) { m_subentity_maintain_maps = allow; } 00846 00850 virtual bool GetSubentityTracking() { return m_subentity_maintain_maps; } 00851 00857 void GetSelectionBounding(HPoint * minimum, HPoint * maximum) const; 00858 00859 00863 virtual void SetSelectWillNotify(bool notify) {m_bNotify = notify;} 00864 00866 virtual bool GetSelectWillNotify() const { return m_bNotify; } 00867 00868 00869 // internal use only 00870 int GetAttrLookupID(const char * attribute_string); 00871 HSelectionSegmentConditionInfo * GetSelectionSegmentConditionInfo(); 00872 HConditionStyleKeyInfoHash * GetConditionStyleKeyInfo(); 00873 00874 00875 private: 00876 void HoopsRemove( HC_KEY key ); 00877 void DeselectSegment( HC_KEY key, char const *keytype ); 00878 void DeselectGeometry( HC_KEY key ); 00879 00883 inline bool is_selected(HC_KEY key) const; 00884 00885 void ensure_is_segment(HC_KEY &key) const; 00886 00887 00888 int m_AttrID; 00889 struct vhash_s *m_pAttrLookupHash; 00890 00891 HSelectionSegmentConditionInfo * m_pSelectionSegmentConditionInfo; 00892 HConditionStyleKeyInfoHash * m_pConditionStyleKeyInfoHash; 00893 00894 00895 HVHashPShowCache * m_pshow_cache; 00896 HSelHash * m_selected_hash; 00897 float m_hash_last_updated; 00898 float m_list_last_updated; 00899 HRefSelType m_quickmoves_type; 00900 00901 HC_KEY m_keyHighlightStyle; 00902 00903 HSelectLevel m_selection_level; 00904 00905 bool m_subentity_face; 00906 bool m_subentity_edge; 00907 bool m_subentity_vertex; 00908 bool m_subentity_maintain_maps; 00909 00910 bool m_bSubwindowPenetration; 00911 00912 bool m_currently_in_DeleteSelection; 00913 }; 00914 00915 00916 #ifdef H_PACK_8 00917 #pragma pack(pop) 00918 #endif 00919 00920 #endif 00921 00922 00923