Skip to content

Commit

Permalink
misc: indenting, const
Browse files Browse the repository at this point in the history
  • Loading branch information
smoe committed Jul 28, 2024
1 parent 345812a commit 0f4839d
Show file tree
Hide file tree
Showing 17 changed files with 212 additions and 141 deletions.
7 changes: 3 additions & 4 deletions src/CGview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void CGdialog::OnCharHook ( wxKeyEvent& event )

//*********

CGview::CGview ( TVector *_v )
CGview::CGview ( TVector const *_v )
{
v = _v ;
itemsShown = false ;
Expand All @@ -156,9 +156,8 @@ CGview::CGview ( TVector *_v )
wxString CGview::getXML()
{
wxBeginBusyCursor() ;
wxString ret ;
wxString bgcol = RGB2string ( backgroundColor ) ;
ret += _T("<?xml version='1.0' encoding='ISO-8859-1'?>\n") ;
wxString ret = _T("<?xml version='1.0' encoding='ISO-8859-1'?>\n") ;
ret += wxString::Format ( _T("<cgview backgroundColor='%s' sequenceLength='%d' height='%d' width='%d'>\n\n") , //backboneRadius='%d'
// radius ,
bgcol.c_str() , v->getSequenceLength() , height , width ) ;
Expand Down Expand Up @@ -304,7 +303,7 @@ wxString CGview::addXMLfeatureSlot ( int dir )
ret = _T("") ;
for ( int b = 0 ; b < vvi[a].size() ; b++ )
{
TVectorItem *i = &v->items[vvi[a][b]] ;
const TVectorItem *i = &v->items[vvi[a][b]] ;
if ( i->getDirection() != dir ) continue ; // Wrong direction
wxString label = i->name ;
if ( label.IsEmpty() ) label = i->desc ;
Expand Down
4 changes: 2 additions & 2 deletions src/CGview.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class CGview
{
public :
CGview ( TVector *_v = NULL ) ; ///< Constructor
CGview ( TVector const *_v = NULL ) ; ///< Constructor
~CGview () {} ; ///< Destructor (empty)

wxString getXML () ; ///< Generates the XML for the vector v and returns it as a wxString
Expand All @@ -28,7 +28,7 @@ class CGview
static wxString RGB2string ( const wxColour& col ) ;
static wxString RGB2string ( const int red , const int green , const int blue ) ;

TVector *v ; ///< Pointer to the TVector structure to export
const TVector * v ; ///< Pointer to the TVector structure to export
int width , height , radius ;
bool useDefaultColors , runCGview , runimageapp , showrestrictionsites , showgc ;
bool itemsShown ;
Expand Down
39 changes: 32 additions & 7 deletions src/ChildBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,16 @@ wxMenuBar *ChildBase::GetMenuBar ()
}


/**
* Not implemented.
*/
void ChildBase::updateToolbar ()
{
}

/**
* Not implemented.
*/
void ChildBase::updateSequenceCanvas ( bool remember ) // Dummy
{
}
Expand Down Expand Up @@ -190,14 +196,17 @@ void ChildBase::Activate ()
myapp()->frame->notifyChildrenChanged() ;
}

// Refresh () ;
// Refresh () ;
}

wxToolBar *ChildBase::GetToolBar ()
wxToolBar *ChildBase::GetToolBar () const
{
return toolbar ;
}

/**
* Not implemented.
*/
void ChildBase::SetIcon ( const wxIcon& icon )
{
}
Expand Down Expand Up @@ -249,16 +258,29 @@ wxString ChildBase::getExportFilters () const
return wildcard ;
}

void ChildBase::doExport ( const wxString& filename , int filter )
/**
* Writes the vector 'vec' to a file.
*
* @param[in] filename - Name/Path to file to write to.
* @param[in] filter
*/
void ChildBase::doExport ( const wxString& filename , const int filter ) const
{
wxFile out ( filename , wxFile::write ) ;
exportVector ( vec , out , filter , filename ) ;
out.Close () ;
}

