taxplot3d_ds.cpp
来自「ncbi源码」· C++ 代码 · 共 215 行
CPP
215 行
/* * =========================================================================== * PRODUCTION $Log: taxplot3d_ds.cpp,v $ * PRODUCTION Revision 1000.1 2004/06/01 21:13:43 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7 * PRODUCTION * =========================================================================== *//* $Id: taxplot3d_ds.cpp,v 1000.1 2004/06/01 21:13:43 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: Vladimir Tereshkov * * File Description: * Datasource for taxplot3d viewer. */#include <ncbi_pch.hpp>#include <corelib/ncbiobj.hpp>#include <corelib/ncbistd.hpp>#include <gui/widgets/taxplot3d/taxplot3d_ds.hpp>BEGIN_NCBI_SCOPEtemplate<class T> struct SNormalizeTo : public unary_function<T, void>{ SNormalizeTo(float & value) : normValue(value) {} void operator() (T & x) { x.getXYZ() /= normValue; } float normValue; };template<class T> struct SReshapeTo : public unary_function<T, void>{ SReshapeTo(typename T::EShape value) : m_Shape(value) {} void operator() (T & x) { x.setShape(m_Shape); } typename T::EShape m_Shape;};template<class T> struct SSetSelection : public unary_function<T, void>{ SSetSelection(bool sel) : m_Select(sel) {} void operator() (T & x) { x.doSelect(m_Select); } bool m_Select;};template <class T> struct SBiggerVertex : public binary_function<T, T, bool>{ bool operator() (const T & vert1, const T & vert2) { return vert1.getXYZ().Length2() < vert2.getXYZ().Length2(); } };CTaxplot3dDataSource :: CTaxplot3dDataSource() : m_Xlabel("X"), m_Ylabel("Y"), m_Zlabel("Z"){ clear();}CTaxplot3dDataSource :: ~CTaxplot3dDataSource(){ clear();}void CTaxplot3dDataSource :: clear(void){ m_Data.clear(); m_Filters.clear();}void CTaxplot3dDataSource :: addVertex(TVertex & vert){ m_Data.push_back(vert);}void CTaxplot3dDataSource :: addVertex(TVertex * vert){ m_Data.push_back(*vert);} void CTaxplot3dDataSource :: doVisibleAt(int i, bool flag){ m_Data[i].doVisible(flag);}void CTaxplot3dDataSource :: doSelectAt(int i, bool flag){ m_Data[i].doSelect(flag);}vector<CTaxplot3dDataSource::TVertex> & CTaxplot3dDataSource :: getData(void){ return m_Data;}CTaxplot3dDataSource::TVertex & CTaxplot3dDataSource :: getVertexAt(int i){ return m_Data[i];}CTaxplot3dDataSource * CTaxplot3dDataSource :: normalizeAll(void){ if (m_Data.size()>0){ applyFiltering(); m_Scale = sqrt(max_element(m_Data.begin(), m_Data.end(), SBiggerVertex<CTaxplot3dDataSource::TVertex>())->getXYZ().Length2()); for_each(m_Data.begin(), m_Data.end(), SNormalizeTo<TVertex>(m_Scale)); } return this;}void CTaxplot3dDataSource::addDatasource(CTaxplot3dDataSource & ds){ vector<TVertex>::size_type size = m_Data.size(); m_Data.resize(size + ds.getData().size()); copy(ds.getData().begin(), ds.getData().end(), m_Data.begin()+size);}void CTaxplot3dDataSource::addDatasource(CTaxplot3dDataSource * ds){ vector<TVertex>::size_type size = m_Data.size(); m_Data.resize(size + ds->getData().size()); copy(ds->getData().begin(), ds->getData().end(), m_Data.begin()+size);}void CTaxplot3dDataSource::reshapeAll(TVertex::EShape shp){ for_each(m_Data.begin(), m_Data.end(), SReshapeTo<TVertex>(shp)); }void CTaxplot3dDataSource::applyFiltering(void){ int cutoff = 20; sort(m_Data.begin(), m_Data.end(), SBiggerVertex<CTaxplot3dDataSource::TVertex>()); m_Data.resize(m_Data.size()-cutoff); m_Data.erase(m_Data.begin(), m_Data.begin()+cutoff); }void CTaxplot3dDataSource::dropSelection(void){ for_each(m_Data.begin(), m_Data.end(), SSetSelection<TVertex>(false)); }END_NCBI_SCOPE/* * =========================================================================== * $Log: taxplot3d_ds.cpp,v $ * Revision 1000.1 2004/06/01 21:13:43 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/01/28 19:54:03 ucko * SBiggerVertex: allow const arguments. * * Revision 1.5 2004/01/28 15:50:27 tereshko * Added scale, current gi, to display tooltips in graph * * Revision 1.4 2004/01/21 14:16:30 dicuccio * Adjusted API to be more coding standard compliant. * * Revision 1.3 2004/01/14 20:33:24 ucko * Add "typename" in a couple of places to fix GCC (at least) build. * * Revision 1.2 2004/01/14 16:39:22 tereshko * Minor changes due to integration with Taxplot viewer * * Revision 1.1 2004/01/05 16:20:49 tereshko * Initial revision * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?