genome_layoutpolicy.cpp

来自「ncbi源码」· C++ 代码 · 共 207 行

CPP
207
字号
/* * =========================================================================== * PRODUCTION $Log: genome_layoutpolicy.cpp,v $ * PRODUCTION Revision 1000.1  2004/06/01 21:12:39  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7 * PRODUCTION * =========================================================================== *//*  $Id: genome_layoutpolicy.cpp,v 1000.1 2004/06/01 21:12:39 gouriano Exp $ * =========================================================================== * *                            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:  Vlad Lebedev * * File Description: * */#include <ncbi_pch.hpp>#include <gui/widgets/seq_graphic/genome_layoutpolicy.hpp>#include <gui/objutils/feature.hpp>#include <gui/objutils/comment.hpp>#include <gui/objutils/alignment.hpp>#include <gui/objutils/feat_pack.hpp>#include <gui/objutils/utils.hpp>#include <gui/objutils/feat_label.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(objects);CGenomeLayoutPolicy::CGenomeLayoutPolicy(){}void CGenomeLayoutPolicy::PrepareData(CGlPane& pane, CLayout& lay_objects){    pane.OpenOrtho();    if (x_IsOverviewMode(pane)) {        x_PrepareGenomeView(pane, lay_objects);    } else {        x_PrepareDetailedView(pane, lay_objects);        }        pane.Close();}void CGenomeLayoutPolicy::x_PrepareGenomeView(CGlPane& pane, CLayout& lay_objects){    TModelRect rcV = pane.GetVisibleRect();    TSeqRange range( TSeqPos(rcV.Left()), TSeqPos(rcV.Right()) );        lay_objects.Clear();        C2DLayoutEngine engine;    engine.SetMinDist( x_GetMinSpacing(pane) );            CLayout temporary;    CLayoutFeat::TFeatList feats;    CLayoutFeat::TFeatList land_marks;    CLayoutEngine::TObjects objs;        lay_objects.Clear();    engine.Layout(objs, lay_objects);        // Add Segment Map    x_AddSeqSegmentMap(pane, lay_objects, range);    // Add feature profile histograms    x_AddHistograms(pane, lay_objects, range);        // All Genes    CSeqUtils::GetFeatures(m_Handle, range, CSeqFeatData::e_Gene, feats);        // Landmark Genes    CSeqUtils::GetLandmarkFeatures(m_Handle, range, 150, land_marks);    // Comments for All Genes    string str = "All Genes: " + NStr::UIntToString(feats.size());    CRef<CLayoutObject> comment1(new CLayoutComment(str));    objs.push_back(comment1);    engine.Layout(objs, temporary);    lay_objects.Append(temporary);            if (land_marks.size() < feats.size()) {        objs.clear();        NON_CONST_ITERATE (CLayoutFeat::TFeatList, iter, feats) {            (*iter)->HideLabels();  // hide labels for all genes            CRef<CLayoutObject> obj(*iter);            objs.push_back(obj);        }        engine.Layout(objs, temporary);        lay_objects.Append(temporary);    }    // Comments for Landmark Genes    if (land_marks.size() < feats.size()) {        objs.clear();        temporary.Clear();        str  = "Landmark Genes: " + NStr::UIntToString(land_marks.size());                CRef<CLayoutObject> comment2(new CLayoutComment(str));        objs.push_back(comment2);        engine.Layout(objs, temporary);        lay_objects.Append(temporary);    }    objs.clear();    SAnnotSelector sel =        CSeqUtils::GetAnnotSelector(CSeqFeatData::eSubtype_mRNA);    NON_CONST_ITERATE (CLayoutFeat::TFeatList, iter, land_marks) {        CLayoutFeat& feat = **iter;        TSeqRange range = feat.GetMappedFeature().GetLocation().GetTotalRange();        CRef<CLayoutObject> gene_obj(*iter);        objs.push_back(gene_obj);        CLayoutFeat::TFeatList feats_tmp;        CSeqUtils::GetFeatures(m_Handle, range, sel, feats_tmp);                if (feats_tmp.size() > 1) {  // Add a pack of features            CRef<CLayoutFeatPack> pack(new CLayoutFeatPack(feats_tmp));            CRef<CLayoutObject> obj(pack);            objs.push_back(obj);        } else if (feats_tmp.size() == 1) {  // Just add mRNA            CRef<CLayoutObject> rna_obj(feats_tmp[0]);            objs.push_back(rna_obj);                }    }        temporary.Clear();    engine.Layout(objs, temporary);        lay_objects.Append(temporary);}END_NCBI_SCOPE/* * =========================================================================== * $Log: genome_layoutpolicy.cpp,v $ * Revision 1000.1  2004/06/01 21:12:39  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7 * * Revision 1.7  2004/05/21 22:27:55  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.6  2004/05/03 13:23:58  dicuccio * gui/utils --> gui/objutils where needed * * Revision 1.5  2004/04/07 13:11:28  dicuccio * Use proper annotation selector for retrieving mRNA features * * Revision 1.4  2004/03/23 12:33:56  lebedev * Made sequence and histograms bars a layout objects in the object panel. * Made segment map a number of layout objects. Get rid of fixed size rows in the object panel. * * Revision 1.3  2004/03/11 17:53:06  dicuccio * Deprecated typedefs TPosition, TDimension, TIndex, TColor.  Use TSeqRange instead of TRange * * Revision 1.2  2004/03/02 15:29:14  lebedev * Switch to detailed mode if reached certain number of * genes in visible range. * * Revision 1.1  2004/02/24 14:43:49  lebedev * Initial revision * * =========================================================================== */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?