/***************************************************************************** # Copyright (C) 1994-2008 by David Gordon. # All rights reserved. # # This software is part of a beta-test version of the Consed/Autofinish # package. It should not be redistributed or # used for any commercial purpose, including commercially funded # sequencing, without written permission from the author and the # University of Washington. # # This software is provided ``AS IS'' and any express or implied # warranties, including, but not limited to, the implied warranties of # merchantability and fitness for a particular purpose, are disclaimed. # In no event shall the authors or the University of Washington be # liable for any direct, indirect, incidental, special, exemplary, or # consequential damages (including, but not limited to, procurement of # substitute goods or services; loss of use, data, or profits; or # business interruption) however caused and on any theory of liability, # whether in contract, strict liability, or tort (including negligence # or otherwise) arising in any way out of the use of this software, even # if advised of the possibility of such damage. # # Building Consed from source is error prone and not simple which is # why I provide executables. Due to time limitations I cannot # provide any assistance in building Consed. Even if you do not # modify the source, you may introduce errors due to using a # different version of the compiler, a different version of motif, # different versions of other libraries than I used, etc. For this # reason, if you discover Consed bugs, I can only offer help with # those bugs if you first reproduce those bugs with an executable # provided by me--not an executable you have built. # # Modifying Consed is also difficult. Although Consed is modular, # some modules are used by many other modules. Thus making a change # in one place can have unforeseen effects on many other features. # It may takes months for you to notice these other side-effects # which may not seen connected at all. It is not feasable for me to # provide help with modifying Consed sources because of the # potentially huge amount of time involved. # #*****************************************************************************/ #ifndef TEDWIN_INCLUDED #define TEDWIN_INCLUDED #include "sysdepend.h" #include "teditor_types.h" #include "locatedFragment.h" #include "filename.h" #include "guitedwin.h" #include "whatToDoWithSelectionTypes.h" #include "rwtptrvector.h" class Teditor; class ContigWin; class TraceFile; class GuiColorText; class GuiTedWin; class Ntide; // // when the user clicks on a fragment to create a Tedwin, the base // they click upon will be appear this many bases from the left // edge of the TedWin, or roughly in the middle of the window. // static const int nOffsetToPutBaseInTheMiddle = 12; class TedWin { public: TedWin(Teditor*, // parent Teditor object const int, // base position LocatedFragment*, // loc frag to display/edit const int nPositionOnTeditor, const bool bAddToScrollingWindow ); ~TedWin(); // keeping Rogue Wave happy... // for our purposes, two different TedWins can never be equal bool operator == (const TedWin& rTed) const { return (this == &rTed); } // return pointer to your parent TedWin Teditor* pTeditorGet() { return pTeditor_; } // get pointer to the ContigWin that created you from your parent Teditor ContigWin* pContigWinGet(); // return pointer to your corresponding located fragment LocatedFragment* pLocFragGet() { return pLocatedFragment_; } // get pointer to the TraceFile object that contains the traces, // called bases. Get it from LocatedFragment instead of // duplicating the pointer in your own member data TraceFile* pTraceFileGet() { return pLocatedFragment_->pTraceFileGet(); } GuiColorText* pGetGuiColorTextForCalledBase( char cBase ); GuiColorText* pGetGuiColorTextForSameAsContigWin( int nConsensusPos ); GuiColorText* pGetGuiColorTextForTag( const int nConsPos ); // convenience wrapper int nGetTraceValue( const char c, const int nPoint ) { return pTraceFileGet()->nGetTraceValue( c, nPoint ); } // another convenience wrapper. // what is the number of points in the trace arrays? // this is needed (for example) to complement point positions int nGetNumberOfPoints() { return pTraceFileGet()->nGetNumberOfPoints(); } // uses above to actually complement the passed by reference point // position void complementPointPosition(int& nPointPos) { nPointPos = nGetNumberOfPoints() - nPointPos - 1; } void drawTraces(); // callback for scrollbar void userMovedScrollBar( const int nNewScrollBarPosition ); void userChangedHorizontalMagnification(); // can be used for scrolling under program control or due to user // moving scroll bar void scrollTedWin( const int nNewScrollBarPosition ); // passed a consensus position, will scroll the TedWin to the // appropriate point position. if the consensus position is // outside the range of the fragment scrolls to the end i.e. // as close as it can get. this relies on the Fragment // member fun to translate from consensus pos to point pos. void scrollToConsPos(const int nConsPos); void scrollToConsPosAndRefresh( const int nConsPos ); void scrollToConsPosInCenter( const int nConsPos ); // general purpose refresh. draw everything. void drawBasesAndTraces( const bool bRecalculateBasePositions ); // special case of refresh - after complementation of // the Fragment and TraceFile to which object corresponds, // scrolling is required to put the same dna in view at // its new position void refreshAfterCompContig(); // these calls handle user mouse input to select a new base segment void continueHighlight( const int nPoint ); void startHighlight( const int nPoint ); void drawHighlightedRegion(); void automaticScrollingTimer(); void automaticallyScroll(); // highlights the region of the editable bases line void drawHighlightedBases(const int nCalledBaseLeftIndex, const int nCalledBaseRightIndex); void highlightFinished(); void userPressedHotKey( const etypeWhatToDoWithSelection eAction ); void userPressedUserDefinedKey( const RWCString& soProgram, const RWCString& soArgument, const RWCString& soTagToApply ); // by clicking on the fragment ntide with (currently) MB1 the // user can set the cursor to that base. passed point position. void setFragCursor(const int nPoint); // ditto for consensus void setConsCursor(const int nPoint); // // there are two versions of the calls to draw particular // windows. one has no args, the other has the consensus // positions as args. if you do not pass them, they will // be (re)calculated. the two versions are _equivalent_, // but using the one with params (if they have already been // calculated) is more efficient. // // passed starting and stopping positions in terms of indices into // array of originally called bases, draws those bases on the TedWin // in appropriate place and color. void drawCalledBases(const int nCalledPosMin, const int nCalledPosMax, const eTeditorType eTeditorTypee); void drawCalledBases(const eTeditorType eTeditorTypee); // recalculate range // passed the starting and stopping positions in terms of consensus // position, draws the consensus bases on the TedWin in appropriate // place and color void drawConsensusBases(const int nConsPosMin, const int nConsPosMax); void drawConsensusBases(); // recalculate range // passed the starting and stopping positions in terms of consensus // position, draws the fragment bases on the TedWin in appropriate // place and color void drawFragmentBases(const int nConsPosMin, const int nConsPosMax); void drawFragmentBases(); // recalculate range // draws the scale on the TedWin using passed consensus range void drawScale(const int nConsPosMin, const int nConsPosMax, const bool bDrawInShowAllTracesConsensusWindow, const bool bDrawConsensusPositions ); void drawScale( const bool bDrawInShowAllTracesConsensusWindow, const bool bDrawConsensusPositions ); // recalculate range // if passed true, draw the cursor at the current position // if passed false, draw the normal (non-cursor) background again // checks first to see if cursor is valid and in view void drawCursor(const bool bMakeVisible); // sets the read sense arrow (next to file name) according // to fragments bComp() void updateReadSense(); // gets an overstrike edit event message from the Gui, passes // it along to the ConsEd after consulting the EditCursor // (and not the event's x,y coords) to see where it should go void userOverstruckNtide(const char c); // gets an "insert-column-of-pads" message from the Gui, passes // it along to the ConsEd after consulting the EditCursor // (and not the event's x,y coords) to see where it should go void insertColumnOfPads(); // set the Undo button to active or inactive according to whether // or not this TedWin initiated the last edit void setUndoButtonState(); void setBasePixelPositions(); GuiTedWin* pGetGuiTedWin() { return( pGuiTedWin_ ); } bool bScrolledOffScreen(); void clearTedWin(); // clears everything--used when scrolled off the screen void loadGuiColorTextArrayForTags( const int nConsPosMin, const int nConsPosMax ); void popupTags( const int nPixelX ); void drawVerticalLineThroughTraces( const int nConsPos ); void drawVerticalLineThroughTraces(); void prepareToShowAllTraces(); void userPushedArrowKey( const bool bLeftArrowNotRightArrow ); bool bCursorVisible(); // the contig is available via the LocatedFragment Contig* pGetContig() { return pLocatedFragment_->pGetContig(); } public: // pointer to your parent Teditor object Teditor* pTeditor_; // pointer to your comanion gui object GuiTedWin* pGuiTedWin_; // pointer to the located fragment you display and edit LocatedFragment* pLocatedFragment_; // this flag is used to indicate that this TedWin has just // created an edit action. when the message comes back from // the consed to deactivate all other undo buttons, this // one gets activated instead but this flag is cleared. bool bJustCreatedEditAction_; RWTPtrVector aGuiColorTextArray_; int nLeftMostConsPos_; // used for calculating the index into // aGuiColorTextArray_ private: // passed the (fragment relative and necessarily unpadded) index of // the originally called base, returns the ntide and its // GuiColorText void getCalledBaseAndColor(const int nFragPos, bool& bIsPad, char& cBase, GuiColorText*& pGuiColorText, int& nPointPos, const eTeditorType eTeditorTypee); // passed the consensus relative index of the fragment base, // return it's ntide and GuiColorText void getFragBaseAndColor(int nConsensusPos, Ntide& nt, GuiColorText*& pGuiColorText); void getColorForTag( const int nConsPos, GuiColorText*& pGuiColorText ); // passed the consensus relative index of the fragment base, // return it's ntide and highlighted GuiColorText void getHighlightedBaseAndColor(int nConsensusPos, Ntide& nt, GuiColorText*& pGuiColorText); void askUserWhatToDoWithSelection( etypeWhatToDoWithSelection& eWhatToDoWithSelection, RWCString& soTagComment ); bool bMustLoadGuiColorTextArrayForTags(); }; // class TedWin #endif