void ChildBase::exportVector ( TVector *vec , wxFile &out , int filter , const wxString& filename )
/**
* Writes vector 'vec' that is passed as an argument to the file out
*
* @param[in] out - reference to wxFile to which should be written
* @param[in] filter - 0 for GenBank, 1 for plain text, 2 for FASTA, 3 for EMBL, 4 IG, 5 GCview XML
* @filename[in] filename - ignored, except for GCview XML
*/
void ChildBase::exportVector ( const TVector * const vec , wxFile &out , const int filter , const wxString& filename ) const
{
if ( filter == 0 ) // GeneBank
if ( filter == 0 ) // GenBank
{
TGenBank gb ;
wxArrayString ex ;
Expand Down Expand Up @@ -311,7 +333,7 @@ void ChildBase::exportVector ( TVector *vec , wxFile &out , int filter , const w
}
}

void ChildBase::arrangedExport ( wxFile &out , const wxString& n , const wxString& _s , int l )
void ChildBase::arrangedExport ( wxFile &out , const wxString& n , const wxString& _s , int l ) const
{
int sl = l - n.length() ;
wxString s (_s) ;
Expand All @@ -325,7 +347,10 @@ void ChildBase::arrangedExport ( wxFile &out , const wxString& n , const wxStrin
}
}

bool ChildBase::HasUndoData ()
/**
* Returns always false
*/
bool ChildBase::HasUndoData () const
{
return false ;
}
10 changes: 5 additions & 5 deletions src/ChildBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ class ChildBase : public MyChildBase
virtual wxToolBar *CreateToolBar ( const int i , const int j , const wxString& s ) ; ///< Generates the tool bar
virtual void SetMenuBar ( wxMenuBar *menu_bar ) ; ///< Sets the menu bar for the window
virtual wxMenuBar *GetMenuBar () ; ///< Returns a pointer to the menu bar
virtual wxToolBar *GetToolBar () ; ///< Returns a pointer to the tool bar
virtual wxToolBar *GetToolBar () const ; ///< Returns a pointer to the tool bar
virtual void Activate () ; ///< Activates the module (in foreground etc.)
virtual void SetIcon ( const wxIcon& icon ) ; ///< Sets the module icon (unused)
virtual void SetMyMenuBar () ; ///< Sets the menu bar (used for mac version primarily)
virtual bool HasUndoData () ; ///< TRUE if undo button available and active (undo data present)
virtual bool HasUndoData () const ; ///< TRUE if undo button available and active (undo data present)

bool allow_cut , allow_copy , allow_paste , allow_find , allow_save , allow_print , allow_undo ;

Expand All @@ -69,9 +69,9 @@ class ChildBase : public MyChildBase
wxToolBar *toolbar ; ///< Pointer to the window too bar

virtual wxString getExportFilters () const ;
virtual void doExport ( const wxString& filename , int filter ) ; ///< Export data, depending on filename and export type
virtual void exportVector ( TVector *vec , wxFile &out , int filter , const wxString& filename = _T("") ) ; ///< Exports a TVector
virtual void arrangedExport ( wxFile &out , const wxString& n , const wxString& s , int l ) ;
virtual void doExport ( const wxString& filename , const int filter ) const ; ///< Export data, depending on filename and export type
virtual void exportVector ( const TVector * const vec , wxFile &out , const int filter , const wxString& filename = _T("") ) const ; ///< Exports a TVector
virtual void arrangedExport ( wxFile &out , const wxString& n , const wxString& s , int l ) const ;
virtual void updateToolbar () ; ///< Sets the tool bar
} ;

Expand Down
55 changes: 31 additions & 24 deletions src/FindSequenceDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ SequenceCanvas *FindSequenceDialog::getMarkSequence ( wxString &mark ) const
}
return canvas ;
}

void FindSequenceDialog::doAction ( const bool doubleclick )
{
int idx = lb->GetSelection () ;
Expand Down Expand Up @@ -233,6 +234,7 @@ void FindSequenceDialog::doAction ( const bool doubleclick )
}
}
}

