NCBI C++ Toolkit Cross Reference

  C++/src/gui/widgets/seq_graphic/seq_glyph.cpp


/* $Id: seq_glyph.cpp 26400 2012-09-12 13:24:18Z wuliangs $ * =========================================================================== * * 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: Mike Dicuccio, Liangshou Wu * * File Description: * */ #include <ncbi_pch.hpp> #include <gui/widgets/seq_graphic/seq_glyph.hpp> #include <gui/widgets/seq_graphic/rendering_ctx.hpp> #include <gui/widgets/seq_graphic/object_based_glyph.hpp> #include <corelib/ncbiutil.hpp> BEGIN_NCBI_SCOPE static const TModelUnit kUndefined = -1.0; CSeqGlyph::CSeqGlyph() : m_Parent(NULL) , m_Width(kUndefined) , m_Height(kUndefined) , m_Pos(kUndefined, kUndefined) , m_Context(NULL) , m_Selected(false) , m_Highlighted(false) { } bool CSeqGlyph::OnLeftDown(const TModelPoint& /*p*/) { return false; } bool CSeqGlyph::OnLeftUp(const TModelPoint& /*p*/) { return false; } bool CSeqGlyph::OnLeftDblClick(const TModelPoint& /*p*/) { return false; } void CSeqGlyph::Update(bool /*layout_only*/) { x_UpdateBoundingBox(); } void CSeqGlyph::Draw() const { if (m_Renderer) { m_Renderer->Draw(this); } else { x_Draw(); } if (IsHighlighted()) { x_DrawHighlight(); } } CRef<CSeqGlyph> CSeqGlyph::HitTest(const TModelPoint& p) { CRef<CSeqGlyph> obj; if (IsIn(p)) { obj.Reset(this); } return obj; } bool CSeqGlyph::Intersects(const TModelRect& rect, TConstObjects& objs) const { if (rect.Intersects(GetModelRect())) { objs.push_back(CConstRef<CSeqGlyph>(this)); return true; } return false; } bool CSeqGlyph::NeedTooltip(const TModelPoint& /*p*/, string& /*tt*/, string& t_title) const { return false; } void CSeqGlyph::GetTooltip(const TModelPoint& /*p*/, string& tt, string& /*t_title*/) const { tt = kEmptyStr; } bool CSeqGlyph::IsIn(TModelUnit x, TModelUnit y) const { TModelUnit pix_size = m_Context->ScreenToSeq(1.0); return x > GetLeft() - pix_size && x < GetRight() + pix_size && y > GetTop() - 1.0 && y < GetBottom() + 1.0; } void CSeqGlyph::x_DrawHighlight() const { m_Context->DrawHighlight(GetModelRect()); } void CSeqGlyph::x_OnLayoutChanged() { x_UpdateBoundingBox(); if (m_Parent) { m_Parent->x_OnLayoutChanged(); } } void CSeqGlyph::x_World2Local(TModelUnit& x, TModelUnit& y) const { if (m_Parent) { m_Parent->x_World2Local(x, y); x_Parent2Local(x, y); } } void CSeqGlyph::x_Local2World(TModelUnit& x, TModelUnit& y) const { y += GetTop(); if (m_Parent) { m_Parent->x_Local2World(x, y); } } void CSeqGlyph::x_InitHTMLActiveArea(CHTMLActiveArea& area) const { TVPUnit x1 = m_Context->SeqToScreenX(GetLeft()); TVPUnit x2 = m_Context->SeqToScreenX(GetRight()); if (m_Context->IsFlippedStrand()) { x1 = -x1; x2 = -x2; } TModelUnit t_x = 0; TModelUnit t_y = 0; x_Local2World(t_x, t_y); TVPUnit y1 = TVPUnit(t_y); TVPUnit y2 = TVPUnit(t_y + GetHeight() + 2.0); area.m_Bounds.Init(x1, y2, x2, y1); area.m_SeqRange = GetRange(); } bool CSeqGlyph::x_Visible_V() const { TModelUnit x = 0.0, t = 0.0, b = GetHeight(); x_Local2World(x, t); x_Local2World(x, b); return !m_Context->IntersectVisible_Y(TModelRange(t, b)).Empty(); } 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.