ElementAgenda.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
9 
10 typedef struct IDataObject GuiDataObject;
11 
12 #include <Bentley/bvector.h>
13 #include <Bentley/bset.h>
14 #include "ElementHandle.h"
15 
17 DGNPLATFORM_TYPEDEFS (IModifyElement)
18 DGNPLATFORM_TYPEDEFS (IRedrawOperation)
19 DGNPLATFORM_TYPEDEFS (IRedrawAbort)
21 
23 
26 {
27  Selected = 0,
28  SelectionSet = 1,
29  Fence = 2,
30  WorkingSet = 3,
31  GraphicGroup = 4,
32  NamedGroup = 5,
33  DragSelection = 6,
34  Unknown = 10,
35 };
36 
37 struct IElementAgendaEvents;
38 
39 //=======================================================================================
40 // @bsiclass Bentley Systems
41 //=======================================================================================
42 template <class T_ElemHandle> class ElemHandleArray : public bvector<T_ElemHandle>
43 {
44 public:
46  bool IsEmpty () const {return this->empty();}
48  size_t GetCount () const {return this->size();}
50  T_ElemHandle const* GetFirst () const {return IsEmpty() ? NULL : &this->front();}
52  T_ElemHandle const* GetLast () const {return IsEmpty() ? NULL : &this->back();}
54  T_ElemHandle const* GetEntry (size_t i) const {return (i >= GetCount()) ? NULL : &this->front()+i;}
56  T_ElemHandle* GetFirstP () {return IsEmpty() ? NULL : &this->front();}
58  T_ElemHandle* GetLastP () {return IsEmpty() ? NULL : &this->back();}
60  T_ElemHandle* GetEntryP (size_t i) {return (i >= GetCount()) ? NULL : &this->front()+i;}
62  void Empty (bool andFree=true) {if (andFree) this->clear(); else this->resize (0);}
63  DEFINE_T_SUPER(bvector<T_ElemHandle>);
64  typedef typename T_Super::iterator iterator;
65 
68  {
69  if (IsEmpty())
70  return;
71 
72  iterator curr = this->begin(); // first entry
73  iterator endIt = this->end(); // one past the last entry
74  iterator nextValid = curr; // where next valid entry should go
75 
76  for (; curr != endIt; ++curr)
77  {
78  if (curr->IsValid ())
79  {
80  if (nextValid != curr)
81  *nextValid = *curr;
82  ++nextValid;
83  }
84  }
85 
86  if (nextValid != endIt)
87  this->erase (nextValid, endIt);
88  }
89 };
90 
93 struct RedrawGroupInfo
94 {
95 public:
96 
97 enum class GroupEvent
98  {
99  OnGroupInit = 0,
100  IsElementInGroup = 1,
101  OnPostModifyElement = 2,
102  OnPostModifyGroup = 3,
103  OnGroupComplete = 4,
104  };
105 
106 private:
107  virtual void MakeClassAbstract() = 0;
108 public:
109 public:
110 
112 DGNPLATFORM_EXPORT GroupEvent GetEventType () const;
114 DGNPLATFORM_EXPORT ViewContextR GetViewContext () const;
116 DGNPLATFORM_EXPORT ElementRefP GetOriginalElement () const;
118 DGNPLATFORM_EXPORT ElementHandleCP GetModifiedElement () const;
119 
120 }; // RedrawGroupInfo
122 
125 {
127  virtual bool _DoModifyAgendaEntries (ElementAgendaP agenda, AgendaOperation, AgendaModify) {return false;}
128 
131 
133  virtual void _OnPreModifyAgenda (ElementAgendaCP agenda, AgendaOperation, AgendaModify, bool isGroupOperation) {};
134 
136  virtual void _OnPostModifyAgenda (ElementAgendaCP agenda, AgendaOperation, AgendaModify, bool isGroupOperation) {};
137 
140  virtual void _DoAddDeferredClipboardFormats (ElementAgendaP, AgendaOperation, AgendaModify, GuiDataObject*) {}
141 
143  virtual bool _OnRedrawGroupEvent (ElementAgendaCP, AgendaOperation, AgendaModify, RedrawGroupInfo const*) {return false;}
144 
145  virtual bool Dummy1 (void*) {return false;}
147 };
148 
151 {
152 public:
156  ElemAgendaEntry (ElementRefP elRef, DgnModelRefP modelRef) : EditElementHandle (elRef, modelRef) {}
158  ElemAgendaEntry (ElementHandleCR from, bool duplicateDescr) : EditElementHandle (from, duplicateDescr) {}
160  ElemAgendaEntry (ElemAgendaEntry const& from) {CopyFrom(from);}
161 
164  {
165  if (this == &from)
166  return *this;
167 
168  ClearAll();
169  return (ElemAgendaEntry&) CopyFrom (from);
170  }
171 
173  static intptr_t GetIndexFromHandleDifference (ElementHandleCP pToolElem, const ElemAgendaEntry* first)
174  {
175  //-------------------------------------------------------------------------------------
176  // NEEDSWORK_VS2012 - Without the type-cast, we get this error with VS2012
177  // error C2440: '-' : cannot convert from
178  // 'const Bentley::DgnPlatform::ElemAgendaEntry *' to 'Bentley::EditElementHandleCP'
179  //-------------------------------------------------------------------------------------
180  return pToolElem - static_cast<ElementHandleCP> (first);
181  }
182 
183 };
184 
186 {
187  Unknown = 0,
188  Yes = 1,
189  No = 2,
190 };
191 
192 //=======================================================================================
194 // @bsiclass Bentley Systems
195 //=======================================================================================
197 {
198 private:
199  ElementRefP m_elem;
200  DgnModelRefP m_modelRef;
201 public:
202  ElemModelPair () {m_elem = NULL, m_modelRef = NULL;}
204  ElemModelPair (ElementRefP el, DgnModelRefP modelRef) {m_elem = el, m_modelRef = modelRef;}
206  ElementRefP GetElementRef () const {return m_elem;}
208  DgnModelRefP GetModelRef() const {return m_modelRef;}
210  bool IsLess (ElemModelPair const& other) const {return (m_modelRef == other.m_modelRef) ? (m_elem<other.m_elem) : (m_modelRef<other.m_modelRef);}
211 };
212 
213 //=======================================================================================
215 // @bsiclass Bentley Systems
216 //=======================================================================================
217 struct ElemModelCompare {bool operator()(ElemModelPair const& a, ElemModelPair const& b) const {return a.IsLess(b);}};
218 
219 //=======================================================================================
224 // @bsiclass Bentley Systems
225 //=======================================================================================
226 struct ElemModelPairSet : bset<ElemModelPair, ElemModelCompare>
227 {
229  void Add (ElementRefP el, DgnModelRefP modelRef) {insert (ElemModelPair(el, modelRef));}
230 };
231 
232 
234 //=======================================================================================
255 // @bsiclass Bentley Systems
256 //=======================================================================================
257 struct ElementAgenda : RefCounted <T_AgendumVector>
258 {
259 private:
260  ModifyElementSource m_source;
261  AgendaHilitedState m_hilitedState;
262 
263 public:
264 
269 DGNPLATFORM_EXPORT virtual ~ElementAgenda();
270 
282  DGNVIEW_EXPORT void Draw (ViewportP viewport, DgnDrawMode drawMode, DrawPurpose drawPurpose, IRedrawOperationP redrawOp, ClipVectorCP clip, IRedrawAbortP abort);
283 
293  DGNVIEW_EXPORT void DrawInAllViews (DgnDrawMode drawMode, DrawPurpose drawPurpose, IRedrawOperationP redrawOp, ClipVectorCP clip, IRedrawAbortP abort);
294 
297  DGNVIEW_EXPORT void Clear ();
298 
302  void SetCapacity (int nEntries) {reserve (nEntries);}
303 
307  ModifyElementSource GetSource () const {return m_source;}
308 
311  void SetSource (ModifyElementSource val) {m_source = val;}
312 
320  DGNPLATFORM_EXPORT EditElementHandleCP Find (ElementRefP elRef, DgnModelRefP modelRef, size_t startIndex=0, size_t endIndex=-1) const;
321 
329  DGNPLATFORM_EXPORT EditElementHandleP Insert (EditElementHandleR eeh, bool atHead = false);
330 
340  DGNPLATFORM_EXPORT EditElementHandleP Insert (ElementRefP elRef, DgnModelRefP modelRef, bool atHead=false);
341 
355  DGNVIEW_EXPORT EditElementHandleP InsertPath (DisplayPathCP path, bool doGroups, bool allowLocked);
356 
371  DGNPLATFORM_EXPORT EditElementHandleP InsertPath (DisplayPathCP path, bool doGroups, bool groupLockState, bool allowLocked);
372 
381  DGNPLATFORM_EXPORT void Insert (ElemModelPairSet& pairSet);
382 
393  DGNVIEW_EXPORT StatusInt ModifyAgenda (IModifyElementP modifyOp, bool redraw);
394 
400  DGNVIEW_EXPORT StatusInt BuildFromElementSet (IElementSetP elementSet, ModifyElementSource source);
401 
412  DGNVIEW_EXPORT StatusInt BuildFromFence (DgnModelRefP fenceModel, DgnModelRefListP modelRefs, bool overlap, bool modifyOrig, bool allowLocked, bool callAsynchs);
413 
418  DGNPLATFORM_EXPORT void BuildFromViewport (ViewportR viewPort);
419 
424  DGNVIEW_EXPORT void Hilite ();
425 
428  DGNVIEW_EXPORT void ClearHilite ();
429 
433  MSCORE_EXPORT static void AddListener (IElementAgendaEvents* agendaListener);
434 
436  MSCORE_EXPORT static void DropListener (IElementAgendaEvents* agendaListener);
437 };
438 
439 /*=================================================================================**/
444 {
445 private:
446  virtual void _DrawElementAgenda (ElementAgendaR agenda, DgnDrawMode drawMode, DrawPurpose purpose) = 0;
447 public:
450  DGNPLATFORM_EXPORT void DrawElementAgenda (ElementAgendaR agenda, DgnDrawMode drawMode, DrawPurpose purpose);
451 }; // IDrawElementAgenda
452 
AgendaOperation
Definition: DgnPlatform.h:1472
bool empty() const
Definition: stdcxx/bstdmap.h:210
ElemAgendaEntry(ElementHandleCR from, bool duplicateDescr)
Create an ElemAgendaEntry which is an EditElementHandle in an ElementAgenda. See EditElementHandle(El...
Definition: ElementAgenda.h:158
A lightweight structure to hold an ElementRefP and DgnModelRef pair with a comparison operator...
Definition: ElementAgenda.h:196
The element is selected by the user by drag selection or multi-selection using ctrl.
The element is processed because it is in the selection set.
#define END_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:69
ElemAgendaEntry(ElementRefP elRef, DgnModelRefP modelRef)
Create an ElemAgendaEntry which is an EditElementHandle in an ElementAgenda. See EditElementHandle(El...
Definition: ElementAgenda.h:156
void Empty(bool andFree=true)
Remove all elements from the array. Call delete on the elements if andFree is specified.
Definition: ElementAgenda.h:62
void SetSource(ModifyElementSource val)
Set the source for this ElementAgenda.
Definition: ElementAgenda.h:311
ElementRefP GetElementRef() const
Extract the ElementRef from the ElemModelPair.
Definition: ElementAgenda.h:206
Provides Bentley specific set implementation (Bentley/bset.h).
T_ElemHandle * GetFirstP()
Return an editable pointer the first elemement in the ElemHandleArray or NULL if it is empty...
Definition: ElementAgenda.h:56
EditElementHandle residing in an ElementAgenda
Definition: ElementAgenda.h:150
ElemAgendaEntry()
Create an ElemAgendaEntry which is an EditElementHandle in an ElementAgenda.
Definition: ElementAgenda.h:154
struct DgnPlatform::ClipVector const * ClipVectorCP
Definition: DgnPlatform.h:178
AgendaModify
Definition: DgnPlatform.h:1464
struct DgnPlatform::ElementAgenda const * ElementAgendaCP
Definition: DgnPlatform.h:258
struct IDataObject GuiDataObject
Definition: ElementAgenda.h:10
iterator begin()
Definition: stdcxx/bstdmap.h:178
virtual void _OnPostModifyAgenda(ElementAgendaCP agenda, AgendaOperation, AgendaModify, bool isGroupOperation)
Called after the tool operation is applied to the agenda.
Definition: ElementAgenda.h:136
Definition: NamedGroup.h:449
virtual void _OnPreModifyAgenda(ElementAgendaCP agenda, AgendaOperation, AgendaModify, bool isGroupOperation)
Called before the tool operation is applied to the agenda.
Definition: ElementAgenda.h:133
Interface for an agent that can display elements.
Definition: ElementAgenda.h:443
static intptr_t GetIndexFromHandleDifference(ElementHandleCP pToolElem, const ElemAgendaEntry *first)
Return the index of a given ElementHandle in the Agenda.
Definition: ElementAgenda.h:173
T_ElemHandle const * GetFirst() const
Return the first elemement in the ElemHandleArray or NULL if it is empty.
Definition: ElementAgenda.h:50
iterator end()
Definition: stdcxx/bstdmap.h:186
ElemAgendaEntry(ElemAgendaEntry const &from)
Create an ElemAgendaEntry from another ElemAgendaEntry. Any ElementDescriptors contained will not be ...
Definition: ElementAgenda.h:160
DrawPurpose
Definition: DgnPlatform.h:1548
A writeable "handle" to an MSElement.
Definition: ElementHandle.h:470
T_ElemHandle const * GetEntry(size_t i) const
Return the ith elemement in the ElemHandleArray or NULL if it is empty.
Definition: ElementAgenda.h:54
T_ElemHandle * GetEntryP(size_t i)
Return an editable pointer the ith elemement in the ElemHandleArray or NULL if it is empty...
Definition: ElementAgenda.h:60
#define DGNPLATFORM_EXPORT
Definition: DgnPlatform/ExportMacros.h:58
iterator erase(iterator __it)
Definition: stdcxx/bstdmap.h:242
Template to simplify the task of writing a class that implements the reference-counting pattern...
Definition: RefCounted.h:90
#define NULL
Definition: Bentley.h:157
bstdmap & operator=(const bstdmap &__rhs)
Definition: stdcxx/bstdmap.h:170
ElemModelPair(ElementRefP el, DgnModelRefP modelRef)
Create an ElemModelPair, which is simply an ElementRefP and a DgnModelRefP.
Definition: ElementAgenda.h:204
This interface provides a transparent way to provide access to a collection of ElemHandles.
Definition: ElementHandle.h:726
Comparison function for ElemModelPair entries in ElemModelPairSet.
Definition: ElementAgenda.h:217
bool IsLess(ElemModelPair const &other) const
Compare two ElemModelPair's in a consistant manner. This is so they will work in an ElemModelPairSet...
Definition: ElementAgenda.h:210
struct DgnPlatform::DisplayPath const * DisplayPathCP
Definition: DgnPlatform.h:236
size_t GetCount() const
Now just a wrapper around vector->size(). Returns the number of elements in the ElemHandleArray.
Definition: ElementAgenda.h:48
T_Super::iterator iterator
Definition: ElementAgenda.h:63
virtual void _OnPreCopyAgenda(ElementAgendaCP agenda, AgendaOperation, AgendaModify, ElementCopyContextP)
Called to allow listeners to copy additional information from source to destination not appropriate t...
Definition: ElementAgenda.h:130
A DgnModelRef provides access to a model in a Bentley::DgnPlatform::DgnFile.
Definition: DgnModelRef.h:172
ElemModelPair()
Definition: ElementAgenda.h:202
The element is processed because it is passes the fence criteria.
T_ElemHandle const * GetLast() const
Return the last elemement in the ElemHandleArray or NULL if it is empty.
Definition: ElementAgenda.h:52
A bvector of EditElementHandle entries to be used for operating on groups of elements.
Definition: ElementAgenda.h:257
#define DGNPLATFORM_TYPEDEFS(_name_)
Definition: DgnPlatform.h:73
virtual bool _DoModifyAgendaEntries(ElementAgendaP agenda, AgendaOperation, AgendaModify)
Called to allow listeners to modify the agenda by adding/removing entries before applying tool operat...
Definition: ElementAgenda.h:127
struct DgnPlatform::ElementHandle const * ElementHandleCP
Definition: DgnPlatform.h:260
A set of unique ElementRefP/DgnModelRef entries.
Definition: ElementAgenda.h:226
Interface that provides direct and efficient access to element data.
Definition: ElementRefBase.h:120
*//* Bentley Systems
Definition: DgnModelRef.h:67
Interface to notfy applications of ElementAgenda activity.
Definition: ElementAgenda.h:124
The element is selected by the user.
#define DEFINE_T_SUPER(B)
Definition: Bentley.h:167
ElemHandleArray< ElemAgendaEntry > T_AgendumVector
Definition: ElementAgenda.h:233
#define BEGIN_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:68
ModifyElementSource
this gets passed as an argument to the element function
Definition: ElementAgenda.h:25
The element is processed because it belongs to the graphic group of the selected element.
Use the ElementCopyContext class to copy elements.
Definition: ElementCopyContext.h:241
void SetCapacity(int nEntries)
Set the capacity for this ElementAgenda.
Definition: ElementAgenda.h:302
int StatusInt
Definition: Bentley.h:222
struct DgnPlatform::ElementRefBase * ElementRefP
Definition: DgnPlatform.h:166
AgendaHilitedState
Definition: ElementAgenda.h:185
T_ElemHandle * GetLastP()
Return an editable pointer the last elemement in the ElemHandleArray or NULL if it is empty...
Definition: ElementAgenda.h:58
DgnDrawMode
Draw modes for displaying information in viewports.
Definition: DgnPlatform.h:1536
void clear()
Definition: stdcxx/bstdmap.h:257
struct DgnPlatform::ElementHandle const & ElementHandleCR
Definition: DgnPlatform.h:260
Definition: ElementAgenda.h:42
bool IsEmpty() const
Now just a wrapper around vector->empty(). Returns true if the ElemHandleArray contains no elements...
Definition: ElementAgenda.h:46
The element is processed because it is is in the working set.
void Add(ElementRefP el, DgnModelRefP modelRef)
Add an ElementRefP/DgnModelRef pair to this set. If set already contains the pair, it does not add a new entry.
Definition: ElementAgenda.h:229
size_type size() const
Definition: stdcxx/bstdmap.h:214
bool operator()(ElemModelPair const &a, ElemModelPair const &b) const
Definition: ElementAgenda.h:217
DgnModelRefP GetModelRef() const
Extract the ModelRef from the ElemModelPair.
Definition: ElementAgenda.h:208
ModifyElementSource GetSource() const
Get the source for this ElementAgenda, if applicable.
Definition: ElementAgenda.h:307
bpair< iterator, bool > insert(const value_type &__x)
Definition: stdcxx/bstdmap.h:228
void DropInvalidEntries()
Remove all elements from the array that are invalid elements. See ElementHandle::IsValid().
Definition: ElementAgenda.h:67
struct DgnPlatform::ViewContext & ViewContextR
Definition: DgnPlatform.h:469
struct DgnPlatform::EditElementHandle const * EditElementHandleCP
Definition: DgnPlatform.h:254
Definition: DgnViewport.h:186
unknown status (newly added to system)

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.