void FindSequenceDialog::OnCharHook(wxKeyEvent& event)
{
int k = event.GetKeyCode () ;
Expand All @@ -241,17 +243,17 @@ void FindSequenceDialog::OnCharHook(wxKeyEvent& event)
else if ( k == WXK_F1 ) myapp()->frame->OnHelp ( ev ) ;
else event.Skip() ;
}

int FindSequenceDialog::subsearch ( const wxString &s , const wxRegEx &regex , int start, int& len ) const
{
int a;

if ((regex.Matches(s.Mid(start)))&&
(regex.GetMatch((size_t*)&a,(size_t*)&len)))
if (regex.Matches(s.Mid(start)) && regex.GetMatch((size_t*) &a, (size_t*)&len))
{
return start+a;
}
return -1;
}

void FindSequenceDialog::OnSearch ( wxCommandEvent &ev )
{
status->SetLabel ( txt("t_searching") ) ;
Expand All @@ -261,35 +263,35 @@ void FindSequenceDialog::OnSearch ( wxCommandEvent &ev )
lb->Clear () ;
vi.Clear () ;
if ( cb_sequence && cb_sequence->GetValue() )
{
{
sequenceSearch();
if ( c->def == _T("dna") || c->def == _T("ABIviewer") || c->def == _T("PrimerDesign") )
sequenceSearch ( true );
}
}
//if ( c->def == _T("dna") || c->def == _T("PrimerDesign") )
if ( cb_translation && cb_translation->GetValue() ) aaSearch () ;
if ( cb_items && cb_items->GetValue() ) itemSearch() ;
if ( cb_enzymes && cb_enzymes->GetValue() ) restrictionSearch() ;
if ( !vi.IsEmpty() )
{
{
lb->SetSelection ( 0 ) ;
OnLB ( ev ) ;
}
}
// Status text
if ( lb->GetCount() > FIND_MAX )
{
{
status->SetLabel ( wxString::Format ( txt("t_too_many_search_results") , FIND_MAX ) ) ;
do_highlight->Enable() ;
}
}
else if ( lb->GetCount() == 0 )
{
{
status->SetLabel ( txt("t_no_matches_found") ) ;
}
}
else
{
{
status->SetLabel ( wxString::Format ( txt("t_matches_found") , lb->GetCount() ) ) ;
do_highlight->Enable() ;
}
}
Thaw () ;
wxEndBusyCursor() ;
}
Expand Down Expand Up @@ -320,7 +322,7 @@ void FindSequenceDialog::aaSearch ()

