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

Go to the SVN repository for this file.

1 /* $Id: wig_load_manager.cpp 38522 2017-05-22 18:19:49Z evgeniev $
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
27 *
28 */
29 
30 #include <ncbi_pch.hpp>
31 
32 #include "wig_load_manager.hpp"
33 
36 
38 
39 #include <wx/filename.h>
40 
42 
44 {
45  return m_Manager.x_GetParamsPanel();
46 }
47 
48 ///////////////////////////////////////////////////////////////////////////////
49 /// CWigLoadManager
51  : m_Descr("WIG files", "")
54  , m_State(eInvalid)
56  , m_OptionsPage(*this)
57 {
58  m_Descr.SetLogEvent("loaders");
59 }
60 
61 //
62 // IFileLoadPanelClient implementation
63 //
64 
66 {
67  return m_Descr.GetLabel();
68 }
69 
71 {
74 }
75 
76 //
77 // IUILoadManager implementation
78 //
79 
81 {
82  m_SrvLocator = srv_locator;
83 }
84 
85 
86 void CWigLoadManager::SetParentWindow(wxWindow* parent)
87 {
88  m_ParentWindow = parent;
89 }
90 
91 
93 {
94  return m_Descr;
95 }
96 
97 
99 {
100  m_State = eParams;
101 }
102 
103 
105 {
106  m_State = eInvalid;
107  m_ParamsPanel = NULL; // window is destroyed by the system
108 }
109 
110 
112 {
113  return (m_State == eParams) ? x_GetParamsPanel() : NULL;
114 }
115 
117 {
118  if (m_ParamsPanel == NULL) {
122  }
123  return m_ParamsPanel;
124 }
125 
126 
128 {
129  switch(m_State) {
130  case eParams:
131  return action == eNext;
132  case eCompleted:
133  return action == eBack;
134  default:
135  _ASSERT(false);
136  return false;
137  }
138 }
139 
140 
142 {
143  return m_State == eParams;
144 }
145 
146 
148 {
149  return m_State == eCompleted; // does not matter
150 }
151 
152 
154 {
155  if(m_State == eParams && action == eNext) {
157  //TODO validate
160  return true;
161  }
162  return false;
163  } else if(m_State == eCompleted && action == eBack) {
164  m_State = eParams;
165  return true;
166  }
167  _ASSERT(false);
168  return false;
169 }
170 
171 
173 {
174  return nullptr;
175 }
176 
178 {
180 }
181 
183 {
186 }
187 
188 bool CWigLoadManager::ValidateFilenames(const vector<wxString>& /*filenames*/)
189 {
190  // not implemented
191  return true;
192 }
193 
194 
195 void CWigLoadManager::SetFilenames(const vector<wxString>& filenames)
196 {
198 }
199 
200 void CWigLoadManager::GetFilenames(vector<wxString>& filenames) const
201 {
203 }
204 
206 {
207  return m_State == eParams;
208 }
209 
210 
211 bool CWigLoadManager::RecognizeFormat(const wxString& filename)
212 {
213  wxString ext;
214  wxFileName::SplitPath(filename, 0, 0, &ext);
215  return ext == wxT("wig");
216 }
217 
219 {
220  return fmt == CFormatGuess::eWiggle;
221 }
222 
224 {
225  static string sid("wig_format_load_manager");
226  return sid;
227 }
228 
229 
231 {
232  static string slabel("WIG Format Load Manager");
233  return slabel;
234 }
235 
236 void CWigLoadManager::SetRegistryPath(const string& path)
237 {
238  m_RegPath = path; // store for later use
239  m_Params.SetRegistryPath(m_RegPath + ".WigParams");
240 }
241 
243 {
245 }
246 
247 
249 {
251 }
252 
static wxString GetDialogFilter(EFileType fileType)
EFormat
The formats are checked in the same order as declared here.
@ eWiggle
UCSC WIGGLE file format.
virtual void SaveSettings() const
IRegSettings.
virtual void SetRegistryPath(const string &path)
IRegSettings.
virtual void LoadSettings()
CWigObjectLoader.
void SetData(const CWigLoadParams &data)
virtual bool TransferDataFromWindow()
Transfer data from the window.
virtual bool TransferDataToWindow()
Transfer data to the window.
CWigLoadParams & GetData()
Data access.
IAppTask.
Definition: app_task.hpp:83
IServiceLocator - an abstract mechanism for locating services.
Definition: service.hpp:71
IUIObject - object that provides basic properties often required in a UI object.
Definition: ui_object.hpp:63
#define NULL
Definition: ncbistd.hpp:225
virtual void SetRegistryPath(const string &path)
virtual bool IsCompletedState()
Manager goes into "Complete" state when "Finish" button is pressed and all input data is gatherred an...
CWigParamsPanel * x_GetParamsPanel()
virtual void SetFilenames(const vector< wxString > &filenames)
initilize the manager with the given filenames
virtual wxPanel * GetCurrentPanel()
Return the panel corresponding to the current state of Tool Manager.
virtual bool DoTransition(EAction action)
Performs transition if possible and returns true, otherwise the function shall warn the user about th...
virtual void SetParentWindow(wxWindow *parent)
virtual void InitUI()
Initializes the Manager before using it in UI.
CWigLoadManager & m_Manager
virtual void SaveSettings() const
virtual bool IsInitialState()
return true if the current state of the loader UI is the first valid state (first step in a wizard-li...
virtual void SetServiceLocator(IServiceLocator *srv_locator)
Sets / unsets Service Locator.
CWigLoadParams m_Params
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
virtual IExecuteUnit * GetExecuteUnit()
virtual bool IsFinalState()
True if Tool Manager has reached its final state, i.e.
virtual bool RecognizeFormat(const wxString &filename)
return true if the given file format is supported by this manager
virtual bool CanDo(EAction action)
Indicates whether given transition is possible in the current state.
CWigParamsPanel * m_ParamsPanel
vector< wxString > m_FileNames
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
virtual string GetLabel() const
virtual void GetFilenames(vector< wxString > &filenames) const
get actual filenames that will be opened
IServiceLocator * m_SrvLocator
wxWindow * m_ParentWindow
virtual IAppTask * GetTask()
Once parameters are gathered and validated this function is called to produce the final Task object t...
virtual wxString GetFormatWildcard() const
return file wildcard for the format (example - "*.txt;*.tab" )
virtual bool ValidateFilenames(const vector< wxString > &)
checks given filenames and returns true if the manager can handle them, otherwise - shows an error me...
virtual wxPanel * GetPanel()
virtual const IUIObject & GetDescriptor() const
Returns the object describing this tool (UI meta data).
CWigLoadManager()
CWigLoadManager.
virtual void CleanUI()
CleanUI() is called after the host finished using the manager.
virtual void LoadSettings()
virtual void SetLogEvent(const string &log_event)
Definition: ui_object.cpp:118
virtual const string & GetLabel() const
Definition: ui_object.cpp:124
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define wxT(x)
Definition: muParser.cpp:41
static int filenames
Definition: pcregrep.c:172
#define _ASSERT
Modified on Sat Mar 02 10:55:15 2024 by modify_doxy.py rev. 669887