NCBI C++ Toolkit Cross Reference

  C++/src/gui/packages/pkg_sequence_edit/bulk_location_panel.cpp


/* $Id: bulk_location_panel.cpp 32945 2015-05-08 14:20:25Z filippov $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors: Colleen Bollin */ #include <ncbi_pch.hpp> #include <objects/seqloc/Seq_interval.hpp> ////@begin includes ////@end includes #include <gui/packages/pkg_sequence_edit/bulk_location_panel.hpp> #include <gui/widgets/wx/wx_utils.hpp> #include <wx/sizer.h> #include <wx/stattext.h> ////@begin XPM images ////@end XPM images BEGIN_NCBI_SCOPE USING_SCOPE(ncbi::objects); /*! * CBulkLocationPanel type definition */ IMPLEMENT_DYNAMIC_CLASS( CBulkLocationPanel, wxPanel ) /*! * CBulkLocationPanel event table definition */ BEGIN_EVENT_TABLE( CBulkLocationPanel, wxPanel ) ////@begin CBulkLocationPanel event table entries EVT_RADIOBUTTON( ID_RADIOBUTTON2, CBulkLocationPanel::OnRadiobutton2Selected ) EVT_RADIOBUTTON( ID_RADIOBUTTON3, CBulkLocationPanel::OnRadiobutton3Selected ) ////@end CBulkLocationPanel event table entries END_EVENT_TABLE() /*! * CBulkLocationPanel constructors */ CBulkLocationPanel::CBulkLocationPanel() { Init(); } CBulkLocationPanel::CBulkLocationPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) { Init(); Create(parent, id, pos, size, style); } /*! * CBulkLocationPanel creator */ bool CBulkLocationPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) { ////@begin CBulkLocationPanel creation wxPanel::Create( parent, id, pos, size, style ); CreateControls(); if (GetSizer()) { GetSizer()->SetSizeHints(this); } Centre(); ////@end CBulkLocationPanel creation return true; } /*! * CBulkLocationPanel destructor */ CBulkLocationPanel::~CBulkLocationPanel() { ////@begin CBulkLocationPanel destruction ////@end CBulkLocationPanel destruction } /*! * Member initialisation */ void CBulkLocationPanel::Init() { ////@begin CBulkLocationPanel member initialisation m_Partial5 = NULL; m_Partial3 = NULL; m_Strand = NULL; m_WholeSeq = NULL; m_Coordinates = NULL; m_From = NULL; m_To = NULL; m_AddToExisting = NULL; ////@end CBulkLocationPanel member initialisation } /*! * Control creation for CBulkLocationPanel */ void CBulkLocationPanel::CreateControls() { ////@begin CBulkLocationPanel content construction // Generated by DialogBlocks, 10/06/2013 17:55:14 (unregistered) CBulkLocationPanel* itemPanel1 = this; wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); itemPanel1->SetSizer(itemBoxSizer2); wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); m_Partial5 = new wxCheckBox( itemPanel1, ID_CHECKBOX3, _("Incomplete at 5' end"), wxDefaultPosition, wxDefaultSize, 0 ); m_Partial5->SetValue(false); itemBoxSizer3->Add(m_Partial5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_Partial3 = new wxCheckBox( itemPanel1, ID_CHECKBOX4, _("Incomplete at 3' end"), wxDefaultPosition, wxDefaultSize, 0 ); m_Partial3->SetValue(false); itemBoxSizer3->Add(m_Partial3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxArrayString m_StrandStrings; m_StrandStrings.Add(_("&Plus")); m_StrandStrings.Add(_("&Minus")); m_Strand = new wxRadioBox( itemPanel1, ID_RADIOBOX2, _("Strand"), wxDefaultPosition, wxDefaultSize, m_StrandStrings, 1, wxRA_SPECIFY_ROWS ); m_Strand->SetSelection(0); itemBoxSizer2->Add(m_Strand, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL); itemBoxSizer7->Add(itemBoxSizer8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_WholeSeq = new wxRadioButton( itemPanel1, ID_RADIOBUTTON2, _("Use Whole Sequence Interval"), wxDefaultPosition, wxSize(-1, 15), 0 ); m_WholeSeq->SetValue(true); itemBoxSizer8->Add(m_WholeSeq, 0, wxALIGN_LEFT|wxALL, 5); m_Coordinates = new wxRadioButton( itemPanel1, ID_RADIOBUTTON3, _("Use these coordinates:"), wxDefaultPosition, wxSize(-1, 15), 0 ); m_Coordinates->SetValue(false); itemBoxSizer8->Add(m_Coordinates, 0, wxALIGN_LEFT|wxALL, 5); wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL); itemBoxSizer7->Add(itemBoxSizer11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0); itemBoxSizer11->Add(5, 15, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer11->Add(itemBoxSizer13, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0); wxStaticText* itemStaticText14 = new wxStaticText( itemPanel1, wxID_STATIC, _("From"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer13->Add(itemStaticText14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_From = new wxTextCtrl( itemPanel1, ID_TEXTCTRL5, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_From->Enable(false); itemBoxSizer13->Add(m_From, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxStaticText* itemStaticText16 = new wxStaticText( itemPanel1, wxID_STATIC, _("To"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer13->Add(itemStaticText16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_To = new wxTextCtrl( itemPanel1, ID_TEXTCTRL6, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_To->Enable(false); itemBoxSizer13->Add(m_To, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_AddToExisting = new wxCheckBox( itemPanel1, ID_CHECKBOX2, _("Also add to sequences that already have a feature like this"), wxDefaultPosition, wxDefaultSize, 0 ); m_AddToExisting->SetValue(true); itemBoxSizer2->Add(m_AddToExisting, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); ////@end CBulkLocationPanel content construction } /*! * Should we show tooltips? */ bool CBulkLocationPanel::ShowToolTips() { return true; } /*! * Get bitmap resources */ wxBitmap CBulkLocationPanel::GetBitmapResource( const wxString& name ) { // Bitmap retrieval ////@begin CBulkLocationPanel bitmap retrieval wxUnusedVar(name); return wxNullBitmap; ////@end CBulkLocationPanel bitmap retrieval } /*! * Get icon resources */ wxIcon CBulkLocationPanel::GetIconResource( const wxString& name ) { // Icon retrieval ////@begin CBulkLocationPanel icon retrieval wxUnusedVar(name); return wxNullIcon; ////@end CBulkLocationPanel icon retrieval } /*! * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON2 */ void CBulkLocationPanel::OnRadiobutton2Selected( wxCommandEvent& event ) { m_From->Enable(false); m_To->Enable(false); } /*! * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON3 */ void CBulkLocationPanel::OnRadiobutton3Selected( wxCommandEvent& event ) { m_From->Enable(true); m_To->Enable(true); } CRef<CSeq_loc> CBulkLocationPanel::GetLocForBioseq (const CBioseq& bioseq) { int max = bioseq.GetLength() - 1; int from = 0; int to = max; if (m_Coordinates->GetValue()) { string val = ToStdString(m_From->GetValue()); if (NStr::IsBlank(val)) { CRef<CSeq_loc> empty; return empty; } else { try { from = NStr::StringToInt(val); from = from - 1; } catch (...) { CRef<CSeq_loc> empty; return empty; } } val = ToStdString(m_To->GetValue()); if (NStr::IsBlank(val)) { CRef<CSeq_loc> empty; return empty; } else { try { to = NStr::StringToInt(val); to = to - 1; } catch (...) { CRef<CSeq_loc> empty; return empty; } } if (from > max) { from = max; } if (to > max) { to = max; } if (from > to) { int swap = from; from = to; to = swap; } } CRef<CSeq_loc> loc(new CSeq_loc()); loc->SetInt().SetId().Assign(*bioseq.GetId().front()); loc->SetInt().SetFrom(from); loc->SetInt().SetTo(to); if (m_Strand->GetSelection() == 1) { loc->SetInt().SetStrand(eNa_strand_minus); } if (m_Partial5->GetValue()) { loc->SetPartialStart(true, eExtreme_Biological); } if (m_Partial3->GetValue()) { loc->SetPartialStop (true, eExtreme_Biological); } return loc; } END_NCBI_SCOPE

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.