feat_color.cpp

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

CPP
220
字号
/* * =========================================================================== * PRODUCTION $Log: feat_color.cpp,v $ * PRODUCTION Revision 1000.1  2004/06/01 20:43:09  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6 * PRODUCTION * =========================================================================== *//*  $Id: feat_color.cpp,v 1000.1 2004/06/01 20:43:09 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:  Robert Smith * *//// @file feat_color.cpp/// /// Color preferences per type of SeqFeat.#include <ncbi_pch.hpp>#include <gui/config/feat_color.hpp>#include <gui/config/feat_config_list.hpp>/** @addtogroup PluginConfiguration * * @{ */BEGIN_NCBI_SCOPE/// This returns a string in response to any key if there is nothing/// for that key in the PluginConfigCache.  Hence it works closely/// with LoadCurrentSettings below.string CFeatColorFactoryDefaults::Get(const string& key) const{    string  key1, key2;    NStr::SplitInTwo(key, "|", key1, key2);    if (key1 == "color") {        if (key2 == "Master") {            return CRgbaColor::ColorStrFromName("black");        } else if (key2 == "Gene") {            return CRgbaColor::ColorStrFromName("green4");        } else if (key2 == "RNA Master") {            return CRgbaColor::ColorStrFromName("blue");        } else if (key2 == "CDS") {            return CRgbaColor::ColorStrFromName("red");        } else if (key2 == "repeat_region") {            return CRgbaColor::ColorStrFromName("blue");        }    }    NCBI_THROW(CConfigException, eNoDefaultValue, "key: " + key);    return kEmptyStr;}// definitions for CFeatConfigColor/// use this cstr when declaring a CFeatConfigColor object.CFeatConfigColor::CFeatConfigColor(objects::CPluginConfigCache* config_cache, const string& typedesc)    : CSettingsSet(config_cache, "FeatureColors",                    new CFeatColorFactoryDefaults(), typedesc){    LoadCurrentSettings(eLoad_Current);}/// use this cstr when initializing a CFeatConfigColor object as a parent object/// in an inherited class, since it will probably need a different type/// and factory defaults.  But the FactoryDefaultSettings object pass in to here/// should probably inherit from CFeatColorFactoryDefaults.CFeatConfigColor::CFeatConfigColor(objects::CPluginConfigCache* config_cache,                  const string& type,                 const AutoPtr<IFactoryDefaultSettings>& fds,                 const string& typedesc                 )    : CSettingsSet(config_cache, type, fds, typedesc){ //   LoadCurrentSettings(eLoad_Current); // not needed since the child class will do this.}bool CFeatConfigColor::LoadCurrentSettings(ELoadValueSource src){    /// iterate through all feature types.    /// if we Get a "Not Defined" string, do not set anything for    /// that value, for the feature type.    /// Else set a real value and set Inherited to false.        string featvaluestr;        ClearColors();    const CFeatConfigList& featureList = *GetFeatConfigList();    ITERATE ( CFeatConfigList, fc_it, featureList ) {        int myType = fc_it->GetType();        int mySubtype = fc_it->GetSubtype();                try {            featvaluestr = Get("color" + GetKeyDelimiter() + fc_it->GetStoragekey(), src);            SetColor( myType, mySubtype, CGlColor(featvaluestr));            SetColorInherited( myType, mySubtype, false);        }        catch (const CConfigException&) {        }    }    return true;}bool CFeatConfigColor::SaveCurrentSettings(void){    // iterate through all feature types.    // if features color/show/etc. value is not inherited    //  save it as a string.    //  If it is inherited, or no value is defined for that feature type,     //  we do not save it and make sure there is not an entry with that key.        const CFeatConfigList& featureList = *GetFeatConfigList();    ITERATE(CFeatConfigList, fc_it, featureList) {        int myType = fc_it->GetType();        int mySubtype = fc_it->GetSubtype();                if ( ! m_FeatColors.GetInherited(myType, mySubtype)) {            Set("color" + GetKeyDelimiter() + fc_it->GetStoragekey(),                 GetColor(myType, mySubtype).ToString(false) );        } else {            Delete("color" + GetKeyDelimiter() + fc_it->GetStoragekey());        }    }        return true;}CGlColor CFeatConfigColor::GetColor(int type, int subtype) const{    return m_FeatColors.GetValue(type, subtype);}void CFeatConfigColor::SetColor(int type, int subtype, CGlColor color){    m_FeatColors.SetValue(type, subtype, color);}void CFeatConfigColor::SetColorInherited(int type, int subtype, bool inherited){    m_FeatColors.SetInherited(type, subtype, inherited);}void CFeatConfigColor::ClearColors(){    m_FeatColors.ClearValues();}END_NCBI_SCOPE/* @} *//* * =========================================================================== * $Log: feat_color.cpp,v $ * Revision 1000.1  2004/06/01 20:43:09  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6 * * Revision 1.6  2004/05/21 22:27:39  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.5  2004/04/02 21:07:44  rsmith * default color for genes made a darker green. * * Revision 1.4  2004/02/05 16:04:36  rsmith * No need to LoadCurrentSettings when used as a base class. * * Revision 1.3  2004/02/02 18:44:17  rsmith * add description to CSettingsSet, constructor and descendants. * * Revision 1.2  2003/12/30 15:00:11  dicuccio * Fixed compiler errors/warnings on MSVC * * Revision 1.1  2003/12/29 14:34:39  rsmith * split out from feat_config.cpp * * * =========================================================================== */

⌨️ 快捷键说明

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