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

Go to the SVN repository for this file.

1 /* $Id: align_mark_handler.cpp 41823 2018-10-17 17:34:58Z katargir $
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: Andrey Yazhuk
27  *
28  * File Description:
29  * CAlignMarkHandler - class implementing support for Marks in alignments.
30  * IAlignMarkHandlerHost - context in which CAlignMarkHandler operates.
31  */
32 
33 #include <ncbi_pch.hpp>
34 
36 #include <gui/opengl/glutils.hpp>
37 #include <gui/opengl/irender.hpp>
38 
39 #include <wx/settings.h>
40 
41 #include <math.h>
42 
43 
46 
47 BEGIN_EVENT_TABLE(CAlignMarkHandler, wxEvtHandler)
48  EVT_LEFT_DOWN(CAlignMarkHandler::OnLeftDown)
49  EVT_LEFT_UP(CAlignMarkHandler::OnLeftUp)
50  EVT_MOTION(CAlignMarkHandler::OnMotion)
51  EVT_MOUSE_CAPTURE_LOST(CAlignMarkHandler::OnMouseCaptureLost)
52  EVT_KEY_DOWN(CAlignMarkHandler::OnKeyDown)
53  EVT_KEY_UP(CAlignMarkHandler::OnKeyUp)
55 
56 
58 : m_Host(NULL),
59  m_Pane(NULL),
60  m_bHitResizable(false),
61  m_State(eIdle),
62  m_CursorId(wxCURSOR_DEFAULT),
63  m_PrevPos((TSeqPos)-1),
64  m_FillColor(0.5f, 0.5f, 1.0f, 0.5f),
65  m_FrameColor(0.25f, 0.25f, 0.5f, 1.0f),
66  m_DragArea(0)
67 {
68  m_DragArea = wxSystemSettings::GetMetric(wxSYS_DRAG_X);
69 }
70 
71 
73 {
74  m_Host = pHost;
75 }
76 
77 
79 {
80  return dynamic_cast<IGenericHandlerHost*>(m_Host);
81 }
82 
83 
85 {
86  m_Pane = pane;
87 }
88 
89 
91 {
92  return this;
93 }
94 
95 ////////////////////////////////////////////////////////////////////////////////
96 // opeartions with Mark
97 
98 // "coll" specifies ranges in sequence coordinates
100 {
102  if(itM == m_mpRowToMark.end())
104  TRangeColl& mark = itM->second;
105 
106  if(set) { // mark
107  mark.CombineWith(coll);
108  } else { // unmark
109  mark.Subtract(coll);
110  }
111 }
112 
113 
114 // "coll" specifies ranges in alignment coordinates
116 {
117  const IAlnMultiDataSource* pAlnDS = x_GetHost()->MHH_GetAlnDS();
118 
120  if(itM == m_mpRowToMark.end())
122  TRangeColl& mark = itM->second;
123 
124  ITERATE(TRangeColl, itR, coll) { // for each Range in C
125  // translate Range to sequence coordinates
126  TSeqPos from = pAlnDS->GetSeqPosFromAlnPos(row, itR->GetFrom(),
128  TSeqPos to = pAlnDS->GetSeqPosFromAlnPos(row, itR->GetTo(),
130  TSeqRange R(from, to);
131  if(set) {
132  mark += R; // mark
133  } else {
134  mark -= R; // unmark
135  }
136  }
137 }
138 
139 
141 {
143 }
144 
145 
147 {
149  return (itM != m_mpRowToMark.end()) ? &itM->second : NULL;
150 }
151 
152 
154 {
155  const TSelListModel* pModel = x_GetHost()->MHH_GetSelListModel();
157  pModel->SLM_GetSelectedIndices(vSel);
158 
159  //const IAlnMultiDataSource* pAlnDS = x_GetHost()->MHH_GetAlnDS();
160 
161  ITERATE(TSelListModel::TIndexVector, it, vSel) { // for each Mark
162  TNumrow row = pModel->SLM_GetItem(*it);
163  MarkRow(row, coll, set);
164  }
165 }
166 
167 
169 {
171 }
172 
173 
175 {
176  // get selected lines
177  const TSelListModel* pModel = x_GetHost()->MHH_GetSelListModel();
179  pModel->SLM_GetSelectedIndices(vIndices);
180 
181  // for each selected Line
182  ITERATE(TSelListModel::TIndexVector, it, vIndices) {
185  }
186 }
187 
188 
190 {
191  return m_mpRowToMark;
192 }
193 
194 
195 ////////////////////////////////////////////////////////////////////////////////
196 // event handlers
197 
199 {
200  return wxGetKeyState(wxKeyCode('M'));
201 }
202 
203 
204 void CAlignMarkHandler::OnLeftDown(wxMouseEvent& event)
205 {
206  if(x_MarkState()) {
207  wxPoint ms_pos = event.GetPosition();
208  x_OnStartSel(ms_pos);
209  x_OnSelectCursor(ms_pos);
210  } else {
211  event.Skip();
212  }
213 }
214 
215 void CAlignMarkHandler::OnMotion(wxMouseEvent& event)
216 {
217  bool mark = x_MarkState();
218  if(event.Dragging()) {
219  if(m_State == eResize && mark) {
220  x_OnChangeSelRange(event.GetPosition());
221  }
222  // always handle drags
223  } else {
224  if(mark) {
225  x_OnSelectCursor(event.GetPosition());
226  } else {
227  event.Skip();
228  }
229  }
230 }
231 
232 
233 void CAlignMarkHandler::OnLeftUp(wxMouseEvent& event)
234 {
235  if(m_State != eIdle) {
236  if(m_State == eResize) {
237  wxPoint ms_pos = event.GetPosition();
238  EState new_state = x_MarkState() ? eReady : eIdle;
239  x_OnEndSelRange(new_state, ms_pos);
240  }
241  } else {
242  event.Skip();
243  }
244 }
245 
246 
247 void CAlignMarkHandler::OnKeyDown(wxKeyEvent& event)
248 {
249  if(x_MarkState()) {
250  int k = event.GetKeyCode();
251  if(k == WXK_DELETE) {
252  UnMarkSelected();
254  return;
255  }
256  x_UpdateState(true, event.GetPosition());
257  } else {
258  event.Skip();
259  }
260 }
261 
262 
263 void CAlignMarkHandler::OnKeyUp(wxKeyEvent& event)
264 {
265  if(m_State == eResize) {
266  if(x_MarkState()) {
267  x_OnEndSelRange(eIdle, event.GetPosition());
268  } else {
269  x_UpdateState(true, event.GetPosition());
270  }
271  } else {
272  event.Skip();
273  }
274 }
275 
276 
277 ////////////////////////////////////////////////////////////////////////////////
278 /// Signal handlers
279 void CAlignMarkHandler::x_OnStartSel(const wxPoint& ms_pos)
280 {
281  if(x_HitSelectedLine(ms_pos)) {
282  m_PrevPos = (TSeqPos) -1;
283 
284  x_InitDeltaMap(ms_pos);
285 
286  m_State = eResize;
289  }
290 }
291 
292 
293 void CAlignMarkHandler::x_OnChangeSelRange(const wxPoint& ms_pos)
294 {
295  TModelUnit mX = x_MouseToSeqPos(ms_pos);
296  TSeqPos pos = (TSeqPos) floor(mX);
297  pos = x_ClipPosByRange(pos);
298 
299  if(pos != m_PrevPos) {
300  x_UpdateSelection(pos);
302  }
303 
304  m_PrevPos = pos;
305 }
306 
307 
308 void CAlignMarkHandler::x_OnEndSelRange(EState new_state, const wxPoint& ms_pos)
309 {
310  x_OnChangeSelRange(ms_pos);
311 
312  x_UpdateMarks();
313  m_State = new_state;
314 
315  x_OnSelectCursor(ms_pos);
318 }
319 
320 
322 {
325 
326  m_State = eIdle;
327  m_PrevPos = (TSeqPos) -1;
328 
330 }
331 
332 
333 void CAlignMarkHandler::x_UpdateState(bool b_key, const wxPoint& ms_pos)
334 {
335  bool bHit = x_HitSelectedLine(ms_pos);
336 
337  EState new_state = m_State;
338  switch(m_State) {
339  case eIdle:
340  case eReady:
341  new_state = (b_key && bHit) ? eReady : eIdle;
342  break;
343  case eResize:
344  new_state = b_key ? eResize : eIdle;
345  break;
346  }
347 
348  if(new_state != m_State) {
349  m_State = new_state;
350 
351  x_OnSelectCursor(ms_pos);
353  }
354 }
355 
356 
357 // Select cursor depending on the current state and mouse position
358 void CAlignMarkHandler::x_OnSelectCursor(const wxPoint& ms_pos)
359 {
360  switch(m_State) {
361  case eIdle:
362  m_CursorId = wxCURSOR_DEFAULT;
363  break;
364 
365  case eReady: {
366  if(x_HitSelectedLine(ms_pos)) {
367  m_CursorId = x_HitRangeBorder(ms_pos) ? wxCURSOR_SIZEWE : wxCURSOR_IBEAM;
368  } else {
369  m_CursorId = wxCURSOR_DEFAULT;
370  }
371  break;
372  }
373  case eResize:
374  m_CursorId = wxCURSOR_SIZEWE;
375  break;
376  default:
377  break;
378  }
379 
381 }
382 
383 
384 ////////////////////////////////////////////////////////////////////////////////
385 /// helper functions
386 
387 // converts mouse X position to the position in Alignment
389 {
390  _ASSERT(m_Pane);
391  return m_Host->MHH_GetSeqPosByX(ms_pos.x) + 0.5;
392 }
393 
394 
395 // functions creates a "delta" map for ranges that will be resized
396 void CAlignMarkHandler::x_InitDeltaMap(const wxPoint& ms_pos)
397 {
399 
400  // get selected lines
401  const TSelListModel* pModel = x_GetHost()->MHH_GetSelListModel();
403  pModel->SLM_GetSelectedIndices(vIndices);
404 
405  const IAlnMultiDataSource* pAlnDS = x_GetHost()->MHH_GetAlnDS();
406 
407  // for each selected Line
408  ITERATE(TSelListModel::TIndexVector, it, vIndices) {
410  TSeqRange hit_r;
411 
412  // hit testing Mark corresponding to the Row (if it exists)
413  bool hit_start = false; // hit start on alignment
414  SMarkDelta::EExtState start_state, state;
415  bool positive = pAlnDS->IsPositiveStrand(row);
416 
418  if(itM != m_mpRowToMark.end()) {
419  TRangeColl& Mark = itM->second;
420  x_HitTest(row, Mark, ms_pos.x, hit_r, hit_start);
421  } else { // if Mark does not exist - create it
423  }
424 
425  bool seq_start = (hit_start == positive); // hit start on sequnence
426 
427  TSeqPos start_pos;
428  if(hit_r.NotEmpty()) { // hit a border of the marked range
429  start_state = hit_start ? SMarkDelta::eExtRangeStart
431  state = start_state;
432  start_pos = seq_start ? hit_r.GetFrom() : hit_r.GetToOpen();
433  } else {
434  start_state = SMarkDelta::eNoExt;
436 
437  TModelUnit mX = x_MouseToSeqPos(ms_pos);
438  start_pos = (TSeqPos) floor(mX);
439  if( ! positive) {
440  start_pos--;
441  }
442  start_pos = pAlnDS->GetSeqPosFromAlnPos(row, start_pos, IAlnExplorer::eRight);
443 
444  hit_r.SetFrom(start_pos);
445  hit_r.SetLength(0);
446  }
447 
448  // initate Map record
449  m_mpRowToDelta[row] = SMarkDelta(hit_r, TSeqRange(start_pos, start_pos - 1), start_state, state);
450  }
451 }
452 
453 
454 //returns true if mouse pointer is over selected line
455 bool CAlignMarkHandler::x_HitSelectedLine(const wxPoint& ms_pos)
456 {
457  const TSelListModel* pModel = x_GetHost()->MHH_GetSelListModel();
458  int Index = x_GetHost()->MHH_GetLineByWindowY(ms_pos.y);
459 
460  return Index >=0 && pModel->SLM_IsItemSelected(Index);
461 }
462 
463 
464 // returns true if mouse pointer is located over the end of one of the marked segments
465 bool CAlignMarkHandler::x_HitRangeBorder(const wxPoint& ms_pos) const
466 {
467  int Index = x_GetHost()->MHH_GetLineByWindowY(ms_pos.y);
468 
469  if(Index >= 0) {
470  const TSelListModel* pModel = x_GetHost()->MHH_GetSelListModel();
471 
472  if(pModel->SLM_IsItemSelected(Index)) {
474  TSeqRange hit_r;
475  bool hit_start = false;
476  // test the Mark corresponding to the row
478  if(it != m_mpRowToMark.end()) {
479  const TRangeColl& Mark = it->second;
480  x_HitTest(row, Mark, ms_pos.x, hit_r, hit_start);
481  if(hit_r.NotEmpty())
482  return true;
483  }
484  }
485  }
486  return false;
487 }
488 
489 
490 // perfroms a hit test of a given position "X" agains given TRangeColl C
491 // if positions hits a range in the C, this range is returned in "Range"
492 // (in "sequence" coordinates), overwise "Range" is set empty. If position
493 // hits the start of a range then "hit_start" is assigned "true"
494 void CAlignMarkHandler::x_HitTest(TNumrow row, const TRangeColl& C, int X, TSeqRange& Range, bool& hit_start) const
495 {
496  _ASSERT(m_Pane);
497 
498  int MinD = -1;
499  bool bMinStart = false;
500  TRangeColl::const_iterator itMinRange = C.end();
501  const IAlnMultiDataSource *pAlnDS = x_GetHost()->MHH_GetAlnDS();
502 
503  ITERATE(TRangeColl, itR, C) { // iterating by Ranges in C
504  TSeqPos from = pAlnDS->GetAlnPosFromSeqPos(row, itR->GetFrom());
505  TSeqPos to = pAlnDS->GetAlnPosFromSeqPos(row, itR->GetTo());
506  TSeqRange aln_r(from, to);
507 
508  int FromX = m_Pane->ProjectX(aln_r.GetFrom());
509  int ToX = m_Pane->ProjectX(aln_r.GetToOpen());
510 
511  int D = abs(X - FromX); // distance from the start of the range
512  if(MinD < 0 || MinD > D) {
513  MinD = D;
514  bMinStart = true;
515  itMinRange = itR;
516  }
517 
518  D = abs(X - ToX); // distance from the stop of the range
519  if(MinD > D) {
520  MinD = D;
521  bMinStart = false;
522  itMinRange = itR;
523  }
524  }
525 
526  if(MinD > -1 && MinD <= m_DragArea) {
527  hit_start = bMinStart;
528  _ASSERT(itMinRange != C.end());
529  Range = *itMinRange;
530  } else Range.SetLength(0);
531 }
532 
533 
535 {
537  pos = min(pos, (TSeqPos) rcL.Right() - 1);
538  pos = max(pos, (TSeqPos) rcL.Left());
539  return pos;
540 }
541 
542 
543 // updates Ranges being dragged accordingly to the given position
545 {
546  const IAlnMultiDataSource* pAlnDS = x_GetHost()->MHH_GetAlnDS();
547 
549  SMarkDelta& delta = it->second;
550  TNumrow row = it->first;
551  bool negative = pAlnDS->IsNegativeStrand(row);
552  TSeqPos trans_pos = pos + (negative ? -1 : 0);
555 
556  TSeqPos seq_pos = pAlnDS->GetSeqPosFromAlnPos(row, trans_pos, dir);
557  x_UpdateDelta(delta.m_Range, delta.m_State, seq_pos);
558  }
559 }
560 
561 
562 // update given range so that the range end specified by "state" becomes equal
563 // to "pos".
566 {
567  if(state == SMarkDelta::eNoExt && pos != R.GetFrom()) {
568  if(pos > R.GetFrom()) {
569  R.SetToOpen(pos);
571  } else {
572  R.SetToOpen(R.GetFrom());
573  R.SetFrom(pos);
575  }
576  } else if(state == SMarkDelta::eExtRangeEnd && pos != R.GetToOpen()) {
577  if(pos > R.GetFrom()) {
578  R.SetToOpen(pos);
579  } else { //flip
580  R.SetToOpen(R.GetFrom());
581  R.SetFrom(pos);
583  }
584  } else if(state == SMarkDelta::eExtRangeStart && pos != R.GetFrom()) {
585  if(pos <= R.GetToOpen()) {
586  R.SetFrom(pos);
587  } else {
588  R.SetFrom(R.GetToOpen());
589  R.SetToOpen(pos);
591  }
592  }
593 
594 }
595 
596 
597 /// applies changes in SMarkDelta to mark collection
599 {
600  ITERATE(TRowToDeltaMap, it, m_mpRowToDelta) { // for every row
601  TNumrow row = it->first;
603  if(itMark == m_mpRowToMark.end()) {
604  itMark = m_mpRowToMark.insert(
606  }
607  TRangeColl& C = itMark->second;
608 
609  const SMarkDelta& delta = it->second;
610  const TSeqRange& R = delta.m_Range;
611  const TSeqRange& hit_r = delta.m_HitRange;
612 
613  switch(delta.m_StartState) {
614  case SMarkDelta::eNoExt: {
615  if(R.NotEmpty())
616  C.CombineWith(R);
617  }; break;
619  if(R.GetTo() > hit_r.GetTo()) {
620  // extend the end
621  C.CombineWith(R);
622  } else {
623  // cut the end
624  TSeqPos P = max(hit_r.GetFrom(), R.GetFrom());
625  C.Subtract(TSeqRange(P, hit_r.GetTo()));
626  if(R.GetFrom() < hit_r.GetFrom()) {
627  C.CombineWith(TSeqRange(R.GetFrom(), hit_r.GetFrom() - 1));
628  }
629  }
630  }; break;
632  if(R.GetFrom() < hit_r.GetFrom()) {
633  // extend the start
634  C.CombineWith(R);
635  } else {
636  // cut the start
637  TSeqPos P = min(hit_r.GetTo(), R.GetTo());
638  C.Subtract(TSeqRange(hit_r.GetFrom(), P));
639  if(R.GetTo() > hit_r.GetTo()) {
640  C.CombineWith(TSeqRange(hit_r.GetToOpen(), R.GetTo()));
641  }
642  }
643  }; break;
644  };
645  }
647 }
648 
649 
651 {
652  IRender& gl = GetGl();
653  TModelRect rcV = pane.GetVisibleRect();
654 
655  const IAlnMultiDataSource* pAlnDS = x_GetHost()->MHH_GetAlnDS();
656  const TSelListModel* pModel = x_GetHost()->MHH_GetSelListModel();
657 
658  if(! rcV.IsEmpty() && pAlnDS && pModel) {
659 
660  pane.OpenOrtho();
661 
662  TModelUnit offset_x = pane.GetOffsetX();
663  TModelUnit offset_y = pane.GetOffsetY();
664 
665  ITERATE(TRowToMarkMap, itM, m_mpRowToMark) { // for each Mark
666  TNumrow row = itM->first;
667  int Index = x_GetHost()->MHH_GetLineByRowNum(row);
668 
669  if(Index >= 0) { // row exists
670  TModelUnit top_y = x_GetHost()->MHH_GetLinePosY(Index);
671  TModelUnit bottom_y = top_y + x_GetHost()->MHH_GetLineHeight(Index) - 1;
672  bool bVisible = ! (bottom_y < rcV.Top() || top_y > rcV.Bottom());
673 
674  if(bVisible) {
675  bool bSelected = pModel->SLM_IsItemSelected(Index);
676  const TRangeColl& Mark = itM->second;
677 
678  // draw existing mark
679  ITERATE(TRangeColl, itR, Mark) { // for each Range in Mark
680  TSeqRange aln_r = x_AlnRangeFromSeqRange(pAlnDS, row, *itR);
681  TModelUnit x1 = aln_r.GetFrom() - offset_x;
682  TModelUnit x2 = aln_r.Empty() ? x1 : (aln_r.GetToOpen() - offset_x);
683 
684  gl.ColorC(m_FillColor);
685  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
686  gl.Rectd(x1, bottom_y - offset_y, x2, top_y - offset_y);
687 
688  if(bSelected) {
689  gl.ColorC(m_FrameColor);
690  gl.PolygonMode(GL_FRONT_AND_BACK, GL_LINE);
691  gl.Rectd(x1, bottom_y - offset_y, x2, top_y - offset_y);
692  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
693  }
694  }
695 
696  // draw delta - range being edited
698  if(itD != m_mpRowToDelta.end()) {
699  const SMarkDelta& delta = itD->second;
700  const TSeqRange& delta_r = delta.m_Range;
701 
702  TSeqRange aln_r = x_AlnRangeFromSeqRange(pAlnDS, row, delta_r);
703 
704  TModelUnit x1 = aln_r.GetFrom() - offset_x;
705  TModelUnit x2 = aln_r.Empty() ? x1 : (aln_r.GetToOpen() - offset_x);
706 
707  gl.Color4d(0.25, 0.25, 1.0, 1.0);
708  gl.PolygonMode(GL_FRONT_AND_BACK, GL_LINE);
709  gl.Rectd(x1, bottom_y - offset_y,
710  x2, top_y - offset_y);
711  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
712  }
713  }
714  }
715  }
716  pane.Close();
717  }
718 }
719 
720 
722  TNumrow row,
723  const TSeqRange& seq_r)
724 {
725  TSeqRange r;
726  bool negative = pAlnDS->IsNegativeStrand(row);
727 
728  if(seq_r.Empty()) {
729  TSeqPos seq_from = seq_r.GetFrom() + (negative ? -1 : 0);
730  TSeqPos pos_1 = pAlnDS->GetAlnPosFromSeqPos(row, seq_from);//,
731  //IAlnMultiDataSource::TSearchDirection::eRight);
732 
733  r.SetFrom(pos_1);
734  r.SetLength(0);
735  } else {
736  TSeqPos pos_1, pos_2;
737 
738  if(negative) {
739  pos_2 = pAlnDS->GetAlnPosFromSeqPos(row, seq_r.GetFrom(),
741  pos_1 = pAlnDS->GetAlnPosFromSeqPos(row, seq_r.GetTo(),
743  } else {
744  pos_1 = pAlnDS->GetAlnPosFromSeqPos(row, seq_r.GetFrom(),
746  pos_2 = pAlnDS->GetAlnPosFromSeqPos(row, seq_r.GetTo(),
748 
749  }
750  r.SetFrom(pos_1);
751  r.SetTo(pos_2);
752  }
753  return r;
754 }
755 
756 
757 void CAlignMarkHandler::OnMouseCaptureLost(wxMouseCaptureLostEvent& evt)
758 {
759  m_State = eIdle;
760 
761  x_OnSelectCursor(wxPoint()); // position does not matter for eIdle
763 }
764 
765 
USING_SCOPE(objects)
CAlignMarkHandler manages handling and editing of marks on alignments.
void SetHost(IAlignMarkHandlerHost *pHost)
wxStockCursor m_CursorId
operation type
void OnMouseCaptureLost(wxMouseCaptureLostEvent &evt)
void MarkRow(TNumrow row, const TRangeColl &C, bool set)
mark/unmark a collection of intervals in alignment coordinates
void OnLeftUp(wxMouseEvent &event)
IAlnExplorer::TNumrow TNumrow
TSeqPos x_ClipPosByRange(TSeqPos Pos)
void OnMotion(wxMouseEvent &event)
IAlignMarkHandlerHost::TRangeColl TRangeColl
void OnKeyUp(wxKeyEvent &event)
TRowToDeltaMap m_mpRowToDelta
Marks.
const IAlignMarkHandlerHost * x_GetHost() const
void x_OnSelectCursor(const wxPoint &ms_pos)
void MarkSelectedRows(const TRangeColl &C, bool set)
IAlignMarkHandlerHost * m_Host
Ranges being edited.
void x_OnChangeSelRange(const wxPoint &ms_pos)
void x_UpdateMarks()
applies changes in SMarkDelta to mark collection
TRowToMarkMap m_mpRowToMark
bool x_HitRangeBorder(const wxPoint &ms_pos) const
void Render(CGlPane &Pane)
IGenericHandlerHost * GetGenericHost()
virtual wxEvtHandler * GetEvtHandler()
void OnKeyDown(wxKeyEvent &event)
void x_UpdateSelection(TSeqPos NewPos)
void x_HitTest(TNumrow Row, const TRangeColl &C, int X, TSeqRange &Range, bool &bHitStart) const
void OnLeftDown(wxMouseEvent &event)
void x_OnEndSelRange(EState new_state, const wxPoint &ms_pos)
void x_InitDeltaMap(const wxPoint &ms_pos)
void x_UpdateDelta(TSeqRange &R, SMarkDelta::EExtState &State, TSeqPos Pos)
void MarkRowSeq(TNumrow row, const TRangeColl &C, bool set)
mark/unmark a collection of intervals in seq. coordinates
const TRowToMarkMap & GetMarks() const
bool x_HitSelectedLine(const wxPoint &ms_pos)
void x_OnStartSel(const wxPoint &ms_pos)
Signal handlers.
const TRangeColl * GetMark(TNumrow row) const
virtual void SetPane(CGlPane *pane)
void x_UpdateState(bool b_key, const wxPoint &ms_pos)
TSeqRange x_AlnRangeFromSeqRange(const IAlnMultiDataSource *pAlnDS, TNumrow row, const TSeqRange &seq_r)
TModelUnit x_MouseToSeqPos(const wxPoint &ms_pos)
helper functions
class CGlPane
Definition: glpane.hpp:62
TRangeVector::const_iterator const_iterator
Definition: range_coll.hpp:70
TThisType & CombineWith(const TRange &r)
Definition: range_coll.hpp:195
TThisType & Subtract(const TRange &r)
Definition: range_coll.hpp:205
interface IAlignMarkHandlerHost
virtual TModelUnit MHH_GetSeqPosByX(int X) const =0
virtual int MHH_GetLinePosY(int Index) const =0
virtual int MHH_GetLineByRowNum(TNumrow Row) const =0
virtual int MHH_GetLineByWindowY(int Y) const =0
virtual int MHH_GetLineHeight(int Index) const =0
virtual const TSelListModel * MHH_GetSelListModel() const =0
virtual const IAlnMultiDataSource * MHH_GetAlnDS() const =0
virtual TNumrow MHH_GetRowByLine(int Index) const =0
ESearchDirection
Position search options.
@ eRight
Towards higher aln coord (always to the right)
@ eLeft
Towards lower aln coord (always to the left)
IAlnMultiDataSource - interface to a data source representing an abstract multiple alignment.
virtual TSignedSeqPos GetSeqPosFromAlnPos(TNumrow for_row, TSeqPos aln_pos, IAlnExplorer::ESearchDirection dir=IAlnExplorer::eNone, bool try_reverse_dir=true) const =0
virtual bool IsPositiveStrand(TNumrow row) const =0
virtual TSignedSeqPos GetAlnPosFromSeqPos(TNumrow row, TSeqPos seq_pos, IAlnExplorer::ESearchDirection dir=IAlnExplorer::eNone, bool try_reverse_dir=true) const =0
virtual bool IsNegativeStrand(TNumrow row) const =0
IGenericHandlerHost.
virtual void GHH_ReleaseMouse()=0
releases captured mouse
virtual void GHH_Redraw()=0
redraws the Host and the handler
virtual void GHH_CaptureMouse()=0
captures mouse events in the hosting window for D&D
virtual void GHH_SetCursor(const wxCursor &cursor)=0
changes the cursor in the hosting window
interface ISelListModel
Definition: list_mvc.hpp:45
virtual void SLM_GetSelectedIndices(TIndexVector &vIndices) const =0
virtual TItem SLM_GetItem(TIndex index) const =0
vector< TIndex > TIndexVector
Definition: list_mvc.hpp:49
virtual bool SLM_IsItemSelected(TIndex index) const =0
void erase(iterator pos)
Definition: map.hpp:167
const_iterator end() const
Definition: map.hpp:152
iterator_bool insert(const value_type &val)
Definition: map.hpp:165
void clear()
Definition: map.hpp:169
const_iterator find(const key_type &key) const
Definition: map.hpp:153
Definition: set.hpp:45
#define C(s)
Definition: common.h:231
#define false
Definition: bool.h:36
#define P(a, b)
Definition: sqlwparams.h:19
static FILE * f
Definition: readconf.c:23
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
GLdouble TModelUnit
Definition: gltypes.hpp:48
bool OpenOrtho()
Definition: glpane.hpp:427
T Top() const
Definition: glrect.hpp:84
T Bottom() const
Definition: glrect.hpp:82
TVPUnit ProjectX(TModelUnit m_x) const
Definition: glpane.cpp:661
bool IsEmpty() const
Definition: glrect.hpp:150
IRender & GetGl()
convenience function for getting current render manager
T Right() const
Definition: glrect.hpp:83
TModelUnit GetOffsetY() const
Definition: glpane.hpp:415
void Color4d(GLdouble r, GLdouble g, GLdouble b, GLdouble a)
Definition: irender.hpp:102
TModelRect & GetModelLimitsRect(void)
Definition: glpane.hpp:347
T Left() const
Definition: glrect.hpp:81
void Close(void)
Definition: glpane.cpp:178
virtual void PolygonMode(GLenum face, GLenum mode)=0
Set the polygon rasterization mode.
TModelRect & GetVisibleRect(void)
Definition: glpane.hpp:357
TModelUnit GetOffsetX() const
Definition: glpane.hpp:410
virtual void ColorC(const CRgbaColor &c)=0
Set current color (glColor{3,4}{f,d}{v,})
void Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
Definition: irender.hpp:193
bool NotEmpty(void) const
Definition: range.hpp:152
position_type GetToOpen(void) const
Definition: range.hpp:138
TThisType & SetLength(position_type length)
Definition: range.hpp:194
bool Empty(void) const
Definition: range.hpp:148
CRange< TSeqPos > TSeqRange
typedefs for sequence ranges
Definition: range.hpp:419
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
void SetFrom(TFrom value)
Assign a value to From data member.
Definition: Range_.hpp:231
TTo GetTo(void) const
Get the To member data.
Definition: Range_.hpp:269
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
END_EVENT_TABLE()
#define abs(a)
Definition: ncbi_heapmgr.c:130
T positive(T x_)
T max(T x_, T y_)
T min(T x_, T y_)
T negative(T x_)
Int4 delta(size_t dimension_, const Int4 *score_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
@ eIdle
#define D(d)
#define row(bind, expected)
Definition: string_bind.c:73
helper class representing range being edited
#define _ASSERT
Modified on Fri Sep 20 14:57:39 2024 by modify_doxy.py rev. 669887