NCBI C++ ToolKit
bioseq_editor.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_EDIT___BIOSEQ_EDITOR__HPP
2 #define GUI_WIDGETS_EDIT___BIOSEQ_EDITOR__HPP
3 
4 /* $Id: bioseq_editor.hpp 47154 2022-09-26 17:58:36Z asztalos $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Roman Katargin
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbistd.hpp>
36 
38 #include <gui/utils/extension.hpp>
40 
44 
46 
48  class CSeqdesc;
49  class CSeq_feat;
51 
52 class IEditObject;
53 
140 };
141 
143  public CObject,
144  public IBioseqEditor,
145  public IMenuContributor
146 {
147  DECLARE_EVENT_TABLE()
148 public:
149 
150  CBioseqEditor(ICommandProccessor& cmdProccessor, IGuiWidgetHost* guiWidgetHost) : m_CmdProccessor(cmdProccessor), m_CB(nullptr), m_GuiWidgetHost(guiWidgetHost) {}
151 
152  virtual void SetCallBack(IBioseqEditorCB* cb) { m_CB = cb; }
153  virtual wxMenu* CreateContextMenu(bool shorter = false) const;
154  virtual wxMenu* CreateBioseqMenu() const;
155  virtual void EditSelection();
156 
157  virtual int GetEditFlags(CEditObject& editObj) const;
158  virtual int GetEditFlags(const objects::IFlatItem& item) const;
159 
160  bool IsDeletable(CEditObject& editObj) const;
161  bool IsEditable(CEditObject& editObj) const;
162 
163  bool IsDeletable(const objects::IFlatItem& item) const;
164  bool IsEditable(const objects::IFlatItem& item) const;
165 
166  /// @name IMenuContributor interface implementation
167  /// @{
168  virtual const SwxMenuItemRec* GetMenuDef() const;
169  /// @}
170 
171  void OnEditBiosourceDesc(wxCommandEvent& event);
172  void OnUpdateEditBiosourceDesc(wxUpdateUIEvent& event);
173  void OnCreateBiosourceDesc(wxCommandEvent& event);
174  void OnUpdateCreateBiosourceDesc(wxUpdateUIEvent& event);
175  void OnDeleteBiosourceDesc(wxCommandEvent& event);
176  void OnUpdateDeleteBiosourceDesc(wxUpdateUIEvent& event);
177 
178  void OnEditBiosourceFeat(wxCommandEvent& event);
179  void OnUpdateEditBiosourceFeat(wxUpdateUIEvent& event);
180  void OnCreateBiosourceFeat(wxCommandEvent& event);
181  void OnUpdateCreateBiosourceFeat(wxUpdateUIEvent& event);
182  void OnDeleteBiosourceFeat(wxCommandEvent& event);
183  void OnUpdateDeleteBiosourceFeat(wxUpdateUIEvent& event);
184 
185  void OnPropagateAllFeatures(wxCommandEvent& event);
186  void OnUpdatePropagateAllFeatures(wxUpdateUIEvent& event);
187  void OnPropagateSelectedFeatures(wxCommandEvent& event);
188  void OnUpdatePropagateSelectedFeatures(wxUpdateUIEvent& event);
189 
190  // feature menu items
191  void OnCreateFeature(CRef<objects::CSeq_feat> feat, wxCommandEvent& event);
192  void OnUpdateNucleotideFeat(wxUpdateUIEvent& event);
193  void OnUpdateProteinFeat(wxUpdateUIEvent& event);
194  void OnUpdateAnyFeat(wxUpdateUIEvent& event);
195  void OnCreateCodingRegion(wxCommandEvent& event);
196  void OnCreateGene(wxCommandEvent& event);
197  void OnCreateProt(wxCommandEvent& event);
198  void OnCreateImport(wxCommandEvent& evt);
199  void OnCreateRegion(wxCommandEvent& evt);
200  void OnCreateSecondaryStructure(wxCommandEvent& evt);
201  void OnCreateRNA(wxCommandEvent& evt);
202  void OnCreateSite(wxCommandEvent& event);
203  void OnCreateBond(wxCommandEvent& event);
204  void OnCreatePubFeat(wxCommandEvent& event);
205  void OnCreateDescriptor(wxCommandEvent& evt);
206 
207  void OnEditSelection(wxCommandEvent& event);
208  void OnUpdateEditSelection(wxUpdateUIEvent& event);
209 
210  void OnDeleteSelection(wxCommandEvent& event);
211  void OnUpdateDeleteSelection(wxUpdateUIEvent& event);
212 
213  virtual bool ProcessEvent(wxEvent& event);
214 
215  static objects::CSeqFeatData::ESubtype GetFeatTypeFromCmdID (int cmd_id);
216  static CRef<objects::CSeq_feat> MakeDefaultFeature(objects::CSeqFeatData::ESubtype subtype);
217 
218 private:
219  void x_DeleteObject(objects::CSeq_entry_Handle& seh, const objects::CSeqdesc& seqDesq);
220  void x_DeleteObject(objects::CSeq_entry_Handle& seh, const objects::CSeq_feat& seqFeat);
221  bool x_DeleteFromSingleSeq(objects::CSeq_entry_Handle& seh, objects::CSeq_entry_Handle& sehdesc, const objects::CSeqdesc& seqDesq, bool &any, bool& cancel);
222  CIRef<IEditCommand> x_GetDeleteCommand(objects::CSeq_entry_Handle& seh, const objects::CSeqdesc& seqDesc, bool from_single);
223  CRef<CCmdComposite> x_GetDeleteCommand(objects::CSeq_entry_Handle& seh, const objects::CSeq_feat& seqFeat);
224  CRef<CCmdComposite> x_GetDeleteCommand(objects::CSeq_entry_Handle& seh, const objects::CSeq_annot& annot);
225  CIRef<IEditCommand> x_GetDeleteCommand(objects::CSeq_entry_Handle& seh, const objects::CSeq_align& align);
226  void x_EditObject(CIRef<IEditObject> edit, const string& title = kEmptyStr);
227 
228  void x_ReportError(const string& cmd, const std::exception& e);
229 
230  bool x_HandleFeatCreationHere(wxCommandEvent& event);
231  bool x_HaveBiosourceDesc();
232  bool x_HaveBiosourceFeat();
233  int x_GetFromPosition(void);
234  bool x_HasAlignment(void);
235  bool x_IsNa();
236 
240 };
241 
243 
245  public CObject,
246  public IExtension,
247  public IEditorFactory
248 {
249 public:
250  /// @name IExtension interface implementation
251  /// @{
252  virtual string GetExtensionIdentifier() const;
253  virtual string GetExtensionLabel() const;
254  /// @}
255 
256  /// @name IEditorFactory interface implementation
257  /// @{
258  virtual void RegisterIconAliases(wxFileArtProvider& provider) {}
259  virtual void RegisterCommands(CUICommandRegistry&, wxFileArtProvider&);
260 
261  virtual CObject* CreateEditor(const string& interface_name, ICommandProccessor& cmdProccessor, IGuiWidgetHost* guiWidgetHost);
262  /// @}
263  static void CollectBioseqEditorCommands(vector<CUICommand*> &commands);
264 
265 };
266 
268 
269 #endif // GUI_WIDGETS_EDIT___BIOSEQ_EDITOR__HPP
EBioseqEditCommands
@ eCmdCreateSigPeptide
@ eCmdCreateRegion
@ eCmdCreateMiscRecomb
@ eCmdCreateRepeatRegion
@ eCmdCreateDBLink
@ eCmdCreateRegulatory_ribosome_binding_site
@ eCmdCreatetRNA
@ eCmdCreateAssemblyGap
@ eCmdCreateBond
@ eCmdCreatepreRNA
@ eCmdCreateRegulatory
@ eCmdCreateCRegion
@ eCmdEditBiosourceDesc
@ eCmdCreateProt
@ eCmdCreateVSegment
@ eCmdCreateMiscFeature
@ eCmdEditBiosourceFeat
@ eCmdCreateModifiedBase
@ eCmdCreateMobileElement
@ eCmdCreateNRegion
@ eCmdCreateTelomere
@ eCmdCreateMiscStructure
@ eCmdCreaterRNA
@ eCmdCreatetmRNA
@ eCmdCreatePrimerBind
@ eCmdCreateBiosourceFeat
@ eCmdCreateExon
@ eCmdCreateRefGeneTracking
@ eCmdCreateMatPeptide
@ eCmdCreateCentromere
@ eCmdCreateiDNA
@ eCmdDeleteBiosourceDesc
@ eCmdCreatePrimTranscript
@ eCmdCreateJSegment
@ eCmdCreateTitle
@ eCmdCreateMiscBinding
@ eCmdCreatemiscRNA
@ eCmdCreatePubDescriptorLabeled
@ eCmdCreateRegulatory_promoter
@ eCmdCreateOriT
@ eCmdCreateDSegment
@ eCmdCreateVRegion
@ eCmdCreateRegulatory_riboswitch
@ eCmdCreateSTS
@ eCmdCreateCodingRegion_ext
@ eCmdCreatePolyASite
@ eCmdCreateSRegion
@ eCmdCreateCommentDescriptor
@ eCmdCreateUnreviewed
@ eCmdCreateUnverified
@ eCmdCreateBiosourceDesc
@ eCmdCreate5UTR
@ eCmdCreatePubFeatureLabeled
@ eCmdCreateMRNA
@ eCmdCreateGene
@ eCmdCreateCodingRegion
@ eCmdCreateSite
@ eCmdCreateUnsure
@ eCmdCreateRegulatory_enhancer
@ eCmdCreateVariation
@ eCmdCreatePreRNA
@ eCmdCreatePubDescriptor
@ eCmdCreateTransitPeptide
@ eCmdPropagateAllFeatures
@ eCmdCreateRegionDescriptor
@ eCmdCreateIntron
@ eCmdCreateDLoop
@ eCmdCreateSecondaryStructure
@ eCmdCreateProprotein
@ eCmdCreatencRNA
@ eCmdCreateProteinBind
@ eCmdCreateAuthorizedAccess
@ eCmdPropagateSelectedFeatures
@ eCmdCreateStructuredComment
@ eCmdCreateTPAAssembly
@ eCmdCreate3UTR
@ eCmdCreateRepOrigin
@ eCmdCreateLTR
@ eCmdCreateStemLoop
@ eCmdCreateRNA
@ eCmdCreateOperon
@ eCmdCreateRegulatory_terminator
@ eCmdCreateMiscDifference
@ eCmdDeleteBiosourceFeat
@ eCmdCreateMolInfo
CIRef< IEditObject > CreateEditorForObject(CConstRef< CObject > obj, objects::CSeq_entry_Handle seh, bool create)
virtual void RegisterIconAliases(wxFileArtProvider &provider)
CIRef< IEditCommand > x_GetDeleteCommand(objects::CSeq_entry_Handle &seh, const objects::CSeq_align &align)
IGuiWidgetHost * m_GuiWidgetHost
IBioseqEditorCB * m_CB
virtual void SetCallBack(IBioseqEditorCB *cb)
ICommandProccessor & m_CmdProccessor
CBioseqEditor(ICommandProccessor &cmdProccessor, IGuiWidgetHost *guiWidgetHost)
CRef< CCmdComposite > x_GetDeleteCommand(objects::CSeq_entry_Handle &seh, const objects::CSeq_annot &annot)
bool IsDeletable(const objects::IFlatItem &item) const
CObject –.
Definition: ncbiobj.hpp:180
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
CUICommandRegistry is a centralized registry where all application commands should be registered.
Definition: ui_command.hpp:146
IBioseqEditor.
virtual wxMenu * CreateContextMenu(bool shorter=false) const =0
virtual wxMenu * CreateBioseqMenu() const =0
virtual void EditSelection()=0
virtual int GetEditFlags(CEditObject &editObj) const =0
Undo/Redo interface for editing operations.
GUI editing interface.
Definition: edit_object.hpp:63
IEditFactory.
IExtension IExtension interface represents an abstract pluggable component.
Definition: extension.hpp:57
IMenuContributor - contributes menu to Menu Service.
Definition: ui_command.hpp:371
virtual const SwxMenuItemRec * GetMenuDef() const
simpler way to provide a static menu using macros defined earlier in this file
Definition: ui_command.hpp:384
bool IsEditable(int err_code, const CSerialObject &obj, objects::CSeq_entry_Handle seh)
Include a standard set of the NCBI C++ Toolkit most basic headers.
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define kEmptyStr
Definition: ncbistr.hpp:123
#define NCBI_GUIWIDGETS_EDIT_EXPORT
Definition: gui_export.h:526
@ eBioseqEditBaseCommandsEnd
Definition: fix_pub.hpp:45
#define nullptr
Definition: ncbimisc.hpp:45
Modified on Fri Sep 20 14:58:08 2024 by modify_doxy.py rev. 669887