//--------------------------------------------------------------------------- #include #pragma hdrstop #include "TexLayer.h" #include "common.h" #include "Design.h"//gabriel //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- __fastcall TexLayer::TexLayer(){ bm = new TTexpiaBitmap;//Àӽà ºñÆ®¸Ê bm_no_cursor = new TTexpiaBitmap;//Ä¿¼­ ¾ø´Â »óÅÂÀÇ ºñÆ®¸Ê///¸¶¿ì½º ¹«ºê½Ã ¼Óµµ¾÷// bm_temp = new TTexpiaBitmap; bm_mask = new TTexpiaBitmap; TexList = new TList; YarnList=new TList; YarnUseList = new TList; Complex = false; crState = CR_SQUARE; staticState=false; complete_needle=12; default_complete_needle = true; Yarn *yarn = new Yarn; YarnList->Add(yarn);//yarnÀº ±âº»ÀûÀ¸·Î 1°³ ÀÌ»ó ¸®½ºÆ®¿¡ ¿Ã¶óÀÖ´Ù } //--------------------------------------------------------------------------- __fastcall TexLayer::~TexLayer(){ delete bm; delete bm_no_cursor; delete bm_temp; delete bm_mask; if(TexList){ Tex *itemTex = NULL; for (int i = 0; i < TexList->Count; i++) { itemTex = (Tex *)TexList->Items[i]; delete itemTex; } TexList->Clear(); delete TexList; } if(YarnList){ Yarn *itemYarn = NULL; for (int i = 0; i < YarnList->Count; i++) { itemYarn = (Yarn *)YarnList->Items[i]; delete itemYarn; } YarnList->Clear(); delete YarnList; } if(YarnUseList){ YarnUse *itemYarnUse = NULL; for (int i = 0; i < YarnUseList->Count; i++) { itemYarnUse = (YarnUse *)YarnUseList->Items[i]; delete itemYarnUse; } YarnUseList->Clear(); delete YarnUseList; } } //--------------------------------------------------------------------------- void __fastcall TexLayer::SetHeight(int Height){ for(int i=0;iCount;i++){ ((Tex *)(TexList->Items[i]))->SetHeight(Height); } } //--------------------------------------------------------------------------- int __fastcall TexLayer::GetHeight(){ return ((Tex *)(TexList->Items[0]))->GetHeight(); } //--------------------------------------------------------------------------- void __fastcall TexLayer::AddLayer(){ Tex *tex=new Tex; TexList->Add(tex); } //--------------------------------------------------------------------------- void __fastcall TexLayer::DeleteLayer(int num){ if(num>=TexList->Count)return; delete (Tex *)TexList->Items[num]; TexList->Delete(num); } //--------------------------------------------------------------------------- void __fastcall TexLayer::InsertLayer(int num){ Tex *tex=new Tex; TexList->Insert(num, tex); } //--------------------------------------------------------------------------- int __fastcall TexLayer::GetLayerCount(){ return TexList->Count; } //--------------------------------------------------------------------------- void __fastcall TexLayer::SetVisibleLayer(int l, bool v){ if (l>=TexList->Count)return; if (l<0) return; ((Tex *)(TexList->Items[l]))->Visible=v; } //--------------------------------------------------------------------------- void __fastcall TexLayer::SetRepeatLayer(int l, bool v){ if (l>=TexList->Count) return; if (l<0) return; ((Tex *)(TexList->Items[l]))->Repeat=v; } //--------------------------------------------------------------------------- //ÃÖÁ¾ÀûÀ¸·Î È­¸é¿¡ ±×¸®´Â °ÍÀº ÇÔ¼ö ¾È¿¡¼­ Draw2·Î ³Ñ°Ü¼­ ±×¸°´Ù void __fastcall TexLayer::Draw(HDC hDC, RECT r, int DistX, int DistY, bool reDraw, bool bPosMark){ int i; if(TexList->Count==0)return; int w = (r.right-r.left)/DistX; int h = (r.bottom-r.top)/DistY; int shift; if(Complex) shift = 0.5*DistX; else shift = 0 ; /* if(reDraw){ Draw2(hDC,r,DistX,DistY); bm_no_cursor->Create(r.right,DesignForm->smallchartHeight,24); HDC dc=bm_no_cursor->CreateDC(); BitBlt(dc,0,0,r.right,DesignForm->smallchartHeight,hDC,0,0,SRCCOPY); bm_no_cursor->DeleteDC(dc); } else { HDC dc=bm_no_cursor->CreateDC(); BitBlt(hDC,0,0,r.right,DesignForm->smallchartHeight,dc,0,0,SRCCOPY); bm_no_cursor->DeleteDC(dc); } */ //by siuaa if(reDraw){ Draw2(hDC,r,DistX,DistY); bm_no_cursor->Create(r.right,r.bottom - r.top,24); HDC dc=bm_no_cursor->CreateDC(); BitBlt(dc,0,0,r.right,r.bottom - r.top,hDC,0,0,SRCCOPY); bm_no_cursor->DeleteDC(dc); } else { HDC dc=bm_no_cursor->CreateDC(); BitBlt(hDC,0,0,r.right,r.bottom - r.top,dc,0,0,SRCCOPY); bm_no_cursor->DeleteDC(dc); } ////////// if(bPosMark == true) { if(crState==CR_REGION){ RECT rR; rR.left = min(repeatRegion.left,repeatRegion.right); rR.right = max(repeatRegion.left,repeatRegion.right); rR.top = min(repeatRegion.top,repeatRegion.bottom); rR.bottom = max(repeatRegion.top,repeatRegion.bottom); HPEN hOldPen,hPen = CreatePen(PS_SOLID,1,clGreen); HBRUSH hOldBrush = SelectObject(hDC, GetStockObject(NULL_BRUSH)); hOldPen = SelectObject(hDC, hPen); Rectangle(hDC, r.right-(rR.right+1)*DistX-1 + shift, r.bottom-r.top-DistY*(rR.bottom+1)-1, r.right - (rR.left)*DistX + shift, r.bottom -r.top - DistY*(rR.top)); SelectObject(hDC, hOldPen); SelectObject(hDC, hOldBrush); DeleteObject(hPen); staticState=false; } else if(crState==CR_SQUARE){ if(Focus.x>=0&&Focus.x<=w&&Focus.y>=0&&Focus.y<=h){ HPEN hOldPen,hPen = CreatePen(PS_SOLID,1,clGreen); HBRUSH hOldBrush = SelectObject(hDC, GetStockObject(NULL_BRUSH)); hOldPen = SelectObject(hDC, hPen); Rectangle(hDC, r.right-(Focus.x+1)*DistX-1 + shift, r.bottom-r.top-DistY*(Focus.y+1)-1, r.right - (Focus.x)*DistX + shift, r.bottom -r.top- DistY*(Focus.y)); SelectObject(hDC, hOldPen); SelectObject(hDC, hOldBrush); DeleteObject(hPen); staticState=true; } } } } /* //--------------------------------------------------------------------------- void __fastcall TexLayer::Draw2(HDC hDC, RECT r, int DistX, int DistY){ int i; if(TexList->Count==0)return; int w = (r.right-r.left)/DistX; int h = (r.bottom-r.top)/DistY; int shift; if(Complex) shift = 0.5*DistX; else shift = 0 ; int width = complete_needle; int maxrun=0; int minrun=0; for(int j2=0;j2Count;j2++){ Tex *tex = ((Tex *)TexList->Items[j2]); for(int i2=0;i2Curve->Count;i2++) { KO *ko = (KO *)tex->Curve->Items[i2]; maxrun = max(ko->in,max(ko->via,max(ko->out,maxrun))); minrun = min(ko->in,min(ko->via,min(ko->out,minrun))); } } RECT r2=Rect(0,0,(width+(maxrun-minrun))*DistX,r.bottom); for(i=0;iCount;i++){ if(((Tex *)(TexList->Items[i]))->Visible==true){ if(((Tex *)(TexList->Items[i]))->Repeat==true){ ((Tex *)(TexList->Items[i]))->Draw(hDC, YarnList, r2, DistX, DistY, Point(i&1,i&2)); } } } RECT r3=Rect(0,0,width*DistX,r.bottom); bm->Create(r3.right,r3.bottom,24); HDC dc=bm->CreateDC(); BitBlt(dc,0,0,r3.right,r3.bottom,hDC,r2.right-r3.right,0,SRCCOPY); //r2.bottom==r.bottom for(int l=0;l<=r.right/r3.right;l++){ BitBlt(hDC, r.right-(l+1)*r3.right,0, r3.right,r3.bottom, dc, 0,0, SRCCOPY); } for(i=0;iCount;i++){ if(((Tex *)(TexList->Items[i]))->Visible==true){ if(((Tex *)(TexList->Items[i]))->Repeat==false){ ((Tex *)(TexList->Items[i]))->Draw(hDC, YarnList, r, DistX, DistY, Point(i&1,i&2)); } } } bm->DeleteDC(dc); } */ #define CheckBit(r, s) ((r)[(s)>>3] & (0x80 >> ((s)&7))) #define SetBit(r, s) (((r)[(s)>>3]) |= (BYTE)(0x0080 >> ((s)&7))) #define ResetBit(r, s) (((r)[(s)>>3]) &= (BYTE)(0xFF7F >> ((s)&7))) //--------------------------------------------------------------------------- //TEX_MAX_WIDTH ³Ñ¾î°¥ ¶§ ¿¡·¯ ¼öÁ¤, ¼öÁ¤ ÀüÀº 2.391 Âü°í //º»°ÝÀûÀ¸·Î µðÀÚÀÎâ¿¡ ½Ç ±×¸®´Â ÇÔ¼ö(½Ã¹Ä·¹À̼ǰú´Â »ó°ü ¾øÀ½) void __fastcall TexLayer::Draw2(HDC hDC, RECT r, int DistX, int DistY, int Height_in, int diff_in){//gabriel int i; if(TexList->Count==0)return; int Height=0; int diff=-100; if(Height_in>0) Height = Height_in; else Height = r.bottom - r.top;//DesignForm->smallchartHeight; if(diff_in >= 0) diff = diff_in; else diff = 0;//DesignForm->ChartVScrollBar->Max-DesignForm->ChartVScrollBar->Position; int w = (r.right-r.left)/DistX; int h = (r.bottom-r.top)/DistY; int shift; if(Complex) shift = 0.5*DistX; else shift = 0 ; int width = complete_needle; if(default_complete_needle == true){ //ÀåÁø¸¸ : ÃÖ¼Ò°ø¹è¼ö¸¦ À§ÇØ int a[MAX_LAYER_COUNT] = {0,0,0,0,0,0,0}; for(int j2=0;j2Count;j2++){ Tex *tex = ((Tex *)TexList->Items[j2]); for(int i2=0;i2Wales->Count;i2++) a[j2]+= ((WaleState *)(tex->Wales->Items[i2]))->cnt; } width = GetLCN(a[0],a[1],a[2],a[3],a[4],a[5],a[6]); } int maxrun=0; int minrun=0; for(int j2=0;j2Count;j2++){ Tex *tex = ((Tex *)TexList->Items[j2]); for(int i2=0;i2Curve->Count;i2++) { KO *ko = (KO *)tex->Curve->Items[i2]; maxrun = max(ko->in,max(ko->via,max(ko->out,maxrun))); minrun = min(ko->in,min(ko->via,min(ko->out,minrun))); } } RECT r2=Rect(0,r.top,(width+(maxrun-minrun))*DistX,r.bottom); bool black_y_all = false; bool *black_y = new bool[TexList->Count]; for(i=0;iCount;i++){ black_y[i] = false; } ////////////////////////////////////////////////////////////black½ÇÀÌ¿ÜÀÇ ½ÇÀ» ±×¸°´Ù(¸¶½ºÅ© ¶§¹®¿¡ black ½ÇÀº µû·Î ó¸® ÇÊ¿ä) RECT r3=Rect(0,r.top,width*DistX,r.bottom); bm_temp->ReCreate_size(r2.right,Height,24); bm_temp->FillRect(Rect(0,0,bm_temp->Width,bm_temp->Height), clBlack); HDC dc_temp=bm_temp->CreateDC(); for(i=0;iCount;i++){ if(((Tex *)(TexList->Items[i]))->Visible==true){ if(((Tex *)(TexList->Items[i]))->Repeat==true){ bool temp_b = ((Tex *)(TexList->Items[i]))->Draw(dc_temp, YarnList, r2, DistX, DistY, Point(i&1,i&2),diff); if(temp_b){ black_y[i] = true; black_y_all = true;} } } } bm->ReCreate_size(r3.right,Height,24); bm->FillRect(Rect(0,0,bm->Width,bm->Height), clBlack); HDC dc=bm->CreateDC(); BitBlt(dc,0,0,bm->Width,bm->Height,dc_temp,bm_temp->Width-bm->Width,0,SRCCOPY); // bm->DeleteDC(dc); bm_mask->ReCreate_size(r3.right,Height,1); bm_mask->FillRect(Rect(0,0,bm_mask->Width,bm_mask->Height), clWhite); bm->StartScanLine(); bm_mask->StartScanLine(); for(int j=0; jHeight; j++){ Byte *BM = bm->GetScanLine(j); Byte *BMM = bm_mask->GetScanLine(j); for(int i=0; iWidth; i++){ if(BM[3*i]==0 && BM[3*i+1]==0 && BM[3*i+2]==0) SetBit(BMM, i); else ResetBit(BMM, i); } bm_mask->PutScanLine(j); } bm->StopScanLine(); bm_mask->StopScanLine(); // dc=bm->CreateDC(); HDC dc_mask=bm_mask->CreateDC(); for(int l=0;l<=r.right/r3.right;l++){ BitBlt(hDC,r.right-(l+1)*r3.right,0,bm->Width,bm->Height,dc_mask,0,0,SRCAND); BitBlt(hDC,r.right-(l+1)*r3.right,0,bm->Width,bm->Height,dc,0,0,SRCPAINT); } for(i=0;iCount;i++){ if(((Tex *)(TexList->Items[i]))->Visible==true){ if(((Tex *)(TexList->Items[i]))->Repeat==false){ bool temp_b = ((Tex *)(TexList->Items[i]))->Draw(hDC, YarnList, r, DistX, DistY, Point(i&1,i&2),diff); if(temp_b){ black_y[i] = true; black_y_all = true;} } } } // bm->DeleteDC(dc); if(black_y_all){ ////////////////////////////////////////////////////////////ÀÌÇÏ ºÎºÐÀº °ËÀº½Ç¸¸ ±×¸®±â À§ÇÑ ºÎºÐ BitBlt(hDC,0,0,r.right,Height,hDC,0,0,NOTSRCCOPY); bm_temp->FillRect(Rect(0,0,bm_temp->Width, bm_temp->Height), clBlack); for(i=0;iCount;i++){ if(black_y[i]) if(((Tex *)(TexList->Items[i]))->Visible==true){ if(((Tex *)(TexList->Items[i]))->Repeat==true){ ((Tex *)(TexList->Items[i]))->DrawBlack(dc_temp, YarnList, r2, DistX, DistY, Point(i&1,i&2),diff); } } } bm->FillRect(Rect(0,0,bm->Width, bm->Height), clBlack); BitBlt(dc,0,0,bm->Width,bm->Height,dc_temp,bm_temp->Width-bm->Width,0,SRCCOPY); for(int l=0;l<=r.right/r3.right;l++){ BitBlt(hDC,r.right-(l+1)*r3.right,0,bm->Width,bm->Height,dc,0,0,SRCPAINT); } for(i=0;iCount;i++){ if(black_y[i]) if(((Tex *)(TexList->Items[i]))->Visible==true){ if(((Tex *)(TexList->Items[i]))->Repeat==false){ ((Tex *)(TexList->Items[i]))->DrawBlack(hDC, YarnList, r, DistX, DistY, Point(i&1,i&2),diff); } } } BitBlt(hDC,0,0,r.right,Height,hDC,0,0,NOTSRCCOPY); //////////////////////////////////////////////////////////// } delete[] black_y; bm->DeleteDC(dc); bm_temp->DeleteDC(dc_temp); bm_mask->DeleteDC(dc_mask); } //--------------------------------------------------------------------------- bool __fastcall TexLayer::LayerMouseMove(TShiftState Shift, RECT r, int X , int Y, int DistX, int DistY, int LayerNum){ Tex *tex = ((Tex *)(TexList->Items[LayerNum])); if(tex->Visible==false) return true; POINT p = FindCell(r, X, Y, DistX, DistY); tex->MouseMove(Shift, p.x , p.y); if(Shift.Contains(ssShift)){ crState=CR_REGION; repeatRegion.right=p.x; repeatRegion.bottom=p.y; } else { if(tex->Repeat){ crState=CR_NONE; } else { crState=CR_SQUARE; } } if(Focus.x == p.x && Focus.y == p.y) { return true; } else { Focus = p; return false; } } //--------------------------------------------------------------------------- bool __fastcall TexLayer::LayerMouseDown(TShiftState Shift, RECT r, int X , int Y, int DistX, int DistY, int LayerNum){ Tex *tex = ((Tex *)(TexList->Items[LayerNum])); if(tex->Visible==false) return true; POINT p = FindCell(r, X, Y, DistX, DistY); if(Shift.Contains(ssShift)){ crState=CR_REGION; repeatRegion.left=p.x; repeatRegion.top=p.y; repeatRegion.right=p.x; repeatRegion.bottom=p.y; } else { tex->MouseDown(Shift, p.x, p.y, Complex); crState=CR_SQUARE; } return false; } //--------------------------------------------------------------------------- bool __fastcall TexLayer::LayerMouseUp(TShiftState Shift, RECT r, int X , int Y, int DistX, int DistY, int LayerNum){ return true; } //--------------------------------------------------------------------------- POINT __fastcall TexLayer::FindCell(RECT r, int X , int Y, int DistX, int DistY){ int shift; if(Complex) shift = 0.5*DistX; else shift = 0 ; int x = (r.right-X + shift)/DistX; int y = (r.bottom-Y)/DistY; return Point(x,y); } //--------------------------------------------------------------------------- POINT __fastcall TexLayer::FindCell2(RECT r, int X , int Y, int DistX, int DistY){ int shift = 0.5*DistX; int x = (r.right-X + shift)/DistX; int y = (r.bottom-Y)/DistY; return Point(x,y); } //--------------------------------------------------------------------------- bool __fastcall TexLayer::ReadFromFile(HANDLE hFile, int main_ver){ DWORD dwRead; int cnt,yCnt; try{ if(main_ver>=1){ if(TexList){ Tex *item = NULL; for (int i = 0; i < TexList->Count; i++) { item = (Tex *)TexList->Items[i]; delete item; } TexList->Clear(); //delete TexList; } if(YarnList){ Yarn *item = NULL; for (int i = 0; i < YarnList->Count; i++) { item = (Yarn *)YarnList->Items[i]; delete item; } YarnList->Clear(); //delete YarnList; } if(YarnUseList){ YarnUse *item = NULL; for (int i = 0; i < YarnUseList->Count; i++) { item = (YarnUse *)YarnUseList->Items[i]; delete item; } YarnUseList->Clear(); //delete YarnUseList; } if(main_ver>=100){ int ver; ReadFile(hFile, &ver, sizeof(int), &dwRead, NULL); if(ver>=1){ ReadFile(hFile, &complete_needle, sizeof(int), &dwRead, NULL); ReadFile(hFile, &cnt, sizeof(int), &dwRead, NULL); for(int i=0;iReadFromFile(hFile); YarnList->Add(yarn); } ReadFile(hFile, &cnt, sizeof(int), &dwRead, NULL); for(int i=0;iReadFromFile(hFile); YarnUseList->Add(yu); } ReadFile(hFile, &cnt, sizeof(int), &dwRead, NULL); for(int i=0;iItems[i])->ReadFromFile(hFile, main_ver); } } if(ver>=2){ ReadFile(hFile, &default_complete_needle, sizeof(bool), &dwRead, NULL); }else{ default_complete_needle = false; } } else { ReadFile(hFile, &cnt, sizeof(int), &dwRead, NULL); ReadFile(hFile, &yCnt, sizeof(int), &dwRead, NULL); for(int i=0;iyarnIndex=i; yu->layer_num=ys.Bar; yarn->ym=ys.ym; yarn->yp=ys.yp; yarn->denier=ys.denier; yarn->filament=ys.filament; yarn->color=ys.c; yu->mmPerRACK=ys.meanLengthPer480COS; yu->MPY=ys.MPerY; yu->GPY=ys.GPerY; yu->total_use=ys.total; yu->percent=ys.percent; YarnList->Add(yarn);//¿¹ÀüÈ­ÀÏÀ» ºÒ·¯¿À´Ùº¸¸é ½ÇÁ¦·Î ¾²ÀÌÁö ¾ÊÀº ½ÇÀÌ ³ª¿À´Â ¹ö±×°¡ ÀÖÀ¸³ª ¹«½ÃÇØµµ µÊ YarnUseList->Add(yu); } for(int i=0;iItems[i]; tex->ReadFromFile(hFile, main_ver); for(int j=0;jWales->Count;j++){ OldWaleState2 *ws = (OldWaleState2 *)tex->Wales->Items[j]; if(ws->cnt<1) { delete ws; tex->Wales->Remove(ws); j--; continue; } WaleState *ws2 = new WaleState; ws2->cnt=ws->cnt; ws2->in=ws->in; ws2->isTransParent=ws->isTransParent; ws2->yarnIndex=0; bool match=false; for(int k=0;kCount;k++){ Yarn *yarn = (Yarn *)YarnList->Items[k]; if(yarn->color==ws->c&& yarn->denier==ws->Denier&& yarn->filament==ws->multi&& //yarn->contraction==ws->contraction&& yarn->ym==ws->YarnMaterial()&& yarn->yp==ws->YarnProperty()){ ws2->yarnIndex=k; match=true; break; } } if(match==false){ Yarn *yarn=new Yarn; yarn->color=ws->c; yarn->denier=ws->Denier; yarn->filament=ws->multi; //yarn->contraction=ws->contraction; yarn->ym=ws->YarnMaterial(); yarn->yp=ws->YarnProperty(); ws2->yarnIndex=YarnList->Count; YarnList->Add(yarn); } delete ws; tex->Wales->Remove(ws); tex->Wales->Insert(j,ws2); } if(tex->Wales->Count==0){ tex->Wales->Add(new WaleState); } } if(YarnList->Count==0){ YarnList->Add(new Yarn); } int a[MAX_LAYER_COUNT] = {0,0,0,0,0,0,0}; for(int j2=0;j2Count;j2++){ Tex *tex = ((Tex *)TexList->Items[j2]); for(int i2=0;i2Wales->Count;i2++) a[j2]+= ((WaleState *)(tex->Wales->Items[i2]))->cnt; } complete_needle = GetLCN(a[0],a[1],a[2],a[3],a[4],a[5],a[6]); } } }catch(...){ ShowMessage(IDS_MESSAGE_LOAD_FAIL); return false; } return true; } //--------------------------------------------------------------------------- bool __fastcall TexLayer::SaveToFile(HANDLE hFile){ DWORD dwWrite; try{ int ver=2; WriteFile(hFile, &ver, sizeof(int), &dwWrite, NULL); WriteFile(hFile, &complete_needle, sizeof(int), &dwWrite, NULL); WriteFile(hFile, &(YarnList->Count), sizeof(int), &dwWrite, NULL); for(int i=0;iCount;i++){ ((Yarn *)YarnList->Items[i])->SaveToFile(hFile); } WriteFile(hFile, &(YarnUseList->Count), sizeof(int), &dwWrite, NULL); for(int i=0;iCount;i++){ ((YarnUse *)YarnUseList->Items[i])->SaveToFile(hFile); } WriteFile(hFile, &(TexList->Count), sizeof(int), &dwWrite, NULL); for(int i=0;iCount;i++){ ((Tex *)TexList->Items[i])->SaveToFile(hFile); } WriteFile(hFile, &default_complete_needle, sizeof(bool), &dwWrite, NULL); } catch(...){ ShowMessage(IDS_MESSAGE_SAVE_FAIL); return false; } return true; } //--------------------------------------------------------------------------- void __fastcall TexLayer::setFocus(int fX , int fY){ Focus.x = fX; Focus.y = fY; } //--------------------------------------------------------------------------- void __fastcall TexLayer::repeatUpperRegion(int LayerNum, int repeatnum){//ÀåÁø¸¸:¸®ÇÍ È½¼ö ÀԷ°¡´É Tex *tex = ((Tex *)TexList->Items[LayerNum]); if(crState==CR_REGION){ RECT rR; rR.left = max(repeatRegion.left,repeatRegion.right); rR.right = min(repeatRegion.left,repeatRegion.right); rR.top = max(repeatRegion.top,repeatRegion.bottom); rR.bottom = min(repeatRegion.top,repeatRegion.bottom); if(rR.top>=tex->Curve->Count) return; int cnt = rR.top - rR.bottom + 1; int upper = min((int)(repeatnum*cnt+rR.top)+1, tex->Curve->Count); if(repeatnum == 0) upper = tex->Curve->Count; for(int i=rR.top+1;iCurve->Items[i]; KO *ko2 = (KO *)tex->Curve->Items[(i-rR.bottom)%cnt+rR.bottom]; *ko = *ko2; } } } //--------------------------------------------------------------------------- void __fastcall TexLayer::leftShiftRegion(int shift, int LayerNum){ Tex *tex = ((Tex *)TexList->Items[LayerNum]); if(crState==CR_REGION){ RECT rR; rR.left = max(repeatRegion.left,repeatRegion.right); rR.right = min(repeatRegion.left,repeatRegion.right); rR.top = max(repeatRegion.top,repeatRegion.bottom); rR.bottom = min(repeatRegion.top,repeatRegion.bottom); if(rR.top>=tex->Curve->Count) return; int cnt = rR.top - rR.bottom + 1; for(int i=rR.bottom;iCurve->Items[i]; ko->in = ko->in + shift; ko->via = ko->via + shift; ko->out = ko->out + shift; } } else if(crState==CR_SQUARE){ for(int i=0;iCurve->Count;i++){ KO *ko = (KO *)tex->Curve->Items[i]; ko->in = ko->in + shift; ko->via = ko->via + shift; ko->out = ko->out + shift; } } } //--------------------------------------------------------------------------- void __fastcall TexLayer::invertRegion(int LayerNum){ Tex *tex = ((Tex *)TexList->Items[LayerNum]); if(crState==CR_REGION){ RECT rR; rR.left = max(repeatRegion.left,repeatRegion.right); rR.right = min(repeatRegion.left,repeatRegion.right); rR.top = max(repeatRegion.top,repeatRegion.bottom); rR.bottom = min(repeatRegion.top,repeatRegion.bottom); if(rR.top>=tex->Curve->Count) return; int cnt = rR.top - rR.bottom + 1; int maxx=0; for(int i=rR.bottom;iCurve->Items[i]; maxx = max(ko->via,max(ko->out,max(maxx,ko->in))); } for(int i=rR.bottom;iCurve->Items[i]; ko->in = maxx - ko->in; ko->via = maxx - ko->via; ko->out = maxx - ko->out; } } else if(crState==CR_SQUARE){ int maxx=0; for(int i=0;iCurve->Count;i++){ KO *ko = (KO *)tex->Curve->Items[i]; maxx = max(ko->via,max(ko->out,max(maxx,ko->in))); } for(int i=0;iCurve->Count;i++){ KO *ko = (KO *)tex->Curve->Items[i]; ko->in = maxx - ko->in; ko->via = maxx - ko->via; ko->out = maxx - ko->out; } } } //--------------------------------------------------------------------------- void __fastcall TexLayer::MakeYarnImage(){ for(int i=0;iCount;i++){ Yarn *yarn=(Yarn *)YarnList->Items[i]; //yarn } } //---------------------------------------------------------------------------