TreeViewMain.cpp
上传用户:szb0815
上传日期:2007-06-13
资源大小:338k
文件大小:47k
- /*
- Software and source code Copyright (C) 1998-2000 Stanford University
- Written by Michael Eisen (eisen@genome.stanford.edu)
- This software is copyright under the following conditions:
- Permission to use, copy, and modify this software and its documentation
- is hereby granted to all academic and not-for-profit institutions
- without fee, provided that the above copyright notice and this permission
- notice appear in all copies of the software and related documentation.
- Permission to distribute the software or modified or extended versions
- thereof on a not-for-profit basis is explicitly granted, under the above
- conditions. However, the right to use this software in conjunction with
- for profit activities, and the right to distribute the software or modified or
- extended versions thereof for profit are *NOT* granted except by prior
- arrangement and written consent of the copyright holders.
- Use of this source code constitutes an agreement not to criticize, in any
- way, the code-writing style of the author, including any statements regarding
- the extent of documentation and comments present.
- The software is provided "AS-IS" and without warranty of ank kind, express,
- implied or otherwise, including without limitation, any warranty of
- merchantability or fitness for a particular purpose.
- In no event shall Stanford University or the authors be liable for any special,
- incudental, indirect or consequential damages of any kind, or any damages
- whatsoever resulting from loss of use, data or profits, whether or not
- advised of the possibility of damage, and on any theory of liability,
- arising out of or in connection with the use or performance of this software.
- This code was written using Borland C++ Builder 4 (Inprise Inc., www.inprise.com)
- and may be subject to certain additional restrictions as a result.
- */
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include <dir.h>
- #pragma hdrstop
- #include "TreeViewMain.h"
- #include "LoadingForm.h"
- #include "Options.h"
- #include "URLLabel.h"
- #include "Find.h"
- #include "treeviewhelp.h"
- #include "treeviewabout.h"
- #include "Splash.h"
- #include "SavePSAll.h"
- #include "SaveNodeForm.h"
- #include "URLMemo.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TTreeViewMainForm *TreeViewMainForm;
- //---------------------------------------------------------------------------
- __fastcall TTreeViewMainForm::TTreeViewMainForm(TComponent* Owner)
- : TForm(Owner)
- {
- //TSplashForm *Splash = new TSplashForm(this);
- //Splash->ShowModal();
- Version = "1.47";
- try
- {
- NMHTTP1->Get("http://rana.stanford.edu/software/treeviewversion.html");
- }
- catch (Exception &E)
- {
- }
- if (AnsiString(NMHTTP1->Body) != "")
- {
- if (Version != (AnsiString(NMHTTP1->Body)).SubString(0,Version.Length()) )
- {
- TreeViewMainForm->Caption = "Tree View - Version " + AnsiString(NMHTTP1->Body) +
- " now available at http://rana.stanford.edu/software";
- }
- else
- {
- TreeViewMainForm->Caption = "Tree View";
- }
- }
- else
- {
- TreeViewMainForm->Caption = "Tree View - Check for updates http://rana.stanford.edu/software";
- }
- // TGeneCluster is the class for all expression data and tree data
- Cluster = new TGeneCluster();
- // Default pixel size for each datapoint in small image
- ImageScaleX = 3;
- ImageScaleY = 3;
- ZoomImageScaleX = 12;
- ZoomImageScaleY = 12;
- CorrSelectCutoff = 0.8;
- ImageContrast = 3;
- MaskVal = 0;
- // TreeImage->Canvas->Pen->Mode = pmCopy;
- /* The left side is two images
- TreeImage is the image of the tree
- SmallGeneImage is the image of the entire expression data
- */
- // Default sizes
- OverviewScrollBox->Width = 500;
- OverviewPanel->Width = OverviewScrollBox->ClientWidth;
- OverviewPanel->Height = OverviewScrollBox->ClientHeight;
- SmallGeneImage->Width = 100;
- SmallGeneImage->Left = OverviewScrollBox->ClientWidth - SmallGeneImage->Width -1;
- TreeImage->Width = SmallGeneImage->Left - 1;
- //ZoomPanel->Width = ZoomScrollBox->ClientWidth;
- //ZoomPanel->Height = ZoomScrollBox->ClientHeight;
- NegativeColor = RGB(0,255,0);
- ZeroColor = RGB(0,0,0);
- PositiveColor = RGB(255,0,0);
- MissingColor = RGB(100,100,100);
- GeneLabels = new TStringList();
- LastIndex = -1;
- URLStrings = new TStringList();
- try
- {
- URLStrings->LoadFromFile("URLStrings.txt");
- }
- catch (Exception &E)
- {
- }
- ArrayTreeSplitter->Visible = false;
- ArrayTreePanel->Height = 0;
- TRegistry *Registry = new TRegistry();
- Registry->RootKey = HKEY_CURRENT_USER;
- Registry->OpenKey("Software\Stanford\TreeView\ImageSettings",true);
- try
- {
- ImageScaleX = Registry->ReadInteger("ImageScaleX");
- }
- catch (Exception &E)
- {
- ImageScaleX = 3;
- }
- try
- {
- ImageScaleY = Registry->ReadInteger("ImageScaleY");
- }
- catch (Exception &E)
- {
- ImageScaleY = 3;
- }
- Registry->CloseKey();
- Registry->OpenKey("Software\Stanford\TreeView\Directory",true);
- try
- {
- OpenDialog1->InitialDir = Registry->ReadString("LastOpenDirectory");
- }
- catch (Exception &E)
- {
- }
- Registry->CloseKey();
- delete Registry;
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::FormClose(TObject *Sender,
- TCloseAction &Action)
- {
- TRegistry *Registry = new TRegistry();
- Registry->RootKey = HKEY_CURRENT_USER;
- Registry->OpenKey("Software\Stanford\TreeView\ImageSettings",true);
- Registry->WriteInteger("ImageScaleX",ImageScaleX);
- Registry->WriteInteger("ImageScaleY",ImageScaleY);
- Registry->CloseKey();
- Registry->OpenKey("Software\Stanford\TreeView\Directory",true);
- char Drive[3];
- char Dir[260];
- fnsplit(OpenDialog1->FileName.c_str(),Drive,Dir,NULL,NULL);
- AnsiString SaveDir = AnsiString(Drive) + AnsiString(Dir);
- Registry->WriteString("LastOpenDirectory",SaveDir);
- Registry->CloseKey();
- delete Registry;
- delete Cluster;
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::TreeImageMouseDown(TObject *Sender,
- TMouseButton Button, TShiftState Shift, int X, int Y)
- {
- ResetNode();
- // Set Cluster->BestNode to closest node
- Cluster->Dist(X,Y);
- // Highlight selected node
- MakeZoom();
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::ResetNode()
- {
- if (Cluster->BestNode != NULL)
- {
- TreeImage->Canvas->Pen->Color = clBlack;
- Cluster->BestNode->Draw(TreeImage, ImageScaleY);
- }
- }
- void __fastcall TTreeViewMainForm::MakeZoom()
- {
- TreeImage->Canvas->Pen->Color = clFuchsia;
- if (Cluster->BestNode != NULL)
- {
- Cluster->BestNode->Draw(TreeImage, ImageScaleY);
- NodeBarcodeImage->Height = ZoomImageScaleY + 2;
- Cluster->BestNode->MakeBarcode(NodeBarcodeImage,ZoomImageScaleX,
- ZoomImageScaleY,ImageContrast,
- PositiveColor,ZeroColor,NegativeColor,MissingColor);
- }
- else
- {
- NodeBarcodeImage->Height = 0;
- }
- ZoomBoxShape->Left = SmallGeneImage->Left;
- ZoomBoxShape->Width = SmallGeneImage->Width;
- ZoomBoxShape->Top = (ImageScaleY * Cluster->MinCoor) - 2;
- ZoomBoxShape->Height = (ImageScaleY * (Cluster->MaxCoor - Cluster->MinCoor + 1)) + 4;
- TRect CopyRect, DrawRect;
- // CopyRect is rectangle in unscaled SmallImage
- CopyRect.Left = 0;
- CopyRect.Right = Cluster->Columns;
- CopyRect.Top = Cluster->MinCoor;
- CopyRect.Bottom = Cluster->MaxCoor + 1;
- CentralPanel->Width = Cluster->Columns * ZoomImageScaleX;
- CentralPanel->Height = (Cluster->MaxCoor - Cluster->MinCoor + 1) * ZoomImageScaleY
- + ArrayLabelImage->Height + ArrayTreeImage->Height + NodeBarcodeImage->Height + 10;
- if (CentralScrollBox->ClientWidth > CentralPanel->Width)
- {
- CentralScrollBox->ClientWidth = CentralPanel->Width;
- }
- ZoomImage->Height = ZoomPanel->Height;
- ZoomImage->Width = ZoomPanel->Width;
- ZoomImage->Top = 0;
- ZoomImage->Left = 0;
- ZoomImage->Picture->Bitmap->Height = ZoomImage->Height;
- ZoomImage->Picture->Bitmap->Width = ZoomImage->Width;
- OuterLabelPanel->Top = ZoomPanel->ClientOrigin.y - LabelScrollBox->ClientOrigin.y;
- OuterLabelPanel->Height = ZoomPanel->Height;
- LabelPanel->Height = ZoomPanel->Height;
- LabelPanel->Top = 0;
- DrawRect.Top = 0;
- DrawRect.Left = 0;
- DrawRect.Right = Cluster->Columns * ZoomImageScaleX;
- DrawRect.Bottom = (Cluster->MaxCoor - Cluster->MinCoor + 1) * ZoomImageScaleY;
- ZoomImage->Canvas->Brush->Style = bsSolid;
- ZoomImage->Canvas->Brush->Color = clWhite;
- ZoomImage->Canvas->FillRect(ZoomImage->ClientRect);
- ZoomImage->Canvas->CopyMode = cmSrcCopy;
- ZoomImage->Canvas->CopyRect(DrawRect,SmallGeneImage->Canvas,CopyRect);
- // Label Names
- int i;
- ZoomImage->Canvas->Brush->Style = bsClear; //clear the canvas brush
- ZoomImage->Canvas->Font = ZoomFontDialog->Font;
- ZoomImage->Canvas->Font->Height = - ZoomImageScaleY;
- for (i=0;i<GeneLabels->Count;i++)
- {
- delete GeneLabels->Objects[i];
- }
- GeneLabels->Clear();
- int index;
- TURLLabel *URLLabel;
- int urlindex;
- int MaxLength = 0;
- for (i=Cluster->MinCoor;i<=Cluster->MaxCoor;i++)
- {
- index = GeneLabels->Add(i);
- GeneLabels->Objects[index] = new TURLLabel(this);
- URLLabel = (TURLLabel *) GeneLabels->Objects[index];
- URLLabel->Parent = LabelPanel;
- URLLabel->Visible = true;
- URLLabel->Enabled = true;
- URLLabel->Font = ZoomImage->Canvas->Font;
- URLLabel->Font->Height = ZoomImage->Canvas->Font->Height;
- URLLabel->Top =
- ((i - Cluster->MinCoor) * ZoomImageScaleY);
- URLLabel->Left = 5;
- URLLabel->Width = ClientWidth - LabelPanel->Left;
- URLLabel->Handle = Handle;
- URLLabel->Caption =
- //AnsiString(((TGeneTreeNode *)Cluster->Genes->Objects[i])->Weight) + " " +
- ((TGeneTreeNode *)Cluster->Genes->Objects[i])->Data->Name;
- MaxLength = max(MaxLength,URLLabel->Caption.Length());
- urlindex = URLStrings->IndexOfName(Cluster->UniqueID);
- if ( urlindex > -1)
- {
- AnsiString URL = URLStrings->Values[Cluster->UniqueID];
- AnsiString OldPattern = "UNIQID";
- AnsiString NewPattern = ((TGeneTreeNode *)Cluster->Genes->Objects[i])->Data->ID;
- TReplaceFlags flags;
- flags << rfReplaceAll;
- URLLabel->URL = StringReplace(URL,OldPattern,NewPattern, flags);
- }
- }
- LabelPanel->Width = abs(MaxLength * ZoomImage->Canvas->Font->Height) + 20;
- OuterLabelPanel->Width = LabelPanel->Width;
- if (Cluster->BestNode != NULL)
- {
- TreeViewMainForm->Caption =
- AnsiString("Tree View --- CurrentNode ") + AnsiString(Cluster->BestNode->Data->ID)
- + " --- Correlation " + AnsiString(Cluster->BestNode->Corr);
- }
- else
- {
- TreeViewMainForm->Caption = AnsiString("TreeView");
- }
- }
- void __fastcall TTreeViewMainForm::MakeArrayLabels()
- {
- int i,j;
- ArrayLabelImage->Canvas->Brush->Style = bsSolid;
- ArrayLabelImage->Canvas->Brush->Color = clWhite;
- ArrayLabelImage->Canvas->FillRect(ArrayLabelImage->ClientRect);
- ArrayLabelImage->Canvas->Font = ZoomFontDialog->Font;
- ArrayLabelImage->Canvas->Font->Height = - ZoomImageScaleX;
- ArrayLabelImage->Canvas->Font->Color = clBlack;
- ArrayLabelImage->Canvas->Pen->Color = clBlack;
- LOGFONT lf;
- GetObject(ArrayLabelImage->Canvas->Font->Handle,
- sizeof (LOGFONT), //size of LOGFONT
- &lf);
- lf.lfEscapement = 900; //set to 450 to make 45 degree angle
- lf.lfOrientation = 900;
- lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;
- ArrayLabelImage->Canvas->Font->Handle = CreateFontIndirect (&lf);
- for (j=0;j<Cluster->Columns;j++)
- {
- ArrayLabelImage->Canvas->TextOut((j*ZoomImageScaleX), ArrayLabelImage->Height, Cluster->Arrays->Strings[j]);
- }
- }
- void __fastcall TTreeViewMainForm::MakeArrayTree()
- {
- if (Cluster->TopArrayNode != NULL)
- {
- ArrayTreeSplitter->Visible = true;
- if (ArrayTreePanel->Height == 0)
- {
- ArrayTreePanel->Height = 100;
- ArrayTreeImage->Height = 0;
- }
- ArrayTreeImage->Canvas->Brush->Style = bsSolid;
- ArrayTreeImage->Canvas->Brush->Color = clWhite;
- ArrayTreeImage->Canvas->FillRect(ArrayTreeImage->ClientRect);
- Cluster->TopArrayNode->Draw(ArrayTreeImage, ZoomImageScaleX);
- }
- else
- {
- ArrayTreeSplitter->Visible = false;
- ArrayTreePanel->Height = 0;
- ArrayTreeImage->Height = 0;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::Splitter2Moved(TObject *Sender)
- {
- Redo();
- }
- void __fastcall TTreeViewMainForm::Redo()
- {
- //OverviewPanel->Width = OverviewScrollBox->ClientWidth;
- OverviewPanel->Height = SmallGeneImage->Height;
- CentralPanel->Width = Cluster->Columns * ZoomImageScaleX;
- if (Cluster->TopNode != NULL)
- {
- //SmallGeneImage->Left = max(100,OverviewScrollBox->ClientWidth - SmallGeneImage->Width - 1);
- SmallGeneImage->Left = max(50,SmallGeneImage->Left);
- OverviewPanel->Width = max(SmallGeneImage->Left + SmallGeneImage->Width,
- OverviewScrollBox->ClientWidth);
- TreeImage->Width = SmallGeneImage->Left;
- TreeImage->Height = SmallGeneImage->Height;
- TreeImage->Picture->Bitmap->Width = TreeImage->Width;
- TreeImage->Picture->Bitmap->Height = SmallGeneImage->Height;
- }
- else
- {
- TreeImage->Width = 0;
- OverviewScrollBox->ClientWidth = SmallGeneImage->Width;
- OverviewPanel->Width = max(SmallGeneImage->Width,OverviewScrollBox->ClientWidth);
- SmallGeneImage->Left = 0;
- }
- TreeImage->Canvas->FillRect(TreeImage->ClientRect);
- // SmallGeneImage->Left = TreeImage->Width;
- if (Cluster->Loaded)
- {
- if (Cluster->TopArrayNode != NULL)
- {
- Cluster->TopArrayNode->SetCoor();
- }
- TreeImage->Canvas->Pen->Color = clBlack;
- if (Cluster->TopNode != NULL)
- {
- Cluster->TopNode->SetCoor();
- Cluster->TopNode->Draw(TreeImage, ImageScaleY);
- }
- MakeArrayTree();
- MakeArrayLabels();
- ZoomBoxShape->Left = SmallGeneImage->Left;
- ZoomBoxShape->Width = SmallGeneImage->Width;
- ZoomBoxShape->Top = (ImageScaleY * Cluster->MinCoor) - 2;
- ZoomBoxShape->Height = (ImageScaleY * (Cluster->MaxCoor - Cluster->MinCoor + 1)) + 4;
- // Highlight selected node
- if (Cluster->BestNode != NULL)
- {
- TreeImage->Canvas->Pen->Color = clFuchsia;
- Cluster->BestNode->Draw(TreeImage, ImageScaleY);
- }
- }
- }
- void __fastcall TTreeViewMainForm::Reset()
- {
- OverviewPanel->Height = ImageScaleY * Cluster->Genes->Count;
- Cluster->MakeThumbnail(SmallGeneImage,ImageScaleX,ImageScaleY,ImageContrast,MaskVal,
- PositiveColor,ZeroColor,NegativeColor,MissingColor);
- Redo();
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::Splitter1Moved(TObject *Sender)
- {
- // OverviewPanel->Width = OverviewScrollBox->ClientWidth;
- // SmallGeneImage->Left = max(50,OverviewScrollBox->ClientWidth - SmallGeneImage->Width -1);
- Redo();
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::Load1Click(TObject *Sender)
- {
- int i;
- if (OpenDialog1->Execute())
- {
- for (i=0;i<ControlCount;i++)
- {
- if (Controls[i]->Width == 0)
- {
- Controls[i]->Width = 25;
- }
- if (Controls[i]->Width == 0)
- {
- Controls[i]->Height = 25;
- }
- }
- char Drive[3];
- char Dir[260];
- fnsplit(OpenDialog1->FileName.c_str(),Drive,Dir,NULL,NULL);
- OpenDialog1->InitialDir = AnsiString(Drive) + AnsiString(Dir);
- //Loading->Show();
- //TCursor SaveCursor = Screen->Cursor;
- Application->Minimize();
- Application->ProcessMessages();
- //Screen->Cursor = crHourGlass;
- if (Cluster != NULL)
- {
- delete Cluster;
- Cluster = new TGeneCluster();
- }
- else
- {
- Cluster = new TGeneCluster();
- }
- try
- {
- ImageContrast = 2 * Cluster->Load(OpenDialog1->FileName);
- OptionsForm->ImageContrastEdit->Text = ImageContrast;
- OverviewPanel->Height = ImageScaleY * Cluster->Genes->Count;
- Cluster->MakeThumbnail(SmallGeneImage,ImageScaleX,ImageScaleY,ImageContrast,MaskVal,
- PositiveColor,ZeroColor,NegativeColor,MissingColor);
- Redo();
- //Screen->Cursor = SaveCursor;
- //Loading->Close();
- }
- catch (Exception &E)
- {
- }
- Application->Restore();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::Options1Click(TObject *Sender)
- {
- OptionsForm->ShowModal();
- SmallGeneImage->Width = Cluster->Columns * ImageScaleX;
- SmallGeneImage->Height = Cluster->Rows * ImageScaleY;
- Redo();
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::SmallGeneImageMouseDown(TObject *Sender,
- TMouseButton Button, TShiftState Shift, int X, int Y)
- {
- Dragging = true;
- DragRect.Top = Y;
- DragRect.Bottom = Y;
- ZoomBoxShape->Top = DragRect.Top - 2;
- ZoomBoxShape->Height = DragRect.Bottom - DragRect.Top + 4;
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::SmallGeneImageMouseMove(TObject *Sender,
- TShiftState Shift, int X, int Y)
- {
- if (Dragging)
- {
- DragRect.Bottom = Y;
- ZoomBoxShape->Height = DragRect.Bottom - DragRect.Top + 4;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::SmallGeneImageMouseUp(TObject *Sender,
- TMouseButton Button, TShiftState Shift, int X, int Y)
- {
- if (Dragging)
- {
- DragRect.Bottom = Y;
- if (DragRect.Bottom < DragRect.Top)
- {
- int Hold = DragRect.Top;
- DragRect.Top = DragRect.Bottom;
- DragRect.Bottom = Hold;
- }
- if (DragRect.Right < DragRect.Left)
- {
- int Hold = DragRect.Left;
- DragRect.Left = DragRect.Right;
- DragRect.Right = Hold;
- }
- DragRect.Top = max((int)DragRect.Top,0);
- ZoomBoxShape->Height = DragRect.Bottom - DragRect.Top + 4;
- Dragging = false;
- }
- if (Cluster->BestNode != NULL)
- {
- TreeImage->Canvas->Pen->Color = clBlack;
- Cluster->BestNode->Draw(TreeImage, ImageScaleY);
- }
- Cluster->Include(DragRect.Top/ImageScaleY, min(Cluster->Rows-1,(int)(DragRect.Bottom/ImageScaleY)));
- MakeZoom();
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::FormKeyDown(TObject *Sender, WORD &Key,
- TShiftState Shift)
- {
- if ( (Key > 36) && (Key <41) )
- {
- ResetNode();
- switch (Key)
- {
- case 37:
- if (Cluster->BestNode->IsNode)
- {
- Cluster->BestNode = Cluster->BestNode->Child1;
- MakeZoom();
- }
- break;
- case 38:
- if (Cluster->BestNode != Cluster->TopNode)
- {
- Cluster->BestNode = Cluster->BestNode->Parent;
- MakeZoom();
- }
- break;
- case 39:
- if (Cluster->BestNode->IsNode)
- {
- Cluster->BestNode = Cluster->BestNode->Child2;
- MakeZoom();
- }
- break;
- case 40:
- while (Cluster->BestNode->Corr > CorrSelectCutoff)
- {
- Cluster->BestNode = Cluster->BestNode->Parent;
- }
- MakeZoom();
- break;
- default:
- break;
- }
- }
- if (Key == VkKeyScan('n'))
- {
- //NoteForm->Show();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::SaveTreeImage1Click(
- TObject *Sender)
- {
- if (SaveDialog1->Execute())
- {
- TreeImage->Picture->Bitmap->PixelFormat = 6;
- TreeImage->Picture->Bitmap->SaveToFile(SaveDialog1->FileName);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::SaveThumbnailImage1Click(
- TObject *Sender)
- {
- if (SaveDialog1->Execute())
- {
- SmallGeneImage->Picture->Bitmap->PixelFormat = 6;
- SmallGeneImage->Picture->Bitmap->SaveToFile(SaveDialog1->FileName);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::SaveZoomedImage1Click(TObject *Sender)
- {
- if (Cluster->BestNode != NULL)
- {
- char FileRoot[100];
- fnsplit(OpenDialog1->FileName.c_str(),NULL,NULL,FileRoot,NULL);
- SaveDialog1->FileName = AnsiString(FileRoot) + "_" + Cluster->BestNode->Data->ID
- + ".bmp";
- }
- if (SaveDialog1->Execute())
- {
- Graphics::TBitmap *WholeZoomImage = new Graphics::TBitmap();
- WholeZoomImage->PixelFormat = 6;
- WholeZoomImage->Width = ZoomImage->Width + LabelPanel->Width;
- WholeZoomImage->Height = ArrayTreeImage->Height +
- ArrayLabelImage->Height +
- NodeBarcodeImage->Height +
- ZoomImage->Height;
- WholeZoomImage->Height += 20;
- WholeZoomImage->Canvas->CopyMode = cmSrcCopy;
- TRect DestRect;
- DestRect.Top = 0;
- DestRect.Left = 0;
- DestRect.Right = ArrayTreeImage->ClientWidth;
- DestRect.Bottom = ArrayTreeImage->ClientHeight;
- WholeZoomImage->Canvas->CopyRect(DestRect,ArrayTreeImage->Canvas,ArrayTreeImage->ClientRect);
- DestRect.Top = DestRect.Bottom + 3;
- DestRect.Left = 0;
- DestRect.Right = ArrayLabelImage->ClientWidth;
- DestRect.Bottom = DestRect.Top + ArrayLabelImage->ClientHeight;
- WholeZoomImage->Canvas->CopyRect(DestRect,ArrayLabelImage->Canvas,ArrayLabelImage->ClientRect);
- DestRect.Top = DestRect.Bottom + 3;
- DestRect.Left = 0;
- DestRect.Right = NodeBarcodeImage->ClientWidth;
- DestRect.Bottom = DestRect.Top + NodeBarcodeImage->ClientHeight;
- WholeZoomImage->Canvas->CopyRect(DestRect,NodeBarcodeImage->Canvas,NodeBarcodeImage->ClientRect);
- DestRect.Top = DestRect.Bottom + 3;
- DestRect.Left = 0;
- DestRect.Right = ZoomImage->ClientWidth;
- DestRect.Bottom = DestRect.Top + ZoomImage->ClientHeight;
- WholeZoomImage->Canvas->CopyRect(DestRect,ZoomImage->Canvas,ZoomImage->ClientRect);
- DestRect.Left = DestRect.Right;
- DestRect.Right = DestRect.Left + LabelPanel->ClientWidth;
- //WholeZoomImage->Canvas->CopyRect(DestRect,LabelPanel->Canvas,LabelPabel->ClientRect);
- int i,X,Y;
- for (i=Cluster->MinCoor;i<=Cluster->MaxCoor;i++)
- {
- WholeZoomImage->Canvas->Font = ZoomFontDialog->Font;
- WholeZoomImage->Canvas->Font->Height = - ZoomImageScaleY;
- Y = DestRect.Top + ((i - Cluster->MinCoor) * ZoomImageScaleY);
- X = DestRect.Left + 5;
- WholeZoomImage->Canvas->TextOut(X,Y,((TGeneTreeNode *)Cluster->Genes->Objects[i])->Data->Name);
- }
- WholeZoomImage->SaveToFile(SaveDialog1->FileName);
- delete WholeZoomImage;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::ZoomScrollBoxClick(TObject *Sender)
- {
- //GeneInfoForm->Show();
- //GeneInfoForm->Repaint();
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::Find(AnsiString FindString)
- {
- int index = -1;
- int i;
- if ( (FindString.SubString(1,4) == "NODE") && (Cluster->TopNode != NULL) )
- {
- TGeneTreeNode *MatchedNode = Cluster->TopNode->FindNode(FindString);
- if (MatchedNode != NULL)
- {
- ResetNode();
- Cluster->BestNode = MatchedNode;
- Cluster->BestNode->Limits(&Cluster->MinCoor,&Cluster->MaxCoor);
- MakeZoom();
- //TreeViewMainForm->Caption = "Gene Tree View " + Cluster->BestNode->Data->ID + " " + AnsiString(Cluster->BestNode->Corr);
- }
- }
- else
- {
- for (i=LastIndex+1;i<Cluster->GeneNames->Count;i++)
- {
- if ((Cluster->GeneNames->Strings[i].UpperCase()).Pos(FindString.UpperCase()) > 0)
- {
- index = i;
- i = Cluster->GeneNames->Count;
- }
- }
- if (index > -1)
- {
- if (Cluster->BestNode != NULL)
- {
- TreeImage->Canvas->Pen->Color = clBlack;
- Cluster->BestNode->Draw(TreeImage, ImageScaleY);
- }
- Cluster->MinCoor = index;
- Cluster->MaxCoor = index;
- Cluster->Include(index, index);
- MakeZoom();
- }
- LastIndex = index;
- }
- SetOverviewScrollPos();
- }
- void __fastcall TTreeViewMainForm::Gene1Click(TObject *Sender)
- {
- FindForm->Show();
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::Help1Click(TObject *Sender)
- {
- HelpForm->Show();
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::About1Click(TObject *Sender)
- {
- AboutForm->Show();
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::ArrayTreeSplitterMoved(TObject *Sender)
- {
- MakeArrayTree();
- LabelPanel->Top = ArrayLabelImage->Height + ArrayLabelSplitter->Height +
- ArrayTreeImage->Height + ArrayTreeSplitter->Height;
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::ArrayLabelSplitterMoved(TObject *Sender)
- {
- MakeArrayLabels();
- OuterLabelPanel->Top = ArrayLabelImage->Height + ArrayLabelSplitter->Height +
- ArrayTreeImage->Height + ArrayTreeSplitter->Height;
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::ArrayTreePanelResize(TObject *Sender)
- {
- ArrayTreeImage->Picture->Bitmap->Width = ArrayTreePanel->Width;
- ArrayTreeImage->Picture->Bitmap->Height = ArrayTreePanel->Height;
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::ArrayLabelPanelResize(TObject *Sender)
- {
- ArrayLabelImage->Picture->Bitmap->Width = ArrayLabelPanel->Width;
- ArrayLabelImage->Picture->Bitmap->Height = ArrayLabelPanel->Height;
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::ScrollBar1Change(TObject *Sender)
- {
- //CentralPanel->Top = -ScrollBar1->Position;
- ZoomImage->Top = -ScrollBar1->Position;
- LabelPanel->Top = -ScrollBar1->Position;
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::CentralPanelResize(TObject *Sender)
- {
- if (CentralPanel->Height > CentralScrollBox->ClientHeight)
- {
- ScrollBar1->Visible = true;
- ScrollBar1->Min = 0;
- ScrollBar1->Max = CentralPanel->Height -CentralScrollBox->ClientHeight;
- }
- else
- {
- ScrollBar1->Visible = false;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::Splitter3Moved(TObject *Sender)
- {
- SmallGeneImage->Left = Splitter3->Left + Splitter3->Width;
- Redo();
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::SaveList1Click(TObject *Sender)
- {
- if (Cluster->BestNode != NULL)
- {
- char FileRoot[100];
- fnsplit(OpenDialog1->FileName.c_str(),NULL,NULL,FileRoot,NULL);
- SaveListDialog->FileName = AnsiString(FileRoot) + "_" + Cluster->BestNode->Data->ID
- + ".txt";
- }
- if (SaveListDialog->Execute())
- {
- int i;
- TStringList *IDList = new TStringList();
- for (i=Cluster->MinCoor;i<=Cluster->MaxCoor;i++)
- {
- AnsiString ID =
- ((TGeneTreeNode *)Cluster->Genes->Objects[i])->Data->ID;
- IDList->Add(ID);
- }
- IDList->SaveToFile(SaveListDialog->FileName);
- delete IDList;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::SaveData1Click(TObject *Sender)
- {
- if (Cluster->BestNode != NULL)
- {
- char FileRoot[100];
- fnsplit(OpenDialog1->FileName.c_str(),NULL,NULL,FileRoot,NULL);
- SaveDataDialog->FileName = AnsiString(FileRoot) + "_" + Cluster->BestNode->Data->ID
- + ".txt";
- }
- if (SaveDataDialog->Execute())
- {
- int i,j;
- TStringList *DataList = new TStringList();
- AnsiString Line;
- Line = Cluster->UniqueID + "tNAME";
- if (Cluster->UniqueID == "ID")
- {
- Line = "UIDtNAME";
- }
-
- for (j=0;j<Cluster->Columns;j++)
- {
- Line += "t" +
- Cluster->Arrays->Strings[j];
- }
- DataList->Add(Line);
- for (i=Cluster->MinCoor;i<=Cluster->MaxCoor;i++)
- {
- Line =
- ((TGeneTreeNode *)Cluster->Genes->Objects[i])->Data->ID +
- "t" +
- ((TGeneTreeNode *)Cluster->Genes->Objects[i])->Data->Name;
- for (j=0;j<Cluster->Columns;j++)
- {
- Line += "t";
- if (((TGeneTreeNode *)Cluster->Genes->Objects[i])->Data->Mask[j])
- {
- Line += AnsiString(((TGeneTreeNode *)Cluster->Genes->Objects[i])->Data->Data[j]);
- }
- }
- DataList->Add(Line);
- }
- DataList->SaveToFile(SaveDataDialog->FileName);
- delete DataList;
- }
- }
- void __fastcall TTreeViewMainForm::MakeSimplePS()
- {
- if (SavePSDialog->Execute())
- {
- TStringList *File = new TStringList();
- //
- // PostScript Header
- //
- File->Add("%!PS-Adobe-3.0");
- File->Add("%%Creator: GeneClust1.0");
- File->Add("%%CreationDate: Fri Jul 31 12:35:39 1998");
- File->Add("%%Pages: (atend)");
- File->Add("%%EndComments");
- File->Add("%%BeginSetup");
- File->Add("/ln { newpath moveto lineto stroke closepath } bind def");
- File->Add("/tx { newpath moveto show closepath } bind def");
- File->Add("/sl { setlinewidth } def");
- File->Add("/sc { setlinecap } def");
- File->Add("/sr { setrgbcolor } def");
- File->Add("/sf { exch findfont exch scalefont setfont } def");
- File->Add("/tr { translate } def");
- File->Add("/sp { 1 sc 1 sl 0.0 0.0 0.0 sr 18.00000 13.00000 tr 0.96000 0.98205 scale tr } def");
- AnsiString Temp = "/fillbox {newpath moveto " +
- AnsiString(ZoomImageScaleX) + " 0 rlineto 0 " +
- AnsiString(ZoomImageScaleY) + " rlineto -" +
- AnsiString(ZoomImageScaleX) + " 0 rlineto closepath fill} def";
- File->Add(Temp);
- File->Add("%%EndSetup");
- File->Add("%%Page: tree 1");
- File->Add("%%PageResources: (atend)");
- File->Add("%%BeginPageSetup");
- File->Add("/pgsave save def");
- File->Add("%%EndPageSetup");
- File->Add("0 setlinewidth");
- File->Add("/Courier findfont");
- Temp = AnsiString(ZoomImageScaleY) + " scalefont";
- File->Add(Temp);
- File->Add("setfont");
- int i,j,x,y;
- double Red, Green, Blue, Val;
- AnsiString Name;
- for (i=Cluster->MinCoor;i<=Cluster->MaxCoor;i++)
- {
- Name =
- ((TGeneTreeNode *)Cluster->Genes->Objects[i])->Data->Name;
- TReplaceFlags Flags;
- Flags << rfReplaceAll;
- Name = StringReplace(Name,"(","",Flags);
- Name = StringReplace(Name,")","",Flags);
- for (j=0;j<Cluster->Columns;j++)
- {
- x = j * ZoomImageScaleX;
- y = (i - Cluster->MinCoor) * ZoomImageScaleY;
- if (((TGeneTreeNode *)Cluster->Genes->Objects[i])->Data->Mask[j])
- {
- Red = 0.0;
- Green = 0.0;
- Blue = 0.0;
- Val = ((TGeneTreeNode *)Cluster->Genes->Objects[i])->Data->Data[j];
- if (Val > 0)
- {
- Red = max(min(1.0,Val / ImageContrast),0.0);
- }
- else
- {
- Green = max(min(1.0,-Val / ImageContrast),0.0);
- }
- }
- else
- {
- Red = 0.5;
- Green = 0.5;
- Blue = 0.5;
- }
- TFloatFormat Format = ffFixed;
- AnsiString GreenString = FloatToStrF(Green,Format,6,4);
- AnsiString RedString = FloatToStrF(Red,Format,6,4);
- AnsiString BlueString = FloatToStrF(Blue,Format,6,4);
- Temp = RedString + " " + GreenString + " " + BlueString
- + " setrgbcolor";
- File->Add(Temp);
- Temp = AnsiString(x) + " " + AnsiString(y) + " fillbox";
- File->Add(Temp);
- }
- x = ZoomImageScaleX * Cluster->Columns + 10;
- y = (i - Cluster->MinCoor) * ZoomImageScaleY;
- File->Add("0.0 setgray");
- Temp = AnsiString(x) + " " + AnsiString(y) + " moveto";
- File->Add(Temp);
- Temp = "(" + Name + ") show";
- File->Add(Temp);
- }
- //Temp = "%%BoundingBox: 0 0 " + AnsiString(Cluster->Columns * ZoomImageScaleX + 1000) + AnsiString(" ")
- // + AnsiString(ZoomImageScaleY * (Cluster->MaxCoor - Cluster->MinCoor + 1));
- //File->Insert(3,Temp);
- File->SaveToFile(SavePSDialog->FileName);
- delete File;
- }
- }
- void __fastcall TTreeViewMainForm::SavePSAll(AnsiString PSFileName)
- {
- int ScaleX, ScaleY;
- TGeneTreeNode *Node;
- int MinC, MaxC;
- if (SavePSAllForm->UseSelectedCheckBox->Checked == true)
- {
- Node = Cluster->BestNode;
- MinC = Cluster->MinCoor;
- MaxC = Cluster->MaxCoor;
- }
- else
- {
- Node = Cluster->TopNode;
- MinC = 0;
- MaxC = Cluster->Rows-1;
- }
- try
- {
- ScaleX = SavePSAllForm->XBlockSizeEdit->Text.ToInt();
- ScaleY = SavePSAllForm->YBlockSizeEdit->Text.ToInt();
- }
- catch (EConvertError &E)
- {
- ScaleX = 8;
- ScaleY = 8;
- }
- int GeneTreeSize = 200;
- int ArrayTreeSize = 200;
- int GeneNameSize = 0;
- int ArrayNameSize = 0;
- double Factor;
- unsigned char *Color;
- Color = new unsigned char[3];
- DWORD DPositiveColor = ColorToRGB(PositiveColor);
- unsigned char *Positive;
- //Positive = new unsigned char[3];
- Positive = (unsigned char *)&DPositiveColor;
- DWORD DZeroColor = ColorToRGB(ZeroColor);
- unsigned char *Zero;
- //Zero = new unsigned char[3];
- Zero = (unsigned char *)&DZeroColor;
- DWORD DNegativeColor = ColorToRGB(NegativeColor);
- unsigned char *Negative;
- //Negative = new unsigned char[3];
- Negative = (unsigned char *)&DNegativeColor;
- DWORD DMissingColor = ColorToRGB(MissingColor);
- unsigned char *Missing;
- //Missing = new unsigned char[3];
- Missing = (unsigned char *)&DMissingColor;
- TStringList *File = new TStringList();
- //
- // PostScript Header
- //
- File->Add("%!PS-Adobe-3.0");
- File->Add("%%Creator: GeneClust1.0");
- File->Add("%%CreationDate: Fri Jul 31 12:35:39 1998");
- File->Add("%%Pages: (atend)");
- File->Add("%%EndComments");
- File->Add("%%BeginSetup");
- File->Add("/ln { newpath moveto lineto stroke closepath } bind def");
- File->Add("/tx { newpath moveto show closepath } bind def");
- File->Add("/sl { setlinewidth } def");
- File->Add("/sc { setlinecap } def");
- File->Add("/sr { setrgbcolor } def");
- File->Add("/sf { exch findfont exch scalefont setfont } def");
- File->Add("/tr { translate } def");
- File->Add("/sp { 1 sc 1 sl 0.0 0.0 0.0 sr 18.00000 13.00000 tr 0.96000 0.98205 scale tr } def");
- AnsiString Temp = "/fillbox {newpath moveto " +
- AnsiString(ScaleX) + " 0 rlineto 0 " +
- AnsiString(ScaleY) + " rlineto -" +
- AnsiString(ScaleX) + " 0 rlineto closepath fill} def";
- File->Add(Temp);
- File->Add("%%EndSetup");
- File->Add("%%Page: tree 1");
- File->Add("%%PageResources: (atend)");
- File->Add("%%BeginPageSetup");
- File->Add("/pgsave save def");
- File->Add("%%EndPageSetup");
- File->Add("0 setlinewidth");
- File->Add("/Courier findfont");
- Temp = AnsiString(ScaleY) + " scalefont";
- File->Add(Temp);
- File->Add("setfont");
- // Generate Color Diagram
- int i,j,k,x,y;
- int GeneTreeBuffer = 200;
- double Red, Green, Blue, Val;
- AnsiString Name;
- float H,S,B;
- H = 0;
- S = 1.0;
- B = 1.0;
- for (j=0;j<Cluster->Columns;j++)
- {
- x = GeneTreeBuffer + j * ScaleX;
- y = (MaxC-MinC + 2) * ScaleY;
- if (j < 93)
- {
- H = 0;
- }
- else if (j < 154)
- {
- H = 0.2;
- }
- else if (j < 167)
- {
- H = 0.4;
- }
- else if (j < 227)
- {
- H = 0.6;
- }
- else
- {
- H = 0.8;
- }
- if (Cluster->Arrays->Strings[j] != "Blank")
- {
- TFloatFormat Format = ffFixed;
- AnsiString HString = FloatToStrF(H,Format,6,4);
- AnsiString SString = FloatToStrF(S,Format,6,4);
- AnsiString BString = FloatToStrF(B,Format,6,4);
- Temp = HString + " " + SString + " " + BString + " sethsbcolor";
- File->Add(Temp);
- Temp = AnsiString(x) + " " + AnsiString(y) + " fillbox";
- File->Add(Temp);
- }
- else
- {
- //H += .025;
- }
- }
- for (i=0;i<=MaxC-MinC;i++)
- {
- if (SavePSAllForm->SavePictureCheckBox->Checked == true)
- {
- for (j=0;j<Cluster->Columns;j++)
- {
- x = GeneTreeBuffer + j * ScaleX;
- y = (MaxC-MinC - i ) * ScaleY;
- for (k=0;k<3;k++)
- {
- Color[k] = Missing[k];
- }
- Val = 0;
- if (((TGeneTreeNode *)Cluster->Genes->Objects[i+MinC])->Data->Mask[j])
- {
- Val = ((TGeneTreeNode *)Cluster->Genes->Objects[i+MinC])->Data->Data[j];
- if (Val > 0)
- {
- Factor = min(1.0, Val / ImageContrast);
- for (k=0;k<3;k++)
- {
- Color[k] = Factor * Positive[k] + (1.0 - Factor) * Zero[k];
- }
- }
- else
- {
- Factor = min(1.0, -Val / ImageContrast);
- for (k=0;k<3;k++)
- {
- Color[k] = Factor * Negative[k] + (1.0 - Factor) * Zero[k];
- }
- }
- }
- Red = (double) Color[0] / 256.0;
- Green = (double) Color[1] / 256.0;
- Blue = (double) Color[2] / 256.0;
- TFloatFormat Format = ffFixed;
- AnsiString GreenString = FloatToStrF(Green,Format,6,4);
- AnsiString RedString = FloatToStrF(Red,Format,6,4);
- AnsiString BlueString = FloatToStrF(Blue,Format,6,4);
- Temp = RedString + " " + GreenString + " " + BlueString + " setrgbcolor";
- File->Add(Temp);
- /*
- Temp = AnsiString(x) + " " + AnsiString(y) + " fillbox";
- File->Add(Temp); */
- int Size = Val * 100;
- Temp = "newpath " + AnsiString(x) + " " + AnsiString(y) + " moveto " +
- AnsiString(ScaleX) + " 0 rlineto " +
- "0 " + AnsiString(Size) + " rlineto " +
- "-" + AnsiString(ScaleX) + " 0 rlineto closepath fill";
- File->Add(Temp);
- }
- }
- if (SavePSAllForm->SaveGeneLabelsCheckBox->Checked == true)
- {
- Name = ((TGeneTreeNode *)Cluster->Genes->Objects[i+MinC])->Data->Name;
- TReplaceFlags Flags;
- Flags << rfReplaceAll;
- Name = StringReplace(Name,"(","",Flags);
- Name = StringReplace(Name,")","",Flags);
- GeneNameSize = max(ScaleY*Name.Length(),GeneNameSize);
- x = GeneTreeSize + ScaleX * Cluster->Columns + 10;
- y = (MaxC-MinC - i ) * ScaleY;
- File->Add("0.0 setgray");
- Temp = AnsiString(x) + " " + AnsiString(y) + " moveto";
- File->Add(Temp);
- Temp = "(" + Name + ") show";
- File->Add(Temp);
- }
- }
- File->Add("0.0 setgray");
- if (SavePSAllForm->SaveArrayLabelsCheckBox->Checked == true)
- {
- for (j=0;j<Cluster->Columns;j++)
- {
- x = GeneTreeSize + ScaleX * (j + 1);
- y = ((MaxC-MinC)+4)*ScaleY;
- File->Add("newpath");
- File->Add("gsave");
- Temp = AnsiString(x) + " " + AnsiString(y) + " moveto";
- File->Add(Temp);
- File->Add("90 rotate");
- Name = Cluster->Arrays->Strings[j];
- TReplaceFlags Flags;
- Flags << rfReplaceAll;
- Name = StringReplace(Name,"(","",Flags);
- Name = StringReplace(Name,")","",Flags);
- Temp = "(" + Name + ") show";
- File->Add(Temp);
- File->Add("grestore");
- File->Add("closepath");
- ArrayNameSize = max(ScaleY*Name.Length(),ArrayNameSize);
- }
- }
- File->Add("0 setlinewidth");
- File->Add("0.0 setgray");
- if (SavePSAllForm->SaveGeneTreeCheckBox->Checked == true)
- {
- Node->DrawPS(File,0.95 * GeneTreeSize,ScaleY,MaxC);
- }
- File->Add("0 setlinewidth");
- File->Add("0.0 setgray");
- if (SavePSAllForm->SaveArrayTreeCheckBox->Checked == true)
- {
- Cluster->TopArrayNode->DrawPS(File, ScaleX, ArrayTreeSize, GeneTreeSize, ((MaxC)-(MinC)+2)*ScaleY + ArrayNameSize);
- }
- //Temp = "%%BoundingBox: 0 0 " + AnsiString(Cluster->Columns * ScaleX + GeneTreeSize + GeneNameSize) +
- AnsiString(" ") + AnsiString(ScaleY * ((MaxC)-(MinC)+2) + ArrayNameSize + ArrayTreeSize);
- //File->Insert(3,Temp);
- File->SaveToFile(PSFileName);
- delete File;
- }
- void __fastcall TTreeViewMainForm::SavePSClick(TObject *Sender)
- {
- MakeSimplePS();
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::S1Click(TObject *Sender)
- {
- Cluster->TopNode->WriteList(OptionsForm->CorrSelectCutoffEdit->Text.ToDouble());
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::SaveAllPS1Click(TObject *Sender)
- {
- SavePSAllForm->ShowModal();
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::SetOverviewScrollPos()
- {
- int index;
- if (Cluster->BestNode != NULL)
- {
- index = (Cluster->BestNode->MinCoor + Cluster->BestNode->MaxCoor)/2;
- }
- else
- {
- index = (Cluster->MinCoor + Cluster->MaxCoor)/2;
- }
- OverviewScrollBox->VertScrollBar->Position = index * ImageScaleY
- - OverviewScrollBox->Height / 2;
- }
- void __fastcall TTreeViewMainForm::SaveNodeData1Click(TObject *Sender)
- {
- if (Cluster->TopNode != NULL)
- {
- SaveNodeDataForm->ShowModal();
- }
- }
- void __fastcall TTreeViewMainForm::SaveNodeData(AnsiString FileName)
- {
- TStringList *NodeDataList = new TStringList();
- int j;
- AnsiString Line;
- Line = "NODEtNAMEt";
- for (j=0;j<Cluster->Columns;j++)
- {
- Line += "t" +
- Cluster->Arrays->Strings[j];
- }
- double MinCorrVal = SaveNodeDataForm->MinCorr;
- double MaxCorrVal = SaveNodeDataForm->MaxCorr;
- int MinElements = SaveNodeDataForm->MinElements;
- bool SaveChildren = SaveNodeDataForm->SaveChildrenCheckBox->Checked;
- bool SaveList = SaveNodeDataForm->SaveListCheckBox->Checked;
- NodeDataList->Add(Line);
- if ((Cluster->BestNode != NULL) && (SaveNodeDataForm->UseSelectedNodeCheckBox->Checked) )
- {
- Cluster->BestNode->SaveData(NodeDataList,MinCorrVal,MaxCorrVal,MinElements,SaveChildren,SaveList);
- }
- else
- {
- Cluster->TopNode->SaveData(NodeDataList,MinCorrVal,MaxCorrVal,MinElements,SaveChildren,SaveList);
- }
- NodeDataList->SaveToFile(FileName);
- delete NodeDataList;
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::EditURLStringsClick(TObject *Sender)
- {
- URLMemoForm->Show();
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::SaveNotes1Click(TObject *Sender)
- {
- if (NoteSaveDialog->Execute())
- {
- TStringList *OutFile = new TStringList();
- for (int i=0;i<Cluster->Rows;i++)
- {
- AnsiString OutString = ((TGeneTreeNode *)Cluster->Genes->Objects[i])->Data->ID;
- OutString += "t" + ((TGeneTreeNode *)Cluster->Genes->Objects[i])->Data->Note;
- OutFile->Add(OutString);
- }
- OutFile->SaveToFile(NoteSaveDialog->FileName);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::ScrollBar1KeyDown(TObject *Sender,
- WORD &Key, TShiftState Shift)
- {
- FormKeyDown(Sender,Key,Shift);
- }
- //---------------------------------------------------------------------------
- void __fastcall TTreeViewMainForm::AddNotetoDB1Click(TObject *Sender)
- {
- //NoteForm->Show();
- }
- //---------------------------------------------------------------------------