NCBI C++ ToolKit
selection_view.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: selection_view.cpp 38835 2017-06-23 18:15:53Z katargir $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Andrey Yazhuk
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
34 #include "selection_view.hpp"
35 #include "selection_panel.hpp"
36 
38 
40 
42 
44 
46 
47 ///////////////////////////////////////////////////////////////////////////////
48 /// CSelectionView
49 
50 /// register the factory
52  decl( "view_manager_service::view_factory", new CSelectionViewFactory() )
53 ;
54 
60 
62  "Active Objects Inspector", // type name
63  "selection_inspector", // icon alias TODO
64  "Active Objects Inspector displays information about objects selected in views",
65  "Active Objects Inspector displays information about objects selected in views",
66  "SELECTION_INSPECTOR", // help ID
67  "System", // category
68  true // singleton
69 );
70 
72  : m_Service( NULL )
73  , m_Broadcasting( false )
74  , m_Panel( NULL )
75 {
76 }
77 
79 {
81 }
82 
83 /////////////////////////////////////////
84 /// IView interface implementation
85 
87 {
88  return m_TypeDescr;
89 }
90 
91 
93 {
94  if (workbench) {
96  if (m_Service) {
97  m_Service->AddListener(this);
98  }
99  } else {
100  if (m_Service) {
101  m_Service->RemoveListener(this);
102  m_Service = 0;
103  }
104  }
105 
106  if (m_Panel)
108 }
109 
111 {
112  CSelectionServiceEvent* sse = dynamic_cast<CSelectionServiceEvent*>(evt);
113  if (sse)
115  else
116  m_Panel->Update();
117 }
118 
119 void CSelectionView::CreateViewWindow( wxWindow* parent )
120 {
121  m_Panel = new CSelectionPanel(this);
122  m_Panel->Create( parent, wxID_ANY );
123 }
124 
125 
127 {
128  if( m_Panel ){
129  m_Panel->Destroy();
130  m_Panel = NULL;
131  }
132 }
133 
134 /////////////////////////////////////////
135 /// IWMClient interface implementation
136 
138 {
139  return m_Panel;
140 }
141 
142 
144 {
145  return m_TypeDescr.GetLabel();
146 }
147 
148 
150 {
151  return m_TypeDescr.GetIconAlias();
152 }
153 
154 
156 {
157  return NULL;
158 }
159 
160 
161 void CSelectionView::SetColor( const CRgbaColor& /*color*/ )
162 {
163  // do nothing
164 }
165 
166 
167 const wxMenu* CSelectionView::GetMenu()
168 {
169  return NULL;
170 }
171 
172 
173 void CSelectionView::UpdateMenu( wxMenu& /*root_menu*/ )
174 {
175 }
176 
177 
179 {
180  return CFingerprint(m_TypeDescr.GetLabel(), true);
181 }
182 
183 
184 /////////////////////////////////////////////
185 /// IRegSettings interface implementation
186 
187 void CSelectionView::SetRegistryPath( const string& path )
188 {
189  m_Panel->SetRegistryPath( path ); // store for later use
190 }
191 
193 {
195 }
196 
197 
199 {
201 }
202 
203 
205 {
207 }
208 
209 
211 {
212  CSelectionService* srv = dynamic_cast<CSelectionService*>( service );
213  m_Service = srv;
214 }
215 
216 
218 {
219  return "Active Objects Inspector";
220 }
221 
222 
224 {
225  TConstScopedObjects sel_objs;
226  GetSelection(sel_objs);
227  if( ! sel_objs.empty()) {
228  TConstObjects objs;
229  ITERATE(TConstScopedObjects, it, sel_objs) {
230  objs.push_back(it->object);
231  }
232 
233  // brodcast everything as Object selection, we cannot distinguish object
234  // selection from range selection at this point
235  evt.AddObjectSelection(objs);
236  }
237 }
238 
239 
241 {
242  // not supported
243 }
244 
245 
247 {
248  // there is no main object here
249 }
250 
251 
252 ///////////////////////////////////////////////////////////////////////////////
253 /// CSelectionViewFactory
255 {
256  static string sid("selection_inspector_factory");
257  return sid;
258 }
259 
260 
262 {
263  static string slabel("Selection Inspector Factory");
264  return slabel;
265 }
266 
267 
269 {
270  //TODO
271 }
272 
273 
275 {
277 }
278 
279 
281 {
282  return new CSelectionView();
283 }
284 
285 
287 {
289  if(print == fingerprint) {
290  return CreateInstance();
291  }
292 
293  return NULL;
294 }
295 
296 
CEventHandler.
CEvent - generic event implementation TODO TODO - Attachments.
Definition: event.hpp:86
CExtensionDeclaration - static declaration helper.
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
CSelectionEvent CSelectionEvent is used for broadcasting selection between views.
Definition: obj_event.hpp:68
bool AddObjectSelection(const CObject &obj)
Definition: obj_event.cpp:177
CSelectionPanel.
virtual void LoadSettings()
virtual void Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
virtual void SetRegistryPath(const string &reg_path)
void SetSelectionService(CSelectionService *service)
virtual bool Destroy()
virtual void SaveSettings() const
void OnSelServiceStateChange(CSelectionServiceEvent &update)
void GetSelection(TConstScopedObjects &buf) const
CSelectionViewFactory.
virtual IView * CreateInstance() const
creates a view instance
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
virtual const CViewTypeDescriptor & GetViewTypeDescriptor() const
returns a Descriptor for the View Type supported by the Factory
virtual void RegisterIconAliases(wxFileArtProvider &provider)
called by the framework to give Factory a chance to register images used by view
virtual string GetExtensionIdentifier() const
CSelectionViewFactory.
virtual IView * CreateInstanceByFingerprint(const TFingerprint &fingerprint) const
if fingerprint is recognized - creates and returns a new instance
CSelectionView.
void x_OnSelectionEvent(CEvent *)
virtual string GetClientLabel(IWMClient::ELabel ltype=IWMClient::eDefault) const
returns the client label (name) to be displayed in UI
virtual void SaveSettings() const
CSelectionService * m_Service
virtual ~CSelectionView()
CSelectionPanel * m_Panel
virtual void UpdateMenu(wxMenu &aRootMenu)
virtual void SetRegistryPath(const string &reg_path)
IRegSettings interface implementation.
virtual void SetColor(const CRgbaColor &aColor)
returns a color associated with the client
virtual void SetSelectionService(ISelectionService *service)
virtual const CViewTypeDescriptor & GetTypeDescriptor() const
IView interface implementation.
virtual const wxMenu * GetMenu()
returns a menu (must be deleted by the caller) menu injections should follow a separator named "Contr...
virtual string GetSelClientLabel()
returns a string identifying the client in UI
virtual void GetMainObject(TConstScopedObjects &objects) const
Adds the main data objects represented by the client to "objects".
virtual CFingerprint GetFingerprint() const
returns a fingerprint identifying the client
virtual void CreateViewWindow(wxWindow *parent)
create Window corresponding to the view
static CViewTypeDescriptor m_TypeDescr
virtual void SetSelection(CSelectionEvent &evt)
set broadcasted selection
virtual void SetWorkbench(IWorkbench *workbench)
connect / disconnect this view with / from Workbench
virtual const CRgbaColor * GetColor() const
returns a color associated with the client, n/a if NULL
virtual wxWindow * GetWindow()
IWMClient interface implementation.
virtual string GetIconAlias() const
returns an icon alias that can be used to retrieve the client's icon
virtual void LoadSettings()
virtual void DestroyViewWindow()
destroy Window corresponding to the view
virtual void GetSelection(TConstScopedObjects &objects) const
shall return data objects representing selected things, return one data object for every selected thi...
CViewTypeDescriptor - holds description of a view type.
Definition: view.hpp:98
ISelectionService - an interface.
IView - represents a standard visual part of Workbench UI.
Definition: view.hpp:73
CFingerprint identifies an instance of IWMClient and is used for labeling layout positions.
Definition: wm_client.hpp:58
ELabel
Different flavors of label types for different GUI aspects.
Definition: wm_client.hpp:80
IWorkbench is the central interface in the application framework.
Definition: workbench.hpp:113
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
CIRef< T > GetServiceByType()
retrieves a typed reference to a service, the name of C++ type is used as the name of the service.
Definition: service.hpp:91
virtual void RemoveListener(CEventHandler *listener)
Remove a listener.
vector< CConstRef< CObject > > TConstObjects
Definition: objects.hpp:64
virtual const string & GetIconAlias() const
Definition: ui_object.cpp:130
#define ON_EVENT_RANGE(type, id, id_last, handler)
#define END_EVENT_MAP()
Ends definition of Command Map.
#define BEGIN_EVENT_MAP(thisClass, baseClass)
Begins definition of Command Map for CEventHandler-derived class.
virtual void AddListener(CEventHandler *listener, int pool_name=ePool_Default)
Add a listener.
virtual const string & GetLabel() const
Definition: ui_object.cpp:124
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
string GetLabel(const CSeq_id &id)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
char * buf
std::istream & in(std::istream &in_, double &x_)
static CExtensionDeclaration decl("view_manager_service::view_factory", new CSelectionViewFactory())
CSelectionView.
static static static wxID_ANY
Modified on Wed May 22 11:29:32 2024 by modify_doxy.py rev. 669887