void FindSequenceDialog::aaSubSearch ( const wxString &s , int start , int dir , const wxString& rf )
{
int a, len ;
int len ;
wxChar codon[4] ;
codon[3] = 0 ;
wxString res ;
Expand All @@ -334,7 +336,7 @@ void FindSequenceDialog::aaSubSearch ( const wxString &s , int start , int dir ,
{
for ( start = -start ; start + 3 < s.length() ; start += 3 ) ;
}
for ( a = start ; a + dir * 2 >= 0 && a + dir * 2 < s.length() ; a += dir * 3 )
for ( int a = start ; a + dir * 2 >= 0 && a + dir * 2 < s.length() ; a += dir * 3 )
{
codon[0] = s.GetChar ( a ) ;
codon[1] = s.GetChar ( a + dir ) ;
Expand All @@ -345,13 +347,17 @@ void FindSequenceDialog::aaSubSearch ( const wxString &s , int start , int dir ,
ai.Add ( a ) ;
}
for (int i=0;i<sizeof(AA_SUBS)/(2*sizeof(wxChar*));i++)
{
sub.Replace(AA_SUBS[i][0],AA_SUBS[i][1]);
}
wxLogNull noLog; // Supresses Message Box showing malformed regular expressions
wxRegEx regex(sub);
if (!regex.IsValid())
{
return;
}

a = 0 ;
int a = 0 ;
while ( (a = subsearch ( res , regex , a , len)) != -1 )
{
if ( lb->GetCount() > FIND_MAX ) return ;
Expand All @@ -369,17 +375,17 @@ void FindSequenceDialog::aaSubSearch ( const wxString &s , int start , int dir ,
res.SetChar ( a , '_' ) ; // Invalidating
a++;
}

}

void FindSequenceDialog::itemSearch ()
{
TVector *v = c->vec ;
const TVector * const v = c->vec ;
wxString s = t->GetValue().Upper() ; // Using original input instead of filtered query
for ( int a = 0 ; a < v->items.size() ; a++ )
{
if ( lb->GetCount() > FIND_MAX ) return ;
if ( v->items[a].name.Upper().Find(s) != -1 ||
v->items[a].desc.Upper().Find(s) != -1 )
if ( v->items[a].name.Upper().Find(s) != -1 || v->items[a].desc.Upper().Find(s) != -1 )
{
lb->Append ( wxString::Format ( _T("%s: %s (%d-%d)") ,
txt("t_vec_item").c_str() ,
Expand All @@ -392,7 +398,7 @@ void FindSequenceDialog::itemSearch ()
}
void FindSequenceDialog::restrictionSearch ()
{
TVector *v = c->vec ;
const TVector * const v = c->vec ;
wxString s = getQuery() ;
for ( int a = 0 ; a < v->rc.size() ; a++ )
{
Expand All @@ -411,7 +417,7 @@ void FindSequenceDialog::restrictionSearch ()

void FindSequenceDialog::sequenceSearch ( bool invers )
{
int a, len ;
int len ;
wxString sub = getQuery() ;
if ( sub.IsEmpty() ) return ;
// Preparing sequence
Expand Down Expand Up @@ -445,8 +451,9 @@ void FindSequenceDialog::sequenceSearch ( bool invers )
wxRegEx regex(sub);
if (!regex.IsValid())
return;

// Now we search...
a = 0 ;
int a = 0 ;
while ( (a = subsearch ( s , sub , a, len )) > -1 )
{
if ( lb->GetCount() > FIND_MAX ) return ;
Expand Down Expand Up @@ -476,11 +483,11 @@ void FindSequenceDialog::OnTextChange ( wxCommandEvent &ev )
if ( c->vec->getGenomeMode() ) return ;
int ql = getQuery().length() ;
if ( ql < 3 )
{
{
lb->Clear () ;
vi.Clear () ;
return ;
}
}
find_button->Disable () ;
OnSearch ( ev ) ;
#ifdef __WXMAC__
Expand Down
2 changes: 1 addition & 1 deletion src/ManageDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ bool TManageDatabaseDialog::do_load_DNA ( const wxString& name , const wxString&
}

// Sorting by size, largest first
wxPrintf("D: retrieved %u elements \n", v->items.size() ) ;
wxPrintf("D: retrieved %lu elements \n", v->items.size() ) ;
if ( v->items.size() < 100 ) // Don't do that for genomes!
{
for ( int a = 1 ; a < v->items.size() ; a++ )
Expand Down
13 changes: 6 additions & 7 deletions src/MyFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2338,11 +2338,10 @@ void MyFrame::BollocksMenu(wxCommandEvent& event)
if ( !lastChild )
{
wxPrintf("MyFrame::BollocksMenu - return - !lastChild\n") ;
return ;
}
if ( event.GetId() == MDI_NEXT_WINDOW ||
event.GetId() == MDI_PREV_WINDOW )
{
return ;
}
if ( event.GetId() == MDI_NEXT_WINDOW || event.GetId() == MDI_PREV_WINDOW )
{
int a = getChildIndex ( lastChild ) ;
if ( event.GetId() == MDI_NEXT_WINDOW ) a++ ;
else a-- ;
Expand All @@ -2356,12 +2355,12 @@ void MyFrame::BollocksMenu(wxCommandEvent& event)
}
wxPrintf("MyFrame::BollocksMenu - return - NEXT_WINDOW\n") ;
return ;
}
}
if ( lastChild->def != _T("dna") )
{
wxPrintf("MyFrame::BollocksMenu - return - dna != lastChild->def\n") ;
return ;
}
}
lastChild->ProcessEvent ( event ) ;
}

Expand Down
Loading

0 comments on commit 0f4839d

Please sign in to comment.