📄 sequence_display.hpp
字号:
/* * =========================================================================== * PRODUCTION $Log: sequence_display.hpp,v $ * PRODUCTION Revision 1000.1 2004/04/12 17:33:23 gouriano * PRODUCTION PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.28 * PRODUCTION * =========================================================================== *//* $Id: sequence_display.hpp,v 1000.1 2004/04/12 17:33:23 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: Paul Thiessen** File Description:* Classes to hold rows in a sequence/alignment display** ===========================================================================*/#ifndef CN3D_SEQUENCE_DISPLAY__HPP#define CN3D_SEQUENCE_DISPLAY__HPP#include <corelib/ncbistd.hpp>#include <corelib/ncbistl.hpp>#include <map>#include "viewable_alignment.hpp"#include "block_multiple_alignment.hpp"#include "sequence_set.hpp"BEGIN_SCOPE(Cn3D)typedef std::map < BlockMultipleAlignment *, BlockMultipleAlignment * > Old2NewAlignmentMap;////////////////////////////////////////////////////////////////////////////////// The sequence view is composed of rows which can be from sequence, alignment,// or any string - anything derived from DisplayRow.////////////////////////////////////////////////////////////////////////////////class DisplayRow{public: virtual int Width(void) const = 0; virtual bool GetCharacterTraitsAt(int column, BlockMultipleAlignment::eUnalignedJustification justification, char *character, Vector *color, bool *drawBackground, Vector *cellBackgroundColor) const = 0; virtual bool GetSequenceAndIndexAt(int column, BlockMultipleAlignment::eUnalignedJustification justification, const Sequence **sequence, int *index) const = 0; virtual const Sequence * GetSequence(void) const = 0; virtual void SelectedRange(int from, int to, BlockMultipleAlignment::eUnalignedJustification justification, bool toggle) const = 0; virtual DisplayRow * Clone(const Old2NewAlignmentMap& newAlignments) const = 0;};class DisplayRowFromAlignment : public DisplayRow{public: int row; BlockMultipleAlignment * const alignment; DisplayRowFromAlignment(int r, BlockMultipleAlignment *a) : row(r), alignment(a) { } int Width(void) const { return alignment->AlignmentWidth(); } DisplayRow * Clone(const Old2NewAlignmentMap& newAlignments) const { return new DisplayRowFromAlignment(row, newAlignments.find(alignment)->second); } bool GetCharacterTraitsAt(int column, BlockMultipleAlignment::eUnalignedJustification justification, char *character, Vector *color, bool *drawBackground, Vector *cellBackgroundColor) const; bool GetSequenceAndIndexAt(int column, BlockMultipleAlignment::eUnalignedJustification justification, const Sequence **sequence, int *index) const { bool ignore; return alignment->GetSequenceAndIndexAt(column, row, justification, sequence, index, &ignore); } const Sequence * GetSequence(void) const { return alignment->GetSequenceOfRow(row); } void SelectedRange(int from, int to, BlockMultipleAlignment::eUnalignedJustification justification, bool toggle) const { alignment->SelectedRange(row, from, to, justification, toggle); }};class DisplayRowFromSequence : public DisplayRow{public: const Sequence * const sequence; const int fromIndex, toIndex; DisplayRowFromSequence(const Sequence *s, int from, int to); int Width(void) const { return toIndex - fromIndex + 1; } DisplayRow * Clone(const Old2NewAlignmentMap& newAlignments) const { return new DisplayRowFromSequence(sequence, fromIndex, toIndex); } bool GetCharacterTraitsAt(int column, BlockMultipleAlignment::eUnalignedJustification justification, char *character, Vector *color, bool *drawBackground, Vector *cellBackgroundColor) const; bool GetSequenceAndIndexAt(int column, BlockMultipleAlignment::eUnalignedJustification justification, const Sequence **sequenceHandle, int *index) const; const Sequence * GetSequence(void) const { return sequence; } void SelectedRange(int from, int to, BlockMultipleAlignment::eUnalignedJustification justification, bool toggle) const;};class DisplayRowFromString : public DisplayRow{public: const std::string title; std::string theString; const Vector stringColor, backgroundColor; const bool hasBackgroundColor; BlockMultipleAlignment * const alignment; DisplayRowFromString(const std::string& s, const Vector color = Vector(0,0,0.5), const std::string& t = "", bool hasBG = false, Vector bgColor = Vector(1,1,1), BlockMultipleAlignment *a = NULL) : theString(s), stringColor(color), title(t), hasBackgroundColor(hasBG), backgroundColor(bgColor), alignment(a) { } int Width(void) const { return theString.size(); } DisplayRow * Clone(const Old2NewAlignmentMap& newAlignments) const { return new DisplayRowFromString( theString, stringColor, title, hasBackgroundColor, backgroundColor, alignment ? newAlignments.find(alignment)->second : NULL); } bool GetCharacterTraitsAt(int column, BlockMultipleAlignment::eUnalignedJustification justification, char *character, Vector *color, bool *drawBackground, Vector *cellBackgroundColor) const; bool GetSequenceAndIndexAt(int column, BlockMultipleAlignment::eUnalignedJustification justification, const Sequence **sequenceHandle, int *index) const { return false; } const Sequence * GetSequence(void) const { return NULL; } void SelectedRange(int from, int to, BlockMultipleAlignment::eUnalignedJustification justification, bool toggle) const { } // do nothing};////////////////////////////////////////////////////////////////////////////////// The SequenceDisplay is the structure that holds the DisplayRows of the view.// It's also derived from ViewableAlignment, in order to be plugged into a// SequenceViewerWidget.////////////////////////////////////////////////////////////////////////////////class SequenceViewer;class UpdateViewer;class ViewerWindowBase;class Molecule;class SequenceDisplay : public ViewableAlignment{ friend class SequenceViewer; friend class UpdateViewer;public: SequenceDisplay(bool editable, ViewerWindowBase* const *parentViewerWindow); ~SequenceDisplay(void); // these functions add a row to the end of the display, from various sources void AddRowFromAlignment(int row, BlockMultipleAlignment *fromAlignment); void AddRowFromSequence(const Sequence *sequence, int from, int to); void AddRowFromString(const std::string& anyString);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -