//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Design.h" #include "Main_F.h" #include "GuideBar.h" #include "Simulation_F.h" #include "DesignViewForm.h" #include "YarnCompositionData.h" #include "treatment.h" #include "FloatingWin.h" #include "Editor.h" #include "capture.h" #include "jpeg.hpp" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPRuler2D" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_DESIGN StringTable[0] #define IDS_POSITION StringTable[1] #define IDS_VIEW_MENU StringTable[2] #define IDS_INPUT_MENU StringTable[3] #define IDS_OVERLAP StringTable[4] #define IDS_REPEAT StringTable[5] #define IDS_BLACK StringTable[6] #define IDS_GRAY StringTable[7] #define IDS_WHITE StringTable[8] #define IDS_SHOW_DESIGN_VIEWER StringTable[9] #define IDS_VIEW_TEXT StringTable[10] #define IDS_INVERT StringTable[11] #define IDS_PM_REPEAT StringTable[12] #define IDS_SHIFT StringTable[13] #define IDS_ZOOM StringTable[14] #define IDS_UNDO StringTable[15] #define IDS_REDO StringTable[16] #define IDS_START StringTable[17] #define IDS_COPY StringTable[18] #define IDS_SAVE StringTable[19] //--------------------------------------------------------------------------- TDesignForm *DesignForm; //--------------------------------------------------------------------------- __fastcall TDesignForm::TDesignForm(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbOverLapClick(TObject *Sender) { if(cbOverLap->Checked==true){ Main->texlayer->SetVisibleLayer(0, cbLayer1->Checked); Main->texlayer->SetVisibleLayer(1, cbLayer2->Checked); Main->texlayer->SetVisibleLayer(2, cbLayer3->Checked); Main->texlayer->SetVisibleLayer(3, cbLayer4->Checked); } else { Main->UpdateBtn(); } UpdateCheckBox(); DrawChart(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbLayer5Click(TObject *Sender) { UpdateCheckBox(); DrawChart(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbLayer4Click(TObject *Sender) { UpdateCheckBox(); DrawChart(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbLayer3Click(TObject *Sender) { UpdateCheckBox(); DrawChart(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbLayer2Click(TObject *Sender) { UpdateCheckBox(); DrawChart(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbLayer1Click(TObject *Sender) { UpdateCheckBox(); DrawChart(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::RepeatCheckBoxClick(TObject *Sender) { DrawChart(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::edYKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(StrToInt(edY->Text)<1)edY->Text="1"; if(StrToInt(edY->Text)>Main->maindata.course)edY->Text=Main->maindata.course; edXIn->SetFocus(); ChartVScrollBar->Position=ChartVScrollBar->Max-StrToInt(edY->Text)*ChartVScrollBar->Max/Main->maindata.course; } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::edXInKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(StrToInt(edXIn->Text)<0)edXIn->Text="0"; edXVia->SetFocus(); ChartVScrollBar->Position=ChartVScrollBar->Max-StrToInt(edY->Text)*ChartVScrollBar->Max/Main->maindata.course; } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::edXViaKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ Main->Undo->do_(Main->texlayer); if(StrToInt(edXVia->Text)<0)edXVia->Text="0"; int y=StrToInt(edY->Text); Tex *tex = ((Tex *)(Main->texlayer->TexList->Items[Main->LayerNum])); KO *ko=(KO *)tex->Curve->Items[(y-1+tex->Curve->Count)%tex->Curve->Count]; ko->in=StrToInt(edXIn->Text); ko->via=StrToInt(edXVia->Text); int minx,maxx; if(ko->inout&&ko->outvia) ko->out = ko->via-1; else if(ko->in>ko->out&&ko->out>ko->via) ko->out = ko->via+1; minx = min(ko->in,ko->via); maxx = max(ko->in,ko->via); if(ko->out>maxx) ko->out = maxx; else if(ko->outout = minx; tex->Correction(); Main->texlayer->setFocus(min(ko->in,ko->via)+tex->leftShift,y-1); DrawChart(); y++; if(y==Main->maindata.course+1)y=1; edY->Text=IntToStr(y); edXIn->SetFocus(); ChartVScrollBar->Position=ChartVScrollBar->Max-StrToInt(edY->Text)*ChartVScrollBar->Max/Main->maindata.course; } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::cbChartBGColorChange(TObject *Sender) { switch(cbChartBGColor->ItemIndex){ case 0: chartTemp->LoadFromFile(BaseDir + "\\cell.bmp"); break; case 1: chartTemp->LoadFromFile(BaseDir + "\\cellg.bmp"); break; case 2: chartTemp->LoadFromFile(BaseDir + "\\cellw.bmp"); break; default: return; } DrawChart(true); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::sbEnlargeClick(TObject *Sender) { DesignView_F->Visible=!DesignView_F->Visible; if(DesignView_F->Visible){ DesignView_F->Show(Main->texlayer, chartTempL, DistX, DistY); } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartHScrollBarChange(TObject *Sender) { ShowChart(); ChartRuler->StartX=(ChartHScrollBar->Max-ChartHScrollBar->Position); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartVScrollBarChange(TObject *Sender) { ShowChart(); ChartRuler->StartY=this->DistY/2 + (ChartVScrollBar->Max-ChartVScrollBar->Position); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartHScrollBarKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if(Shift.Contains(ssCtrl)){ if(!Shift.Contains(ssShift)&&(Key=='Z'||Key=='z')){ Main->Undo->undo(Main->texlayer); DrawChart(); } else if(Shift.Contains(ssShift)&&(Key=='Z'||Key=='z')){ Main->Undo->redo(Main->texlayer); DrawChart(); } else if(Key=='C'||Key=='c'){ SimulationForm->pmsmToClipBoardClick(NULL); } } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartVScrollBarKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { ChartHScrollBarKeyDown(Sender, Key, Shift); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartRulerMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { int yoff=ChartVScrollBar->Position; int xoff=ChartHScrollBar->Position; Tex *tex = ((Tex *)Main->texlayer->TexList->Items[Main->LayerNum]); RECT r = Rect(0,0,chartTempL->Width, chartTempL->Height); POINT p1 = Chart->ScreenToClient(ChartRuler->ClientToScreen(Point(X,Y))); POINT p2 = Main->texlayer->FindCell2(r, p1.x+xoff, p1.y+yoff, DistX, DistY); tex->leftShift = p2.x; GuideBar_F->UpdateGuideBar(); UpdateEdit(); DrawChart(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartClick(TObject *Sender) { ChartHScrollBar->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { int yoff=ChartVScrollBar->Position; int xoff=ChartHScrollBar->Position; if(Shift.Contains(ssAlt)||Shift.Contains(ssCtrl)) { Main->texlayer->Complex = true; } else { Main->texlayer->Complex = false; } if(Shift.Contains(ssLeft)&&!Shift.Contains(ssShift)&&!RepeatCheckBox->Checked){ Main->Undo->do_(Main->texlayer); } if(Shift.Contains(ssLeft)&&(!RepeatCheckBox->Checked)){ Main->texlayer->LayerMouseDown(Shift, Rect(0,0,chartTempL->Width, chartTempL->Height), X+xoff , Y+yoff, DistX, DistY, Main->LayerNum); Tex *tex = ((Tex *)Main->texlayer->TexList->Items[Main->LayerNum]); int y = ((chartTempL->Height-Y)/DistY)%tex->Curve->Count; KO *ko = (KO *)tex->Curve->Items[y]; edXIn->Text = IntToStr(ko->in); edXVia->Text = IntToStr(ko->via); edY->Text = IntToStr(y+1); DrawChart(); } else if(Shift.Contains(ssLeft)){ Tex *tex = ((Tex *)Main->texlayer->TexList->Items[Main->LayerNum]); WaleState *ws = NULL; if(tex->Wales->Count==0) return; int ion,iotc=0; for(int i=0;iWales->Count;i++){ iotc+=((WaleState *)tex->Wales->Items[i])->cnt; } if(iotc==0&&tex->Wales->Count>0) { return; } POINT p = Main->texlayer->FindCell( Rect(0,0,chartTempL->Width, chartTempL->Height), X+xoff, Y+yoff, DistX, DistY); KO *ko = (KO *)tex->Curve->Items[p.y%tex->Curve->Count]; int x = p.x - tex->leftShift-min(ko->in,ko->via); ion=0; int k; for(int k=0;kWales->Count;k++){ ws=(WaleState *)tex->Wales->Items[k]; int l=x; while(l<0){l+=iotc;} l%=iotc; if( ion<=l && l cnt) ){ if(ws->cnt==1){ ws->in=!ws->in; } else if(ws->cnt>1){ if(ion==l){ WaleState *ws1 = new WaleState; *ws1 = *ws; ws1->cnt=1; ws1->in=!ws->in; tex->Wales->Insert(k,ws1); ws->cnt--; } else if(l==ion+(ws->cnt)-1){ WaleState *ws1 = new WaleState; *ws1 = *ws; ws1->cnt=1; ws1->in=!ws->in; tex->Wales->Insert(k+1,ws1); ws->cnt--; } else { WaleState *ws1 = new WaleState; WaleState *ws2 = new WaleState; int c1=l-ion; int c2=ion+(ws->cnt)-1-l; *ws1 = *ws; *ws2 = *ws; ws->cnt=c1; ws1->cnt=1; ws2->cnt=c2; ws1->in=!ws->in; tex->Wales->Insert(k+1,ws1); tex->Wales->Insert(k+2,ws2); } } arrange_wales(tex); break; } ion+=(ws->cnt); } DrawChart(); } if(CaptureForm->Visible)CaptureForm->update_path(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { int yoff=ChartVScrollBar->Position; int xoff=ChartHScrollBar->Position; static bool isMoving=false; if(isMoving)return; isMoving=true; TCursor cur; if(RepeatCheckBox->Checked){ cur=Screen->Cursor; Screen->Cursor=crHourGlass; } RECT r = Rect(0,0,chartTempL->Width, chartTempL->Height); if( false == Main->texlayer->LayerMouseMove(Shift, r, X+xoff , Y+yoff, DistX, DistY, Main->LayerNum) ){ if(!(RepeatCheckBox->Checked&&Main->texlayer->staticState))DrawChart(); } double CursorX = FindCursorPositionX(r, X+xoff, Y+yoff, DistX, DistY); double CursorY = FindCursorPositionY(r, X+xoff, Y+yoff, DistX, DistY); if(Shift.Contains(ssAlt)||Shift.Contains(ssCtrl)) { ChartStatusBar->Panels->Items[0]->Text="X "+IDS_POSITION+" \"" + IntToStr((int)CursorX)+"\""; Main->texlayer->Complex = true; } else { ChartStatusBar->Panels->Items[0]->Text="X "+IDS_POSITION+" \"" + IntToStr((int)CursorX)+" "+IntToStr((int)CursorX+1)+"\""; Main->texlayer->Complex = false; } ChartStatusBar->Panels->Items[0]->Text += " Y "+IDS_POSITION+" \"" + IntToStr((int)CursorY) + "\""; if(RepeatCheckBox->Checked){ Screen->Cursor=cur; } else { } isMoving=false; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { int yoff=ChartVScrollBar->Position; int xoff=ChartHScrollBar->Position; if(Shift.Contains(ssAlt)||Shift.Contains(ssCtrl)) { Main->texlayer->Complex = true; } else { Main->texlayer->Complex = false; } if(Shift.Contains(ssShift)&&!RepeatCheckBox->Checked){ Main->texlayer->LayerMouseUp(Shift, Rect(0,0,chartTempL->Width, chartTempL->Height), X+xoff , Y+yoff, DistX, DistY, Main->LayerNum); POINT p = Chart->ClientToScreen(Point(X,Y)); ChartPopupMenu->Popup(p.x, p.y); } } //--------------------------------------------------------------------------- bool __fastcall TDesignForm::InitChart(bool reDrawChart){ if(!Main->texlayer)return false; if(!Main->texlayer->TexList)return false; if(Main->texlayer->TexList->Count==0)return false; static bool first=true; if(first||chartTempL->Width!=this->DistX*TEX_MAX_WIDTH||chartTempL->Height!=Main->maindata.course*this->DistY){ first=false; try { chartTempL->Create(this->DistX*TEX_MAX_WIDTH, Main->maindata.course*this->DistY, 24); chartTempL2->Create(this->DistX*TEX_MAX_WIDTH, Main->maindata.course*this->DistY, 24); } catch(...){ Zoom=1; UpdateMenu(); SetDist(); ShowMessage(IDS_MESSAGE_TOO_LARGE_BITMAP_ZOOM); return false; } } RECT r=Rect(0,0,chartTempL->Width,chartTempL->Height); int i,j; int w = (r.right-r.left)/this->DistX; int h = (r.bottom-r.top)/this->DistY; static DistX=0, DistY=0, Course=0; if(reDrawChart||DistX!=this->DistX||DistY!=this->DistY||Course!=Main->maindata.course){ int RULER_THICKNESS=ChartRuler->Thick; OnChangeSize(); if(ChartRuler->Height-RULER_THICKNESS > chartTempL->Height){ ChartRulerPanel->Top=ChartRuler->Top+ChartRuler->Height-chartTempL->Height-RULER_THICKNESS; ChartRulerPanel->Height=ChartRuler->Height+ChartRuler->Top-ChartRulerPanel->Top-RULER_THICKNESS; } else { ChartRulerPanel->Top=ChartRuler->Top; ChartRulerPanel->Height=ChartRuler->Height-RULER_THICKNESS; } if(ChartRuler->Width-RULER_THICKNESS > chartTempL->Width){ ChartRulerPanel->Left=ChartRuler->Left+ChartRuler->Width-chartTempL->Width-RULER_THICKNESS; ChartRulerPanel->Width=ChartRuler->Width+ChartRuler->Left-ChartRulerPanel->Left-RULER_THICKNESS; } else { ChartRulerPanel->Left=ChartRuler->Left; ChartRulerPanel->Width=ChartRuler->Width-RULER_THICKNESS; } ChartRuler->StartY=this->DistY/2; ChartRuler->DPI=this->DistX; Chart->Top=0; Chart->Left=0; Chart->Height=ChartRulerPanel->Height; Chart->Width=ChartRulerPanel->Width; Chart->Picture->Bitmap->Height=ChartRulerPanel->Height; Chart->Picture->Bitmap->Width=ChartRulerPanel->Width; ChartVScrollBar->Max= (chartTempL->Height - Chart->Height > 0) ? (chartTempL->Height - Chart->Height) : 0; ChartHScrollBar->Max= (chartTempL->Width - Chart->Width > 0) ? (chartTempL->Width - Chart->Width) : 0; ChartVScrollBar->Position=ChartVScrollBar->Max; ChartHScrollBar->Position=ChartHScrollBar->Max; HDC dc=chartTempL->CreateDC(); HDC dc2=chartTempL2->CreateDC(); SetStretchBltMode(dc,COLORONCOLOR); for(i=0;iDistX, r.bottom-(j+1)*this->DistY, this->DistX, this->DistY, chartTemp->Canvas->Handle, 0, 0, 20, 20, SRCCOPY); } } BitBlt(dc2, 0, 0, chartTempL->Width, chartTempL->Height, dc, 0, 0, SRCCOPY); chartTempL->DeleteDC(dc); chartTempL2->DeleteDC(dc2); } else { HDC dc=chartTempL->CreateDC(); HDC dc2=chartTempL2->CreateDC(); BitBlt(dc2, 0, 0, chartTempL->Width, chartTempL->Height, dc, 0, 0, SRCCOPY); chartTempL->DeleteDC(dc); chartTempL2->DeleteDC(dc2); } DistX=this->DistX; DistY=this->DistY; Course=Main->maindata.course; return true; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::DrawChart(bool reDrawChart){ if(!InitChart(reDrawChart))return; if(!Main->texlayer)return; HDC dc2=chartTempL2->CreateDC(); Main->texlayer->Draw(dc2, Rect(0,0,chartTempL->Width, chartTempL->Height), DistX, DistY, RepeatCheckBox->Checked==false); chartTempL2->DeleteDC(dc2); ShowChart(); if(GuideBar_F&&GuideBar_F->Visible) GuideBar_F->Repaint(); if(YarnCompositionData_F&&YarnCompositionData_F->Visible) YarnCompositionData_F->Repaint(); Main->UpdateBtn(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::UpdateMenu(){ //¸Þ´º¿Í ÆË¾÷¸Å´º¸¦ ¾÷µ¥ÀÌÆ®ÇÑ´Ù pmcx1over2->Checked=false; pmcx1->Checked=false; switch(Zoom){ case 1: { pmcx1over2->Checked=true; break; } case 2: { pmcx1->Checked=true; break; } default: break; } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::SetDist(){ DistX=10*Zoom; DistY=10*Zoom; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcx1over2Click(TObject *Sender) { Zoom=1; UpdateMenu(); SetDist(); DrawChart(true); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcx1Click(TObject *Sender) { Zoom=2; UpdateMenu(); SetDist(); DrawChart(true); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcUndoClick(TObject *Sender) { Main->Undo->undo(Main->texlayer); DrawChart(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcRedoClick(TObject *Sender) { Main->Undo->redo(Main->texlayer); DrawChart(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ChartPopupMenuPopup(TObject *Sender) { if(Main->Undo->canundo()){ pmcUndo->Enabled = true; } else { pmcUndo->Enabled = false; } if(Main->Undo->canredo()){ pmcRedo->Enabled = true; } else { pmcRedo->Enabled = false; } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcInvertClick(TObject *Sender) { Main->Undo->do_(Main->texlayer); Main->texlayer->invertRegion(Main->LayerNum); DrawChart(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcRepeatClick(TObject *Sender) { Main->Undo->do_(Main->texlayer); Main->texlayer->repeatUpperRegion(Main->LayerNum); DrawChart(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcShiftClick(TObject *Sender) { TCursor cursor = Screen->Cursor; Screen->Cursor = crIBeam; FloatingWindow->Left=Mouse->CursorPos.x; FloatingWindow->Top=Mouse->CursorPos.y-FloatingWindow->Height; if(FloatingWindow->ShowModal()==mrOk){ Main->Undo->do_(Main->texlayer); Main->texlayer->leftShiftRegion(StrToInt(FloatingWindow->edit->Text), Main->LayerNum); DrawChart(); } Screen->Cursor = cursor; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::FormCreate(TObject *Sender) { StringTable.Create(BaseDir, Language, "Design"); Caption=IDS_DESIGN; gbView->Caption=IDS_VIEW_MENU; gbInput->Caption=IDS_INPUT_MENU; cbOverLap->Caption=IDS_OVERLAP; RepeatCheckBox->Caption=IDS_REPEAT; cbChartBGColor->Text=IDS_BLACK; cbChartBGColor->Items->Clear(); cbChartBGColor->Items->Add(IDS_BLACK); cbChartBGColor->Items->Add(IDS_GRAY); cbChartBGColor->Items->Add(IDS_WHITE); sbEnlarge->Caption=IDS_SHOW_DESIGN_VIEWER; sbViewtext->Caption=IDS_VIEW_TEXT; pmcInvert->Caption=IDS_INVERT; pmcRepeat->Caption=IDS_PM_REPEAT; pmcShift->Caption=IDS_SHIFT; pmcZoom->Caption=IDS_ZOOM; pmcUndo->Caption=IDS_UNDO; pmcRedo->Caption=IDS_REDO; pmcToClipBoard->Caption=IDS_COPY; pmcSave->Caption=IDS_SAVE; lbStart->Caption=IDS_START; SetFont(); chartTemp = new Graphics::TBitmap; chartTempL = new TTexpiaBitmap; chartTempL2 = new TTexpiaBitmap; chartTemp->LoadFromFile(BaseDir + "\\cell.bmp"); Zoom = 2; SetDist(); Main->UpdateBtn(); UpdateCheckBox(); DrawChart(true); SavePictureDialog->InitialDir=BaseDir+"\\bmp"; SavePictureDialog->DefaultExt = "bmp"; SavePictureDialog->FileName = "Noname1"; SavePictureDialog->Filter="Bitmaps (*.bmp)|*.bmp|JPEG Image File (*.jpg)|*.jpg"; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::FormDestroy(TObject *Sender) { if(chartTemp){ delete chartTemp; chartTemp = NULL; } if(chartTempL){ delete chartTempL; chartTempL = NULL; } if(chartTempL2){ delete chartTempL2; chartTempL2 = NULL; } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::UpdateCheckBox(void){ if(cbOverLap->Checked){ cbLayer1->Enabled=true; cbLayer2->Enabled=true; cbLayer3->Enabled=true; cbLayer4->Enabled=true; Main->texlayer->SetVisibleLayer(0, cbLayer1->Checked); Main->texlayer->SetVisibleLayer(1, cbLayer2->Checked); Main->texlayer->SetVisibleLayer(2, cbLayer3->Checked); Main->texlayer->SetVisibleLayer(3, cbLayer4->Checked); } else { cbLayer1->Enabled=false; cbLayer2->Enabled=false; cbLayer3->Enabled=false; cbLayer4->Enabled=false; Main->texlayer->SetVisibleLayer(0, Main->LayerNum==0); Main->texlayer->SetVisibleLayer(1, Main->LayerNum==1); Main->texlayer->SetVisibleLayer(2, Main->LayerNum==2); Main->texlayer->SetVisibleLayer(3, Main->LayerNum==3); } switch(Main->maindata.bar){ case 1: cbLayer2->Enabled=false; cbLayer3->Enabled=false; cbLayer4->Enabled=false; break; case 2: cbLayer3->Enabled=false; cbLayer4->Enabled=false; break; case 3: cbLayer4->Enabled=false; break; case 4: break; } } //--------------------------------------------------------------------------- double __fastcall TDesignForm::FindCursorPositionX(RECT r, int X, int Y, int DistX, int DistY){ if(Main->texlayer->Complex){ return (int)(r.right-X + 0.5*DistX)/DistX; } else { return (r.right-X)/DistX; } } //--------------------------------------------------------------------------- double __fastcall TDesignForm::FindCursorPositionY(RECT r, int X, int Y, int DistX, int DistY){ return (r.bottom-Y)/DistY + 1; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::OnChangeSize(){ StructurePanel->Left=2; StructurePanel->Top=2; StructurePanel->Width=ClientWidth-4; ChartBox->Left=2; ChartBox->Top=StructurePanel->Height+4;; ChartBox->Width=ClientWidth-4; ChartBox->Height=ClientHeight-StructurePanel->Height-ChartStatusBar->Height-6; //StructurePanel ³»ºÎ gbView->Width=196+(StructurePanel->Width-393); InputPanel->Left=208+(StructurePanel->Width-393); //ChartBox ³»ºÎ ChartVScrollBar->Width=16; ChartHScrollBar->Height=16; RBPanel->Top=2; RBPanel->Left=2; ChartHScrollBar->Width=ChartBox->ClientWidth-RBPanel->Width-4; ChartVScrollBar->Height=ChartBox->ClientHeight-RBPanel->Height-4; ChartHScrollBar->Left=RBPanel->Width; ChartVScrollBar->Left=RBPanel->Left; ChartVScrollBar->Top=RBPanel->Height; ChartHScrollBar->Top=RBPanel->Top; ChartRuler->Height=ChartVScrollBar->Height; ChartRuler->Width=ChartHScrollBar->Width; ChartRuler->Top=RBPanel->Height; ChartRuler->Left=RBPanel->Width; ChartStatusBar->Top=ClientHeight-ChartStatusBar->Height; ChartStatusBar->Left=2; ChartStatusBar->Width=ClientWidth-4; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::FormResize(TObject *Sender) { OnChangeSize(); DrawChart(true); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::arrange_wales(Tex *tex){ // ÀÌÇÔ¼ö¿¡ µé¾î ¿Ã¶§¿¡´Â Çѹø¿¡ ÇѰ¡Áö¸¸ º¯ÇÑ´Ù°í °¡Á¤//Á¤·ÄÀÇ ´ë»óÀº ¿ÀÁ÷Çϳª//¶Ç´Â ÀÏÂ÷¿øÀû ºñÁ¤·Ä »óÅ WaleState *ws=NULL; WaleState *ws1=NULL; for(int k=0;kWales->Count-1;k++){ if(tex->Wales->Count<2) return; //Áß°£¿¡ ÀÛ¾ÆÁø´Ù// ws=(WaleState *)tex->Wales->Items[k]; ws1=(WaleState *)tex->Wales->Items[k+1]; if(ws->IsSameType(*ws1)&&ws->in==ws1->in){ ws1->cnt+=ws->cnt; ws->cnt=0; } if(ws->cnt==0){ delete ws; tex->Wales->Remove(ws); k--; } } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::sbViewtextClick(TObject *Sender) { EditorForm->Init(); EditorForm->Show(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::SetFont(){ SetSmallFont(Font); SetSmallFont(ChartStatusBar->Font); //SetSmallFont(StructurePanel->Font); SetSmallFont(gbView->Font); SetSmallFont(gbInput->Font); SetSmallFont(cbOverLap->Font); SetSmallFont(RepeatCheckBox->Font); SetSmallFont(cbLayer5->Font); SetSmallFont(cbLayer4->Font); SetSmallFont(cbLayer3->Font); SetSmallFont(cbLayer2->Font); SetSmallFont(cbLayer1->Font); SetSmallFont(cbChartBGColor->Font); SetSmallFont(sbEnlarge->Font); SetSmallFont(sbViewtext->Font); SetSmallFont(lbY->Font); SetSmallFont(lbX1->Font); SetSmallFont(lbX2->Font); //SetSmallFont(edY->Font); //SetSmallFont(edXIn->Font); //SetSmallFont(edXVia->Font); SetSmallFont(lbStart->Font); //SetSmallFont(edShift->Font); SetSmallFont(cbChartBGColor->Font); SetSmallFont(sbEnlarge->Font); SetSmallFont(sbViewtext->Font); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::ShowChart(){ HDC dc2=chartTempL2->CreateDC(); int yoff2=ChartVScrollBar->Max-ChartVScrollBar->Position; int xoff2=ChartHScrollBar->Max-ChartHScrollBar->Position; int dx=0,dy=0,sx=0,sy=0; if(chartTempL2->Width>Chart->Width) { sx = chartTempL2->Width-Chart->Width-xoff2; dx = 0; } else { sx = 0; dx = Chart->Width-chartTempL2->Width; } if(chartTempL2->Height>Chart->Height) { sy = chartTempL2->Height-Chart->Height-yoff2; dy = 0; } else { sy = 0; dy = Chart->Height-chartTempL2->Height; } BitBlt(Chart->Canvas->Handle, dx, dy, Chart->Width, Chart->Height, dc2, sx, sy, SRCCOPY); chartTempL2->DeleteDC(dc2); Chart->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::edShiftKeyPress(TObject *Sender, char &Key) { Tex *tex = (Tex *)Main->texlayer->TexList->Items[Main->LayerNum]; if(Key==VK_RETURN){ if(edShift->Text=="")return; if(StrToInt(edShift->Text)<0) edShift->Text = "0"; tex->leftShift=StrToInt(edShift->Text); GuideBar_F->UpdateGuideBar(); DrawChart(); GuideBar_F->edShift->Text=edShift->Text; } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::UpdateEdit(){ Tex *tex = (Tex *)Main->texlayer->TexList->Items[Main->LayerNum]; edShift->Text = IntToStr(tex->leftShift); } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcToClipBoardClick(TObject *Sender) { BITMAPHANDLE bh; HDC dcSrc = NULL, dcDst = NULL; memset(&bh, 0, sizeof(BITMAPHANDLE)); L_CreateBitmap(&bh, TYPE_CONV, Chart->Width, Chart->Height, 24, ORDER_BGR, NULL, TOP_LEFT); dcDst = L_CreateLeadDC(&bh); dcSrc = Chart->Canvas->Handle; BitBlt(dcDst, 0, 0, Chart->Width, Chart->Height, dcSrc, 0, 0, SRCCOPY); L_DeleteLeadDC(dcDst); dcDst = NULL; L_CopyToClipboard(Handle, &bh); L_FreeBitmap(&bh); } //--------------------------------------------------------------------------- bool __fastcall TDesignForm::ReadFromFile(HANDLE hFile){ DWORD dwRead; int index=0; try{ int ver; ReadFile(hFile, &ver, sizeof(int), &dwRead, NULL); if(ver>=1){ ReadFile(hFile, &index, sizeof(int), &dwRead, NULL); cbChartBGColor->ItemIndex=index; cbChartBGColorChange(NULL); } } catch(...){ ShowMessage(IDS_MESSAGE_LOAD_FAIL); return false; } return true; } //--------------------------------------------------------------------------- bool __fastcall TDesignForm::SaveToFile(HANDLE hFile){ DWORD dwWrite; int index=cbChartBGColor->ItemIndex; if(index>=cbChartBGColor->Items->Count||index<0)index=0; try{ int ver=1; WriteFile(hFile, &ver, sizeof(int), &dwWrite, NULL); WriteFile(hFile, &index, sizeof(int), &dwWrite, NULL); }catch(...){ ShowMessage(IDS_MESSAGE_SAVE_FAIL); return false; } return true; } //--------------------------------------------------------------------------- void __fastcall TDesignForm::pmcSaveClick(TObject *Sender) { if (SavePictureDialog->Execute()) { if(SavePictureDialog->FilterIndex==1){ Chart->Picture->Bitmap->SaveToFile(SavePictureDialog->FileName); } else if(SavePictureDialog->FilterIndex==2){ TJPEGImage *jp = new TJPEGImage(); try { jp->Assign(Chart->Picture->Bitmap); jp->SaveToFile(SavePictureDialog->FileName); } __finally { delete jp; } } } } //--------------------------------------------------------------------------- void __fastcall TDesignForm::FormShow(TObject *Sender) { static bool first=true; if(first){ POINT p=Main->ClientToScreen(Point(0,0)); Top=p.y+2; Height=Main->ClientHeight-4; Left=p.x+(Main->ClientWidth-209-6)/2+4; Width=(Main->ClientWidth-209-6)/2;; } first=false; } //---------------------------------------------------------------------------