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

Go to the SVN repository for this file.

1 /* $Id: crossref_feats_dlg.cpp 47479 2023-05-02 13:24:02Z ucko $
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: Andrea Asztalos
27  */
28 
29 
30 // Generated by DialogBlocks (unregistered), 04/02/2015 12:11:44
31 
32 #include <ncbi_pch.hpp>
35 
41 
42 #include <wx/sizer.h>
43 #include <wx/stattext.h>
44 #include <wx/checklst.h>
45 #include <wx/radiobox.h>
46 #include <wx/button.h>
47 
48 
51 
52 /*!
53  * CCrossRefFeatsDlg type definition
54  */
55 
56 IMPLEMENT_DYNAMIC_CLASS( CCrossRefFeatsDlg, wxDialog )
57 
58 
59 /*!
60  * CCrossRefFeatsDlg event table definition
61  */
62 
63 BEGIN_EVENT_TABLE( CCrossRefFeatsDlg, wxDialog )
64 
65 ////@begin CCrossRefFeatsDlg event table entries
66 ////@end CCrossRefFeatsDlg event table entries
67 
69 
70 
71 /*!
72  * CCrossRefFeatsDlg constructors
73  */
74 
76  : m_Featid(0)
77 {
78  Init();
79 }
80 
81 CCrossRefFeatsDlg::CCrossRefFeatsDlg( wxWindow* parent,
82  TFeatVec& feats, const CFeat_id::TLocal& feat_id,
83  wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
84  : m_Features(feats), m_Featid(&feat_id)
85 {
86  Init();
87  Create(parent, id, caption, pos, size, style);
88 }
89 
90 
91 /*!
92  * CCrossRefFeatsDlg creator
93  */
94 
95 bool CCrossRefFeatsDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
96 {
97 ////@begin CCrossRefFeatsDlg creation
98  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
99  wxDialog::Create( parent, id, caption, pos, size, style );
100 
101  CreateControls();
102  if (GetSizer())
103  {
104  GetSizer()->SetSizeHints(this);
105  }
106  Centre();
107 ////@end CCrossRefFeatsDlg creation
108  return true;
109 }
110 
111 
112 /*!
113  * CCrossRefFeatsDlg destructor
114  */
115 
117 {
118 ////@begin CCrossRefFeatsDlg destruction
119 ////@end CCrossRefFeatsDlg destruction
120 }
121 
122 
123 /*!
124  * Member initialisation
125  */
126 
128 {
129 ////@begin CCrossRefFeatsDlg member initialisation
130  m_FeatList = NULL;
131  m_Modify = NULL;
132 ////@end CCrossRefFeatsDlg member initialisation
133 }
134 
135 
136 /*!
137  * Control creation for CCrossRefFeatsDlg
138  */
139 
141 {
142 ////@begin CCrossRefFeatsDlg content construction
143  // Generated by DialogBlocks, 04/02/2015 14:19:57 (unregistered)
144 
145  CCrossRefFeatsDlg* itemDialog1 = this;
146 
147  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
148  itemDialog1->SetSizer(itemBoxSizer2);
149 
150  wxStaticText* itemStaticText3 = new wxStaticText( itemDialog1, wxID_STATIC, _("The deleted feature is cross referenced in:"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT );
151  itemBoxSizer2->Add(itemStaticText3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
152 
153  wxArrayString m_FeatListStrings;
154  m_FeatList = new wxCheckListBox( itemDialog1, ID_CHECKLISTBOX, wxDefaultPosition, wxDefaultSize, m_FeatListStrings, wxLB_SINGLE );
155  itemBoxSizer2->Add(m_FeatList, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
156 
157  wxArrayString m_ModifyStrings;
158  m_ModifyStrings.Add(_("&Delete"));
159  m_ModifyStrings.Add(_("&Delete feature ID XRef to deleted feature"));
160  m_Modify = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Modify selected features"), wxDefaultPosition, wxDefaultSize, m_ModifyStrings, 1, wxRA_SPECIFY_COLS );
161  m_Modify->SetSelection(0);
162  itemBoxSizer2->Add(m_Modify, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
163 
164  wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
165  itemBoxSizer2->Add(itemBoxSizer6, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
166 
167  wxButton* itemButton7 = new wxButton( itemDialog1, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
168  itemBoxSizer6->Add(itemButton7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
169 
170  wxButton* itemButton8 = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
171  itemBoxSizer6->Add(itemButton8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
172 
173 ////@end CCrossRefFeatsDlg content construction
174 }
175 
176 
178 {
179  ITERATE (TFeatVec, it, m_Features) {
180  const CSeq_feat& feat = *(*it).GetOriginalSeq_feat();
181  string subtype = CSeqFeatData::SubtypeValueToName(feat.GetData().GetSubtype());
182  int start = feat.GetLocation().GetStart(eExtreme_Positional);
183  int stop = feat.GetLocation().GetStop(eExtreme_Positional);
184  string feat_descr(subtype);
185  feat_descr.append(": " + NStr::NumericToString(start) + "..");
186  feat_descr.append(NStr::NumericToString(stop));
187  int index = m_FeatList->Append(ToWxString(feat_descr));
188  m_FeatList->Check(index);
189  }
190  return wxDialog::TransferDataToWindow();
191 }
192 
194 {
195  if (m_Features.empty())
196  return CRef<CCmdComposite>();
197 
198  CRef<CCmdComposite> cmd(new CCmdComposite("Delete/change features that are referencing the deleted feature"));
199 
200  if (m_Modify->GetSelection() == 0) {
201  // delete selected features
202  for (size_t i = 0; i < m_Features.size(); i++) {
203  if (m_FeatList->IsChecked(static_cast<unsigned int>(i))) {
205  cmd->AddCommand(*delFeat);
206  }
207  }
208 
209  } else if (m_Featid) {
210  // delete references in the selected features
211  for (size_t i = 0; i < m_Features.size(); i++) {
212  if (m_FeatList->IsChecked(static_cast<unsigned int>(i))) {
213  const CSeq_feat& orig = *m_Features[i].GetOriginalSeq_feat();
214  CRef<CSeq_feat> new_feat(new CSeq_feat);
215  new_feat->Assign(orig);
216 
217  bool modified(false);
218  EDIT_EACH_SEQFEATXREF_ON_SEQFEAT (it, *new_feat) {
219  if ((*it)->IsSetId() && (*it)->GetId().IsLocal()) {
220  if (m_Featid->Match((*it)->GetId().GetLocal())) {
221  ERASE_SEQFEATXREF_ON_SEQFEAT (it, *new_feat);
222  modified = true;
223  }
224  }
225  }
226  if (new_feat->IsSetXref() && new_feat->GetXref().empty()) {
227  new_feat->ResetXref();
228  modified = true;
229  }
230 
231  if (modified) {
232  CRef<CCmdChangeSeq_feat> chg_feat(new CCmdChangeSeq_feat(m_Features[i], *new_feat));
233  cmd->AddCommand(*chg_feat);
234  }
235  }
236  }
237  }
238  return cmd;
239 }
240 /*!
241  * Should we show tooltips?
242  */
243 
245 {
246  return true;
247 }
248 
249 /*!
250  * Get bitmap resources
251  */
252 
253 wxBitmap CCrossRefFeatsDlg::GetBitmapResource( const wxString& name )
254 {
255  // Bitmap retrieval
256 ////@begin CCrossRefFeatsDlg bitmap retrieval
257  wxUnusedVar(name);
258  return wxNullBitmap;
259 ////@end CCrossRefFeatsDlg bitmap retrieval
260 }
261 
262 /*!
263  * Get icon resources
264  */
265 
266 wxIcon CCrossRefFeatsDlg::GetIconResource( const wxString& name )
267 {
268  // Icon retrieval
269 ////@begin CCrossRefFeatsDlg icon retrieval
270  wxUnusedVar(name);
271  return wxNullIcon;
272 ////@end CCrossRefFeatsDlg icon retrieval
273 }
274 
User-defined methods of the data storage class.
@ eExtreme_Positional
numerical value
Definition: Na_strand.hpp:63
wxCheckListBox * m_FeatList
void CreateControls()
Creates the controls and sizers.
const objects::CFeat_id::TLocal * m_Featid
static bool ShowToolTips()
Should we show tooltips?
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
CRef< CCmdComposite > GetCommand()
~CCrossRefFeatsDlg()
Destructor.
void Init()
Initialises member variables.
CCrossRefFeatsDlg()
Constructors.
bool Create(wxWindow *parent, wxWindowID id=ID_CCROSSREFFEATSDLG, const wxString &caption=_("Cross referenced features"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
vector< objects::CSeq_feat_Handle > TFeatVec
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
ESubtype GetSubtype(void) const
static CTempString SubtypeValueToName(ESubtype eSubtype)
Turns a ESubtype into its string value which is NOT necessarily related to the identifier of the enum...
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
USING_SCOPE(objects)
#define _(proto)
Definition: ct_nlmzip_i.h:78
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static void Init(void)
Definition: cursor6.c:76
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
TSeqPos GetStart(ESeqLocExtremes ext) const
Return start and stop positions of the seq-loc.
Definition: Seq_loc.cpp:915
TSeqPos GetStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:963
#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 enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
bool IsSetXref(void) const
cite other relevant features Check if a value has been assigned to Xref data member.
Definition: Seq_feat_.hpp:1296
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
const TXref & GetXref(void) const
Get the Xref member data.
Definition: Seq_feat_.hpp:1308
void ResetXref(void)
Reset Xref data member.
Definition: Seq_feat_.cpp:182
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is orig
END_EVENT_TABLE()
int i
const struct ncbi::grid::netcache::search::fields::SIZE size
#define ERASE_SEQFEATXREF_ON_SEQFEAT(Itr, Var)
ERASE_SEQFEATXREF_ON_SEQFEAT.
#define EDIT_EACH_SEQFEATXREF_ON_SEQFEAT(Itr, Var)
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
Modified on Tue May 21 10:53:13 2024 by modify_doxy.py rev. 669887