{ ==============================================================================
|
方法名稱:ISB1Click
|
引用相依:
|
方法描述:影像滾輪盒(ISB)的點擊處理。更新當前顯示的 ISB 對象,調整 Shape1 標記框
|
的位置以框選當前 ISB。根據 ISB 名稱與捲軸位置計算並更新 PageLV 清單中
|
的選取狀態(NowPage 與 ItemIndex)。
|
============================================================================== }
|
procedure TCB_IMGPSScanX.ISB1Click(Sender: TObject);
|
var
|
p : Integer;
|
begin
|
DisplayISB := TImageScrollBox(Sender);
|
Shape1.Left := TPanel(TImageScrollBox(Sender).Parent).Left - Seg;
|
Shape1.Top := TPanel(TImageScrollBox(Sender).Parent).Top - Seg;
|
P := strtoint(copy(DisplayISB.Name,4,1)) + ScrollBar1.Position-2;
|
if P <= PageLV.Items.Count-1 then
|
begin
|
if PageLVclear then
|
begin
|
PageLV.ClearSelection;
|
end;
|
NowPage := p+1;
|
PageLV.ItemIndex := P;
|
end;
|
//DisplayISB.SetFocus;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:ISB1EndScroll
|
引用相依:
|
方法描述:當影像滾輪盒停止捲動時觸發。呼叫 SetScrollData 將當前的水平/垂直捲軸
|
位置與縮放百分比存回緩存中,以維持影像顯示的一致性。
|
============================================================================== }
|
procedure TCB_IMGPSScanX.ISB1EndScroll(Sender: TObject);
|
var
|
ISB : TImageScrollBox;
|
begin
|
ISB := TImageScrollBox(Sender);
|
|
SetScrollData(ISB,ISB.HorzScrollBar.Position,ISB.VertScrollBar.Position,ISB.ZoomPercent);
|
{if (TImageScrollBox(Sender) = MpsViewX1) and SortMode then
|
begin
|
ReczoomPercent := MpsViewX1.ZoomPercent;
|
RecHozPos := MpsViewX1.HorzScrollBarPos;
|
RecVerPos := MpsViewX1.VertScrollBarPos;
|
end;}
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:ISB1Enter
|
引用相依:
|
方法描述:當滑鼠進入影像滾輪盒區域時,強制將焦點設為 ISB1。
|
============================================================================== }
|
procedure TCB_IMGPSScanX.ISB1Enter(Sender: TObject);
|
begin
|
ISB1.SetFocus;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:ISB1ImageMouseDown
|
引用相依:LoadFromFile
|
方法描述:影像滑鼠按下事件。設定當前 DisplayISB 並視情況取得焦點,更新 Shape1 的
|
選取框位置。同步更新 PageLV 的選取頁面。若處於特定模式(NowClick = -1)
|
且按下左鍵,則啟動影像的拖曳操作(BeginDrag)。此外也會處理旋轉模式下的
|
影像載入。
|
============================================================================== }
|
procedure TCB_IMGPSScanX.ISB1ImageMouseDown(Sender: TObject; Button: TMouseButton;
|
Shift: TShiftState; X, Y: Integer);
|
var
|
p : Integer;
|
begin
|
DisplayISB := TImageScrollBox(Sender);
|
if NowClick<>0 then
|
DisplayISB.SetFocus;
|
Shape1.Left := TPanel(TImageScrollBox(Sender).Parent).Left - Seg;
|
Shape1.Top := TPanel(TImageScrollBox(Sender).Parent).Top - Seg;
|
P := strtoint(copy(DisplayISB.Name,4,1)) + ScrollBar1.Position-2;
|
if P <= PageLV.Items.Count-1 then
|
begin
|
NowPage := p+1;
|
PageLV.ClearSelection;
|
PageLV.ItemIndex := P;
|
|
//PageLV.Selected := PageLV.Items.Item[PageLV.ItemIndex];
|
|
end;
|
if (NowClick = -1) and (Button=TMouseButton(mbLeft)) and (DisplayISB.FileName <> '') then
|
begin
|
{for P := 1 to 8 do
|
begin
|
TImageScrollBox(FindComponent('ISB'+inttostr(p))).Enabled := False;
|
end; }
|
DisplayISB.BeginDrag(True);
|
end;
|
case TImageScrollBox(Sender).MouseMode of
|
mmR90,mmR180,mmR270:
|
begin
|
TImageScrollBox(Sender).LoadFromFile(TImageScrollBox(Sender).FileName,1);
|
end;
|
end;
|
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:ISB1ImageMouseMove
|
引用相依:
|
方法描述:影像滑鼠移動事件。根據當前是否有載入影像檔案,動態切換滑鼠模式(MouseMo
|
de)。若無檔案則設為使用者模式(mmUser),否則根據 NowClick 狀態呼叫 View
|
MouseMode 切換至對應的檢視模式。
|
============================================================================== }
|
procedure TCB_IMGPSScanX.ISB1ImageMouseMove(Sender: TObject; Shift: TShiftState;
|
X, Y: Integer);
|
begin
|
//Edit1.SetFocus;
|
//TImageScrollBox(Sender).SetFocus;
|
|
if TImageScrollBox(Sender).FileName = '' then
|
TImageScrollBox(Sender).MouseMode := mmUser
|
Else
|
ViewMouseMode(NowClick);
|
|
ISB1.AlwaysShowAnnotations := False;
|
|
// if TImageScrollBox(Sender).FileName = '' then
|
// begin
|
////ShowMessage('AAA');
|
//Label3.Caption:='FileName='+TImageScrollBox(Sender).FileName+' time='+FormatDateTime('yyyy/mm/dd HH:MM:SS', now);
|
// TImageScrollBox(Sender).MouseMode := mmUser
|
// end
|
// Else
|
// begin
|
//Label3.Caption:='FileName='+TImageScrollBox(Sender).FileName;
|
// ViewMouseMode(NowClick);
|
// end;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:ISB1ImageMouseUp
|
引用相依:SaveQuality, SaveToFile, TJpegGraphic
|
方法描述:影像滑鼠放開事件。處理多種滑鼠模式:在 mmDelete 模式下觸發刪除功能;在
|
旋轉模式(mmR90等)下儲存旋轉後的影像檔案,並同步更新預覽圖(SelectISB)
|
與清空檢核記錄。最後針對縮放或拖曳模式更新捲軸位置數據。
|
============================================================================== }
|
procedure TCB_IMGPSScanX.ISB1ImageMouseUp(Sender: TObject; Button: TMouseButton;
|
Shift: TShiftState; X, Y: Integer);
|
Var
|
p : Integer;
|
ISB : TImageScrollBox;
|
begin
|
case TImageScrollBox(Sender).MouseMode of
|
mmDelete:
|
begin
|
PM508Click(Self);
|
end;
|
mmR90,mmR180,mmR270:
|
begin
|
if TImageScrollBox(Sender).Graphic.ImageFormat <> ifBlackWhite then
|
begin
|
TJpegGraphic(TImageScrollBox(Sender).Graphic).SaveQuality := 30;
|
TJpegGraphic(TImageScrollBox(Sender).Graphic).SaveToFile(TImageScrollBox(Sender).FileName);
|
end
|
Else
|
TImageScrollBox(Sender).SaveToFile(TImageScrollBox(Sender).FileName);
|
|
SelectISB.Graphic.Assign(TImageScrollBox(Sender).Graphic);
|
SelectISB.Redraw(True);
|
FitPreViewISB;
|
ISBClick(SelectISB);
|
ClearErrini(NowCaseno,MyTreeNode1); //清掉檢核記錄
|
end;
|
end;
|
|
ISB := TImageScrollBox(Sender);
|
if (ISB.MouseMode = mmZoom) or (ISB.MouseMode = mmDrag) then
|
SetScrollData(ISB,ISB.HorzScrollBar.Position,ISB.VertScrollBar.Position,ISB.ZoomPercent);
|
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:ScrollBox1MouseEnter
|
引用相依:
|
方法描述:當滑鼠進入捲軸區域時,自動將焦點設定至 ScrollBox1。
|
============================================================================== }
|
procedure TCB_IMGPSScanX.ScrollBox1MouseEnter(Sender: TObject);
|
begin
|
ScrollBox1.SetFocus;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:FindISB2View
|
引用相依:
|
方法描述:根據檢視模式,在畫面中尋找下一個可顯示影像的 TImageScrollBox。遍歷 ISB
|
1-ISB8,檢查 FileName 是否為空;若已滿則會清空特定位置影像並重新開始,
|
確保影像載入有對應視窗。
|
============================================================================== }
|
Function TCB_IMGPSScanX.FindISB2View(Vmode:Integer):TImageScrollBox; //找空的ISB來顯示
|
var
|
i,n : Integer;
|
ISB : TImageScrollBox;
|
begin
|
case Vmode of
|
0 : n := 1;
|
1 : n := 2;
|
2 : n := 4;
|
3 : n := 6;
|
4 : n := 8;
|
end;
|
for i := 1 to 8 do
|
begin
|
if i > n then Break;
|
ISB := TImageScrollBox(FindComponent('ISB'+inttostr(i)));
|
if (i = n) and (ISB.FileName <> '') then
|
begin
|
clearView(i);
|
Result := ISB1;
|
end
|
Else if ISB.FileName = '' then
|
Result := ISB;
|
end;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:ImageScrollBox1NewGraphic
|
引用相依:ConvertToBW, TDibGraphic
|
方法描述:當載入新影像時觸發。將當前 Graphic 內容同步至黑白影像處理元件(ISB_BW)
|
,若原始影像非黑白格式則執行 ConvertToBW 轉換。
|
============================================================================== }
|
procedure TCB_IMGPSScanX.ImageScrollBox1NewGraphic(const Graphic: TDibGraphic);
|
begin
|
IF ImageScrollBox1.Graphic.Empty Then Exit;
|
ISB_BW.Graphic.Assign(ImageScrollBox1.Graphic);
|
If ImageScrollBox1.Graphic.ImageFormat <> ifBlackWhite Then
|
begin
|
ConvertToBW(ISB_BW.Graphic);
|
end;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:GetScrollData
|
引用相依:
|
方法描述:根據傳入的影像捲軸盒(ISB)名稱,從 ScrollRec 陣列中提取其儲存的水平、垂
|
直捲軸位置及縮放比例。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.GetScrollData(ISB:TImageScrollBox;Var HS,VS:Integer;Var iRate:Single);
|
var
|
index : Integer;
|
begin
|
index := strtoint(copy(ISB.Name,4,1));
|
HS := ScrollRec[Index].HScroll;
|
VS := ScrollRec[Index].VScroll;
|
iRate := ScrollRec[Index].Rate;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:SetScrollData
|
引用相依:
|
方法描述:將指定的水平、垂直捲軸位置與縮放比例存入對應影像視窗索引的 ScrollRec
|
記錄中。
|
============================================================================== }
|
Procedure TCB_IMGPSScanX.SetScrollData(ISB:TImageScrollBox;HS,VS:Integer;iRate:Single);
|
var
|
index : Integer;
|
begin
|
index := strtoint(copy(ISB.Name,4,1));
|
ScrollRec[Index].HScroll := HS;
|
ScrollRec[Index].VScroll := VS;
|
ScrollRec[Index].Rate := iRate;
|
end;
|
|
|
{ ==============================================================================
|
方法名稱:FindMpsView
|
引用相依:
|
方法描述:根據當前的檢視模式(Vmode),在 8 個影像視窗中尋找適合載入下一個影像的
|
視窗組件。函式會根據 1x1 到 4x2 的佈局決定搜尋上限,優先回傳檔名為空的
|
視窗;若視窗已滿,則清空指定位置的顯示並回傳主視窗 ISB1。
|
============================================================================== }
|
Function TCB_IMGPSScanX.FindMpsView(Vmode: Integer):TImageScrollBox;
|
var
|
i,n : Integer;
|
ISB : TImageScrollBox;
|
begin
|
case Vmode of
|
0 : n := 1;
|
1 : n := 2;
|
2 : n := 4;
|
3 : n := 6;
|
4 : n := 8;
|
end;
|
for i := 1 to 8 do
|
begin
|
if i > n then Break;
|
ISB := TImageScrollBox(FindComponent('ISB'+inttostr(i)));
|
if (i = n) and (ISB.FileName <> '') then
|
begin
|
clearView(i);
|
Result := ISB1;
|
end
|
Else if ISB.FileName = '' then
|
Result := ISB;
|
end;
|
end;
|