vector_object.cpp
来自「ncbi源码」· C++ 代码 · 共 340 行
CPP
340 行
/* * =========================================================================== * PRODUCTION $Log: vector_object.cpp,v $ * PRODUCTION Revision 1000.2 2004/06/01 21:04:32 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9 * PRODUCTION * =========================================================================== *//* $Id: vector_object.cpp,v 1000.2 2004/06/01 21:04:32 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: Peter Meric * * File Description: * CPVecObj - vector objects - point, polygon, text * CPVecPoint * CPVecLine * CPVecPolygon * CPVecText * */#include <ncbi_pch.hpp>#include <gui/print/vector_object.hpp>BEGIN_NCBI_SCOPECPVecObj::CPVecObj(){}CPVecObj::~CPVecObj(){}CPVecPoint::CPVecPoint(const float* buffer) : m_X(buffer[0]), m_Y(buffer[1]), m_Z(buffer[2]),m_Color(CRgbaColor(buffer + 3, 4)){}CPVecPoint::~CPVecPoint(){}const CRgbaColor& CPVecPoint::GetColor(void) const{ return m_Color;}unsigned int CPVecPoint::GetNumPoints(void) const{ return 1;}bool CPVecPoint::IsFlatColored(void) const{ return true;}void CPVecPoint::PrintTo(CNcbiOstream& strm, short flags) const{ bool need_space = false; if (flags & eCoordX) { strm << m_X; need_space = true; } if (flags & eCoordY) { if (need_space) { strm << " "; } strm << m_Y; need_space = true; } if (flags & eCoordZ) { if (need_space) { strm << " "; } strm << m_Z; }}inline CNcbiOstream& operator<<(CNcbiOstream& strm, const CPVecPoint& p){ p.PrintTo(strm); return strm;}CPVecLine::CPVecLine(const float* buffer): m_P1(buffer), m_P2(buffer + CPVecPoint::kVertexSize){}CPVecLine::~CPVecLine(){}pair<CPVecPoint, CPVecPoint> CPVecLine::GetPoints(void) const{ return make_pair(m_P1, m_P2);}unsigned int CPVecLine::GetNumPoints(void) const{ return 2;}bool CPVecLine::IsFlatColored(void) const{ return true;}void CPVecLine::PrintTo(CNcbiOstream& strm, short flags) const{ strm << '['; m_P1.PrintTo(strm, flags); strm << ", "; m_P2.PrintTo(strm, flags); strm << ']';}CPVecPolygon::CPVecPolygon(int num_vertices, const float* buffer): m_FlatColored(true){ m_Points.reserve(num_vertices); CRgbaColor c; for (int i = 0; i < num_vertices; ++i) { CRef<CPVecPoint> p(new CPVecPoint(buffer)); if (i == 0) { c = p->GetColor(); } else { if ( !(c == p->GetColor()) ) { m_FlatColored = false; } } m_Points.push_back(p); buffer += CPVecPoint::kVertexSize; }}CPVecPolygon::~CPVecPolygon(){}unsigned int CPVecPolygon::GetNumPoints(void) const{ return (unsigned int) m_Points.size();}bool CPVecPolygon::IsFlatColored(void) const{ return m_FlatColored;}CPVecPolygon::iterator CPVecPolygon::begin(void){ return m_Points.begin();}CPVecPolygon::const_iterator CPVecPolygon::begin(void) const{ return m_Points.begin();}CPVecPolygon::iterator CPVecPolygon::end(void){ return m_Points.end();}CPVecPolygon::const_iterator CPVecPolygon::end(void) const{ return m_Points.end();}CPVecPolygon::reverse_iterator CPVecPolygon::rbegin(void){ return m_Points.rbegin();}CPVecPolygon::const_reverse_iterator CPVecPolygon::rbegin(void) const{ return m_Points.rbegin();}CPVecPolygon::reverse_iterator CPVecPolygon::rend(void){ return m_Points.rend();}CPVecPolygon::const_reverse_iterator CPVecPolygon::rend(void) const{ return m_Points.rend();}inline CNcbiOstream& operator<<(CNcbiOstream& strm, const CPVecLine& l){ l.PrintTo(strm); return strm;}CPVecText::CPVecText(const string& text, float position[4], const CRgbaColor& color, const string& font): m_Text(text), m_Color(color), m_Font(font){ for (int i = 0; i < 4; ++i) { m_Position[i] = position[i]; }}CPVecText::~CPVecText(){}string CPVecText::GetText(void) const{ return m_Text;}const float* CPVecText::GetPosition(void) const{ return m_Position;}const CRgbaColor& CPVecText::GetColor(void) const{ return m_Color;}string CPVecText::GetFont(void) const{ return m_Font;}END_NCBI_SCOPE/* * =========================================================================== * $Log: vector_object.cpp,v $ * Revision 1000.2 2004/06/01 21:04:32 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9 * * Revision 1.9 2004/05/21 22:27:50 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.8 2004/01/27 18:45:51 dicuccio * Pass CRgbaColor by const reference * * Revision 1.7 2003/08/15 17:02:16 meric * Updates include paths for print-related files from gui/utils to gui/print * * Revision 1.6 2003/06/19 01:00:27 dicuccio * Minor reformatting change * * Revision 1.5 2003/06/18 17:25:39 meric * Final phase of print reorg: remove dependence on gui/opengl and OpenGL * * Revision 1.4 2003/06/18 16:40:33 meric * First phase of print reorg: remove dependence on gui/opengl and OpenGL * except for class COpenGLPrintBuffer * * Revision 1.3 2003/06/16 19:21:20 meric * Fixed member initialization order in c'tor to match declaration order * * Revision 1.2 2003/06/16 12:44:52 dicuccio * Clean-up after initial commit * * Revision 1.1 2003 / 06 / 13 18:13:56 meric * Initial version * * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?