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

Go to the SVN repository for this file.

1 /* $Id: phy_exporter.cpp 39345 2017-09-13 19:39:22Z 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: Roman Katargin, Vladimir Tereshkov
27 *
28 */
29 
30 #include <ncbi_pch.hpp>
31 
33 
34 #include <serial/typeinfo.hpp>
35 
37 
38 #include "phy_exporter.hpp"
39 #include "phy_export_page.hpp"
40 
42 
44 
47 
48 class CPhyExporter :
49  public CObject,
50  public IUIExportTool,
51  public IRegSettings
52 {
53 public:
54  CPhyExporter();
55  /// @name IUIToolManager interface implementation
56  /// @{
57  virtual const IUIObject& GetDescriptor() const;
58  virtual void SetServiceLocator(IServiceLocator* srv_locator);
59  virtual void SetParentWindow(wxWindow* parent);
60  virtual void InitUI();
61  virtual void CleanUI();
62  virtual wxPanel* GetCurrentPanel();
63  virtual bool IsFinalState();
64  virtual bool IsCompletedState();
65  virtual bool CanDo(EAction action);
66  virtual bool DoTransition(EAction action);
67  virtual IAppTask* GetTask();
68  /// @}
69 
70  /// @name IUIExportTool interface implementation
71  /// @{
72  virtual void SetLocations(const TRelatedObjectsMap& /*input_map*/) {}
73  virtual void SetObjects(const TConstScopedObjects& input);
74  /// @}
75 
76  /// @name IRegSettings interface implementation
77  /// @{
78  virtual void SetRegistryPath(const string& path);
79  virtual void SaveSettings() const;
80  virtual void LoadSettings();
81  /// @}
82 
83 protected:
84  /// defines states of the Tool Manager
85  enum EState {
86  eInvalid = -1, // initial
87  eParams, // displaying parameters panel
88  eCompleted // done
89  };
90 
92  wxWindow *m_ParentWindow;
94  string m_RegPath;
95 
99 
100  /// tool manager state (int the Run Tool wizard)
102 };
103 
105  : m_Descriptor("Phylogenetic Tree File", ""),
106  m_ParentWindow(),
107  m_Panel(),
108  m_State(eInvalid)
109 {
110  m_Descriptor.SetLogEvent("exporters");
111 }
112 
114 {
115  return m_Descriptor;
116 }
117 
119 {
120 }
121 
122 void CPhyExporter::SetParentWindow(wxWindow* parent)
123 {
124  m_ParentWindow = parent;
125 }
126 
128 {
129  m_State = eParams;
130  //m_State = eCompleted;
131 }
132 
134 {
135  m_State = eInvalid;
136  m_Panel = NULL;
137 }
138 
140 {
141 
142  if (m_Panel == NULL) {
147 
148  if (!m_RegPath.empty()) {
149  m_Panel->SetRegistryPath(m_RegPath + ".ParamsPanel");
151  }
152  }
153 
154  return m_Panel;
155 }
156 
158 {
159  return m_State == eParams;
160 }
161 
163 {
164  return m_State == eCompleted;
165 }
166 
168 {
169  switch (m_State)
170  {
171  case eInvalid:
172  return action == eNext;
173  case eParams:
174  return action == eNext;
175  case eCompleted:
176  return false; // nothing left to do
177  default:
178  _ASSERT(false);
179  return false;
180  }
181 }
182 
184 {
185 
186  if(m_State == eInvalid && action == eNext) {
187  m_State = eParams;
188  return true;
189  }
190  else if (m_State == eParams && action == eNext) {
192  m_Params = m_Panel->GetData();
194  return true;
195  }
196  return false;
197  }
198 
199  return false;
200 }
201 
203 {
205  return new CAppExportTask(*job, m_Params.GetFileName());
206 }
207 
208 void CPhyExporter::SetRegistryPath(const string& path)
209 {
210  m_RegPath = path; // store for later use
211  m_Params.SetRegistryPath(m_RegPath + ".AgpParams");
212 }
213 
215 {
216  m_Objects.clear();
217  m_Objects = input;
218 
219  if (input.size()==1) {
221  dynamic_cast<const CBioTreeContainer*>(input[0].object.GetPointer())));
222  }
223 }
224 
226 {
228 // if (m_Panel) m_Panel->SaveSettings();
229 }
230 
232 {
234 }
235 
237 {
238  static string sid("phy_exporter_factory");
239  return sid;
240 }
241 
242 
244 {
245  static string slabel("Phylogenetic Tree Exporter Factory");
246  return slabel;
247 }
248 
250 {
251  return new CPhyExporter();
252 }
253 
255 {
257  if (dynamic_cast<const CSerialObject*>(it->object.GetPointer()) != NULL)
258  return true;
259  }
260  return false;
261 }
262 
CObject –.
Definition: ncbiobj.hpp:180
CPhyExportJob.
virtual bool TransferDataFromWindow()
Transfer data from the window.
virtual bool TransferDataToWindow()
Transfer data to the window.
virtual void SetRegistryPath(const string &path)
IRegSettings.
virtual void LoadSettings()
void SetObjects(TConstScopedObjects *objects)
void SetData(const CPhyExportParams &data)
CPhyExportParams & GetData()
Data access.
virtual void LoadSettings()
virtual void SaveSettings() const
IRegSettings.
void SetBioTree(CBioTreeContainer *value)
const wxString & GetFileName() const
virtual void SetRegistryPath(const string &path)
IRegSettings.
virtual bool TestInputObjects(TConstScopedObjects &objects) const
Check if exporter can handle the objects.
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
virtual IUIExportTool * CreateInstance() const
create and instance of the IUIExporter
TObjects m_Objects
virtual bool IsFinalState()
True if Tool Manager has reached its final state, i.e.
CPhyExportParams m_Params
CPhyExportPage * m_Panel
virtual void SetLocations(const TRelatedObjectsMap &)
sets objects to be exported.
virtual void InitUI()
Initializes the Manager before using it in UI.
CUIObject m_Descriptor
virtual bool CanDo(EAction action)
Indicates whether given transition is possible in the current state.
virtual void SaveSettings() const
virtual bool DoTransition(EAction action)
Performs transition if possible and returns true, otherwise the function shall warn the user about th...
virtual void LoadSettings()
virtual bool IsCompletedState()
Manager goes into "Complete" state when "Finish" button is pressed and all input data is gatherred an...
virtual const IUIObject & GetDescriptor() const
Returns the object describing this tool (UI meta data).
virtual void SetParentWindow(wxWindow *parent)
virtual void CleanUI()
CleanUI() is called after the host finished using the manager.
virtual void SetServiceLocator(IServiceLocator *srv_locator)
Sets / unsets Service Locator.
virtual void SetObjects(const TConstScopedObjects &input)
string m_RegPath
virtual wxPanel * GetCurrentPanel()
Return the panel corresponding to the current state of Tool Manager.
virtual IAppTask * GetTask()
Once parameters are gathered and validated this function is called to produce the final Task object t...
TConstScopedObjects TObjects
wxWindow * m_ParentWindow
virtual void SetRegistryPath(const string &path)
EState m_State
tool manager state (int the Run Tool wizard)
Base class for all serializable objects.
Definition: serialbase.hpp:150
CUIObject - default mix-in implementation of IUIObject.
Definition: ui_object.hpp:81
IAppTask.
Definition: app_task.hpp:83
IRegSettings An interface for objects that save / restore settings using CGuiRegistry.
IServiceLocator - an abstract mechanism for locating services.
Definition: service.hpp:71
IUIExporter is a IUIToolManager that represents an export tool.
IUIObject - object that provides basic properties often required in a UI object.
Definition: ui_object.hpp:63
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
virtual void SetLogEvent(const string &log_event)
Definition: ui_object.cpp:118
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static int input()
USING_SCOPE(ncbi::objects)
#define _ASSERT
Modified on Fri Sep 20 14:56:57 2024 by modify_doxy.py rev. 669887