67 #include <wx/msgdlg.h>
84 "The Graphical View provides an overview of annotations "
85 "on sequence, with extensive drill-down capabilities.",
94 : m_GraphicPanel(
NULL)
142 object =
objects[0].object.GetPointer();
143 scope =
objects[0].scope.GetPointer();
149 if (seq_entry && seq_entry->
IsSeq())
150 seq = &seq_entry->
GetSeq();
159 static const wxString strInitializing =
wxT(
"Initializing...");
183 string str(
"Failed to retrieve sequence: ");
202 if (!ws)
return false;
211 string settings = doc->GetViewSettings(view_type, view_ins_id);
212 LOG_POST(
Info <<
"Retrieve view settings: " << settings);
213 if (
nullptr != params) {
215 if (!param_settings.empty()) {
216 LOG_POST(
Info <<
"View settings through params: " << param_settings);
218 settings = param_settings;
222 typedef vector<string>
TToken;
230 if (tokens.size() == 2) {
246 "CViewGraphical::InitView() - finish with loading configuration!");
248 wxMessageBox(
wxT(
"Something is wrong with configuration!"),
249 wxT(
"Failed to load configuration for Graphical view"),
250 wxOK | wxICON_EXCLAMATION);
276 "CViewGraphical::InitView() - load sequence: " << id_desc);
283 if (setting_map.count(
"m") != 0) {
286 if (setting_map.count(
"mk") != 0) {
299 }
else if (setting_map.count(
"v") != 0) {
302 if ( !tokens.empty() ) {
306 if (tokens.size() > 1) {
405 if ((*itr)->GetName() ==
"Seq-align -> Seq-id") {
409 const CSeq_id* seq_id =
dynamic_cast<const CSeq_id*
>(&itLoc->GetObject());
412 if (seqIds.
find(handle) == seqIds.
end()) {
477 if (
typeid(
CSeq_id) ==
typeid(*it_obj)) {
482 for ( ; id_iter; ++id_iter) {
490 }
else if (
const CIdLoc* id_loc =
491 dynamic_cast<const CIdLoc*
>(it_obj->GetPointer()) ) {
493 }
else if(
dynamic_cast<const CVcfVariant*
>(it_obj->GetPointer()) !=
NULL) {
535 if (vrange.
Clamp(bsh, this_range)) {
539 }
catch( std::exception& e ){
541 <<
"CViewGraphic::OnVisibleRangeChanged(): exception caught "
550 const IView* iview = *iter;
556 list<TSeqRange> vis_ranges;
558 if ( !vis_ranges.empty() ) {
561 tmp_objs.push_back(vref);
564 }
catch( std::exception& e ){
566 <<
"CViewGraphic::x_UpdateVisRangeLayout(): exception caught "
623 const IView* iview = *iter;
625 if (view_u && view_p && view_p->
GetId() == view_u->
GetId()) {
626 siblings.erase(iter);
642 dm_srv->AttachContext(*
this);
650 dm_srv->DetachContext(*
this);
689 return fp->GetAnnotNames();
699 static string sid(
"view_graphic_factory");
706 static string slabel(
"View Graphic Factory");
745 const type_info&
type =
typeid(object);
749 return seq_entry.
IsSeq();
762 bool found_good =
false;
763 bool found_bad =
false;
788 const CSeq_loc* loc =
dynamic_cast<const CSeq_loc*
> (iter->object.GetPointer());
790 CScope* scope =
const_cast<CScope*
>(iter->scope.GetPointer());
793 ranges[idh] +=
range;
796 if (ranges.size() == 1) {
799 TRanges::iterator iter = ranges.begin();
800 loc->
SetInt().SetFrom(iter->second.GetFrom());
801 loc->
SetInt().SetTo (iter->second.GetTo());
802 loc->
SetId(*iter->first.GetSeqId());
820 if (!widget || !widget->
IsDirty())
823 string settings =
"v=";
828 if (!markers.empty()) {
829 settings +=
"&m=" + markers;
836 project.SaveViewSettings(view_type, view_ins_id, settings);
837 project.SetDirty(
true);
848 if (
type.IsStr() &&
type.GetStr() ==
"GraphicalViewParams") {
850 const CObject_id& field_id = (*it)->GetLabel();
851 if (!field_id.
IsStr())
867 if (!prj_folder.IsSetItems())
870 vector< CIRef<INonAsnTrackDataFactory> > data_factories;
873 if (data_factories.empty())
879 for (
const auto& prj_item : prj_folder.GetItems()) {
880 if (!prj_item->GetItem().IsOther())
883 for (
auto &factory : data_factories) {
886 if (track_data.
IsNull()) {
894 for (
const auto& prj_folder : prj_folder.GetFolders()) {
vector< TRangeWithFuzz > TRanges
User-defined methods of the data storage class.
std::invoke_result< _Fty, ICanceled & >::type GUI_AsyncExec(_Fty &&_Fnarg, const wxString &msg=wxT("Accessing network..."))
const CSeq_id * GetFirstId() const
CEvent - generic event implementation TODO TODO - Attachments.
string GetDefaultAssembly() const
wxString GetWorkDir() const
CUndoManager & GetUndoManager()
CSeqGraphicWidget * GetWidget()
vector< TRelation > TRelationVector
static void FindRelations(objects::CScope &scope, const CObject &obj, const string &to_type_in, TRelationVector &relations)
SConstScopedObject & GetObject()
const objects::CUser_object * GetParams() const
CProjectService - a service providing API for operations with Workspaces and Projects.
virtual void x_ReportInvalidInputData(TConstScopedObjects &objects)
use this function to report incompatible data in InitView()
virtual void OnProjectChanged()
virtual void x_UpdateContentLabel()
CRef< objects::CScope > m_Scope
virtual string GetClientLabel(IWMClient::ELabel ltype=IWMClient::eDefault) const
returns the client label (name) to be displayed in UI
virtual objects::CScope * x_GetScope() const
virtual void x_AttachToProject(CGBDocument &doc)
TId GetId() const
retrieve a unique ID for this view
virtual void RefreshViewWindow()
virtual bool x_HasProject() const
objects::CGBProjectHandle::TId GetProjectId()
EEventSubtype GetSubtype() const
CProjectViewTypeDescriptor - holds description of a project view type.
virtual void SetWorkbench(IWorkbench *workbench)
IView implementation.
void GetReflectionInfo(const objects::CSeq_id &id, list< TSeqRange > &visible_ranges, CRgbaColor &color, string &label) const
Retrieve all information relevant to showing view reflection - that is, displaying the location of si...
vector< SObject > TObjects
@ fConvert_NoExpensive
do not perform any expensive tests (such as fetching from the network)
class CRgbaColor provides a simple abstraction for managing colors.
CSelectionEvent CSelectionEvent is used for broadcasting selection between views.
static bool MatchIdWithId(const objects::CSeq_id &id1, objects::CScope &scope1, const objects::CSeq_id &id2, objects::CScope &scope2)
bool HasRangeSelection() const
Range Selection - represents a collection of selected segments.
void GetAllObjects(TConstObjects &objs) const
void AddRangeSelection(const objects::CSeq_id &id, const TRangeColl &segs)
objects::CScope & GetScope()
const objects::CHandleRangeMap & GetRangeSelection() const
bool AddObjectSelection(const CObject &obj)
list< CRef< CSeqGlyph > > TObjects
Base class for all serializable objects.
Template class for iteration on objects of class C (non-medifiable version)
CUICommandRegistry is a centralized registry where all application commands should be registered.
@ eOpenGraphicalViewEvent
@ eWidgetDataChanged
notification from child to parent that the underlying data has changed
CViewTypeDescriptor - holds description of a view type.
bool Clamp(const objects::CBioseq_Handle &handle, TSeqRange &range) const
Alter the supplied range according to the rules provided in the policy and the supplied new location.
bool Match(const objects::CSeq_id &id) const
See if we can match the supplied range.
void AddLocation(const objects::CSeq_loc &loc)
Interface for testing cancellation request in a long lasting operation.
virtual const CViewTypeDescriptor & GetViewTypeDescriptor() const
returns a Descriptor for the View Type supported by the Factory
IView - represents a standard visual part of Workbench UI.
IVisibleRangeClient - represents an object that wants notifications about visible range changes.
CFingerprint identifies an instance of IWMClient and is used for labeling layout positions.
IWorkbench is the central interface in the application framework.
iterator_bool insert(const value_type &val)
iterator_bool insert(const value_type &val)
const_iterator find(const key_type &key) const
const_iterator end() const
virtual void RegisterFileAlias(const wxArtID &anId, const wxArtClient &aClient, const wxSize &aSize, const wxString &aName, long aType=wxBITMAP_TYPE_ANY, int anIndex=-1)
static const struct name_t names[]
unsigned int TSeqPos
Type for sequence locations and lengths.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
virtual const CObject * x_GetOrigObject() const
virtual void GetCompatibleToolBars(vector< string > &names)
returns the names of toolbars compatible with this class (toolbars that are relevant and useful in th...
virtual void x_OnSetSelection(CSelectionEvent &evt)
override in derived classes in order to handle selection broadcast
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Error(CExceptionArgs_Base &args)
const string & GetMsg(void) const
Get message string.
void Warning(CExceptionArgs_Base &args)
void Info(CExceptionArgs_Base &args)
CIRef< T > GetServiceByType()
retrieves a typed reference to a service, the name of C++ type is used as the name of the service.
vector< CIRef< IView > > TViews
virtual void GetViews(TViews &views)=0
get all registered views
virtual IViewManagerService * GetViewManagerService()=0
static CRef< objects::CSeq_loc > CreateSeq_loc(const objects::CSeq_id &id, const CRangeCollection< TSeqPos > &ranges)
#define EXT_POINT__NONASN_TRACK_DATA_FACTORY
virtual string GetExtensionIdentifier() const
CViewGraphicFactory.
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
virtual void CreateViewWindow(wxWindow *parent)
create Window corresponding to the view
CConstRef< objects::CSeq_id > m_SeqId
virtual void GetVisibleRanges(CVisibleRange &vrange) const
populate a visible range event for broadcasting
virtual void RegisterCommands(CUICommandRegistry &cmd_reg, wxFileArtProvider &provider)
called by the framework to give Factory a chance to register commands used by view
void OnWidgetDataChanged(CEvent *evt)
virtual IView * CreateInstanceByFingerprint(const TFingerprint &fingerprint) const
if fingerprint is recognized - creates and returns a new instance
virtual void SetWorkbench(IWorkbench *workbench)
IView implementation.
virtual const CViewTypeDescriptor & GetTypeDescriptor() const
return an object providing meta information about thei view type
virtual const wxMenu * GetMenu()
returns a menu (must be deleted by the caller) menu injections should follow a separator named "Contr...
virtual CRef< objects::CScope > GetSearchScope()
virtual CRef< objects::CSeq_loc > GetSearchLoc()
virtual void DestroyViewWindow()
destroy Window corresponding to the view
string x_GetViewSettingsFromParams(const objects::CUser_object *params)
void x_SetNonAsnInput(const objects::CProjectFolder &prj_folder)
void x_UpdateVisRangeLayout(const IViewManagerService::TViews &views)
virtual string GetDMContextName()
returns Name of the context to be used in UI
void OnOpenGraphicalView(CEvent *evt)
virtual void RegisterIconAliases(wxFileArtProvider &provider)
called by the framework to give Factory a chance to register images used by view
virtual bool IsCompatibleWith(const CObject &object, objects::CScope &scope)
CGraphicPanel * m_GraphicPanel
virtual bool InitView(TConstScopedObjects &objects, const objects::CUser_object *params)
initialize view with data, inside this function the view must call CProjectService::AttachView to con...
virtual set< string > GetAnnotNames() const
virtual const CProjectViewTypeDescriptor & GetProjectViewTypeDescriptor() const
returns a Descriptor for the View Type supported by the Factory
virtual void OnViewReleased(IView &)
virtual void OnWidgetRangeChanged()
virtual IView * CreateInstance() const
creates a view instance
virtual void OnViewAttached(IView &)
void SaveSettingsAtProject(objects::CGBProjectHandle &project) const
virtual void SetOrigObject(SConstScopedObject &obj)
virtual void OnVisibleRangeChanged(const CVisibleRange &vrange, IVisibleRangeClient *source)
void GetSelection(CSelectionEvent &evt) const
get selection for broadcasting
CIRef< INonAsnTrackData > m_NonAsnTrackData
virtual int TestInputObjects(TConstScopedObjects &objects)
tests input objects (probably using object conversion, or not) and returns a combination of ETestResu...
virtual wxWindow * GetWindow()
returns a pointer to the wxWindow representing the client
virtual bool x_MergeObjects(TConstScopedObjects &objects)
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
CRef< objects::CScope > scope
void GetExtensionAsInterface(const string &ext_point_id, vector< CIRef< I > > &interfaces)
GetExtensionAsInterface() is a helper function that extracts all extensions implementing the specifie...
vector< CConstRef< CObject > > TConstObjects
virtual const string & GetIconAlias() const
virtual const string & GetHelpId() const
#define ON_EVENT(type, id, handler)
#define END_EVENT_MAP()
Ends definition of Command Map.
CConstRef< CObject > object
#define BEGIN_EVENT_MAP(thisClass, baseClass)
Begins definition of Command Map for CEventHandler-derived class.
virtual void AddListener(CEventHandler *listener, int pool_name=ePool_Default)
Add a listener.
vector< SConstScopedObject > TConstScopedObjects
CConstRef< CSeq_id > GetSeqId(void) const
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
@ eFasta
Tagged ID in NCBI's traditional FASTA style.
void SetId(CSeq_id &id)
set the 'id' field in all parts of this location
TRange GetTotalRange(void) const
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
CSeq_id_Handle GetIdHandle(const CSeq_loc &loc, CScope *scope)
@ eGetId_Best
return the "best" gi (uses FindBestScore(), with CSeq_id::CalculateScore() as the score function
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
const CSeq_id_Handle & GetSeq_id_Handle(void) const
Get handle of id used to obtain this bioseq handle.
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
void Reset(void)
Reset reference object.
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
CRange< TSeqPos > TSeqRange
typedefs for sequence ranges
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
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.
static string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string.
static const char label[]
TTo GetTo(void) const
Get the To member data.
TFrom GetFrom(void) const
Get the From member data.
const TStr & GetStr(void) const
Get the variant data.
bool IsStr(void) const
Check if variant Str is selected.
bool IsStr(void) const
Check if variant Str is selected.
const TStr & GetStr(void) const
Get the variant data.
vector< CRef< CUser_field > > TData
bool IsWhole(void) const
Check if variant Whole is selected.
const TSeq & GetSeq(void) const
Get the variant data.
bool IsSeq(void) const
Check if variant Seq is selected.
range(_Ty, _Ty) -> range< _Ty >
@ eSimilarObjectsAccepted
static const char * str(char *buf, int n)
CProjectViewTypeDescriptor s_ViewGraphicTypeDescr("Graphical Sequence View", "graphical_view", "Graphical View", "The Graphical View provides an overview of annotations " "on sequence, with extensive drill-down capabilities.", "GRAPHICAL_VIEW", "Sequence", false, "Seq-loc", eSimilarObjectsAccepted)
CViewGraphic.
void ReportIDError(const string &id_label, bool is_local, const string &title="Error message")
wxString ToWxString(const string &s)