📄 eermodel.pas
字号:
IsChanged:=False;
Need2RefreshNavImg:=False;
PaintingToSpecialCanvas:=False;
//Create List for Actionlog
ActionLog:=TObjectList.Create;
CurrentAction:=-1;
//Create Popupmenus
CreatePopupMenus(AOwner);
LastTableEditorPage:=0;
LastRelEditorPage:=0;
UseVersionHistroy:=True;
AutoIncVersion:=True;
IDModel:=0;
IDVersion:=0;
VersionStr:='1.0.0.0';
DefSaveDBConn:='';
MouseOverObj:=nil;
MouseOverSubObj:=nil;
RegionColors:=TStringList.Create;
//Initialise with default colors
RegionColors.Text:=DMEER.DefaultRegionColors;
PluginData:=TObjectList.Create;
StoredSQLCmds:=TObjectList.Create;
PosMarkers:=TObjectList.Create;
for i:=0 to 10 do
begin
//new(thePosMarker);
thePosMarker:=TPosMarker.Create;
thePosMarker.ZoomFac:=-1;
thePosMarker.X:=0;
thePosMarker.Y:=0;
PosMarkers.Add(thePosMarker);
end;
DisableModelRefresh:=False;
UsePositionGrid:=DMEER.UsePositionGrid;
PositionGrid.X:=DMEER.PositionGrid.X;
PositionGrid.Y:=DMEER.PositionGrid.Y;
TableNameInRefs:=DMEER.TableNameInRefs;
DefaultTableType:=DMEER.DefaultTableType;
ActivateRefDefForNewRelations:=DMEER.ActivateRefDefForNewRelations;
FKPrefix:=DMEER.FKPrefix;
FKPostfix:=DMEER.FKPostfix;
CreateFKRefDefIndex:=DMEER.CreateFKRefDefIndex;
ModelIsBeingCleared:=False;
ReadOnly:=False;
LinkedModels:=TObjectList.Create;
CreateSQLforLinkedObjects:=False;
end;
destructor TEERModel.Destroy;
var i: integer;
begin
ModelIsBeingCleared:=True;
TablePrefix.Free;
//Free Datatypes
DatatypeGroups.Free;
CommonDataType.Free;
Datatypes.Free;
//Free Reserved Words
ReservedWords.Free;
//Free Bitmaps
TblHeaderBmp.Free;
TblHeaderRightBmp.Free;
TblHeaderLinkedBmp.Free;
TblHeaderRightLinkedBmp.Free;
FieldBmp.Free;
FieldKeyBmp.Free;
IndexBmp.Free;
PopUpMenuImgs.Free;
Index_FKBmp.Free;
Field_FKBmp.Free;
SelectionRect.Free;
GridPaintBox.Free;
//Delete all Actions in List
for i:=0 to ActionLog.Count-1 do
DeleteAction(ActionLog[0]);
ActionLog.Free;
RegionColors.Free;
PluginData.Free;
StoredSQLCmds.Free;
PosMarkers.Free;
LinkedModels.Free;
inherited Destroy;
end;
// ---------------------------------------------------
// Mouse action
procedure TEERModel.DoMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if(Button=mbLeft)then
begin
//Make shure that no TextImput has the focus
if(Application.MainForm.ActiveControl<>nil)then
Application.MainForm.ActiveControl:=nil;
if(DMEER.CurrentWorkTool=wtPointer)or
(DMEER.CurrentWorkTool=wtRegion)or
(DMEER.CurrentWorkTool=wtImage)then
begin
DeSelectAllObjs(nil);
mouse_absx:=Mouse.CursorPos.X;
mouse_absy:=Mouse.CursorPos.Y;
mouse_posx:=X;
mouse_posy:=Y;
SetSelectionRectPos(X, Y,
1, 1);
MouseIsDown:=True;
end;
if(DMEER.CurrentWorkTool=wtTable)then
begin
NewTable(ReEvalZoomFac(X), ReEvalZoomFac(Y), True);
DMEER.SetWorkTool(wtPointer);
end;
if(DMEER.CurrentWorkTool=wtNote)then
begin
NewNote(ReEvalZoomFac(X), ReEvalZoomFac(Y), True);
DMEER.SetWorkTool(wtPointer);
end;
if(DMEER.CurrentWorkTool=wtHand)then
begin
mouse_absx:=Mouse.CursorPos.X;
mouse_absy:=Mouse.CursorPos.Y;
if(Name='GridPaintBox')then
begin
mouse_posx:=TForm(TPanel(parent).parent).HorzScrollBar.Position;
mouse_posy:=TForm(TPanel(parent).parent).VertScrollBar.Position;
end
else
begin
mouse_posx:=TForm(parent).HorzScrollBar.Position;
mouse_posy:=TForm(parent).VertScrollBar.Position;
end;
MouseIsDown:=True;
end;
if(DMEER.CurrentWorkTool=wtZoomIn)then
ZoomIn(X, Y);
if(DMEER.CurrentWorkTool=wtZoomOut)then
ZoomOut(X, Y);
end;
end;
procedure TEERModel.DoMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var SelRectWidth, SelRectHeight: integer;
begin
ClearMouseOverObj;
if(Shift=[ssLeft])and(MouseIsDown)then
begin
if(DMEER.CurrentWorkTool=wtPointer)or
(DMEER.CurrentWorkTool=wtRegion)or
(DMEER.CurrentWorkTool=wtImage)then
begin
//Resize SelectionRect
SelRectWidth:=Mouse.CursorPos.X-mouse_absx;
SelRectHeight:=Mouse.CursorPos.Y-mouse_absy;
//update left-top corner if needed
if(SelRectWidth<0)then
SelectionRect.Left:=mouse_posx+SelRectWidth;
if(SelRectHeight<0)then
SelectionRect.Top:=mouse_posy+SelRectHeight;
SetSelectionRectPos(SelectionRect.Left, SelectionRect.Top,
abs(SelRectWidth), abs(SelRectHeight));
//Shop SelectionRect
SelectionRect.Visible:=True;
end;
if(DMEER.CurrentWorkTool=wtHand)then
begin
if(Name='GridPaintBox')then
begin
TForm(TPanel(parent).parent).HorzScrollBar.Position:=
mouse_posx+(Mouse.CursorPos.X-mouse_absx)*-1;
TForm(TPanel(parent).parent).VertScrollBar.Position:=
mouse_posy+(Mouse.CursorPos.Y-mouse_absy)*-1;
end
else
begin
if(TForm(parent).HorzScrollBar<>nil)then
begin
TForm(parent).HorzScrollBar.Position:=
mouse_posx+(Mouse.CursorPos.X-mouse_absx)*-1;
{$IFDEF LINUX}
if(TForm(parent).HorzScrollBar.Position<0)then
TForm(parent).HorzScrollBar.Position:=0;
if(TForm(parent).HorzScrollBar.Position>TForm(parent).HorzScrollBar.Range-TForm(parent).ClientWidth)then
TForm(parent).HorzScrollBar.Position:=TForm(parent).HorzScrollBar.Range-TForm(parent).ClientWidth;
{$ENDIF}
end;
if(TForm(parent).HorzScrollBar<>nil)then
begin
TForm(parent).VertScrollBar.Position:=
mouse_posy+(Mouse.CursorPos.Y-mouse_absy)*-1;
{$IFDEF LINUX}
if(TForm(parent).VertScrollBar.Position<0)then
TForm(parent).VertScrollBar.Position:=0;
if(TForm(parent).VertScrollBar.Position>TForm(parent).VertScrollBar.Range-TForm(parent).ClientHeight)then
TForm(parent).VertScrollBar.Position:=TForm(parent).VertScrollBar.Range-TForm(parent).ClientHeight;
{$ENDIF}
end;
end;
end;
end;
end;
procedure TEERModel.DoMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var theImage: TEERImage;
thePoint: TPoint;
begin
if(Button=mbLeft)then
begin
MouseIsDown:=False;
if(DMEER.CurrentWorkTool=wtPointer)and
(SelectionRect.Visible)then
begin
SelectionRect.Visible:=False;
SelectObjsInSelectionRect;
end;
if(DMEER.CurrentWorkTool=wtRegion)and
(SelectionRect.Visible)then
begin
SelectionRect.Visible:=False;
NewRegion(ReEvalZoomFac(SelectionRect.Left),
ReEvalZoomFac(SelectionRect.Top),
ReEvalZoomFac(SelectionRect.Width),
ReEvalZoomFac(SelectionRect.Height), True);
DMEER.SetWorkTool(wtPointer);
end;
if(DMEER.CurrentWorkTool=wtImage)and
(SelectionRect.Visible)then
begin
SelectionRect.Visible:=False;
theImage:=NewImage(ReEvalZoomFac(SelectionRect.Left),
ReEvalZoomFac(SelectionRect.Top),
ReEvalZoomFac(SelectionRect.Width),
ReEvalZoomFac(SelectionRect.Height), True);
theImage.LoadImageFromFile;
DMEER.SetWorkTool(wtPointer);
end;
if(Not(DisableModelRefresh))then
DMEER.RefreshInfoPalette;
if(DMEER.CurrentWorkTool=wtPlacementFromFile)or
(DMEER.CurrentWorkTool=wtPlacementFromDB)or
(DMEER.CurrentWorkTool=wtPlacementFromLibrary)then
begin
thePoint.X:=ReEvalZoomFac(X);
thePoint.Y:=ReEvalZoomFac(Y);
if(DMEER.CurrentWorkTool=wtPlacementFromFile)then
begin
DMEER.SetWorkTool(wtPointer);
sendCLXEvent(Application.MainForm.Handle, QCustomEvent_create(QEventType_PlaceModelFromFile, @thePoint));
end
else if(DMEER.CurrentWorkTool=wtPlacementFromDB)then
begin
DMEER.SetWorkTool(wtPointer);
sendCLXEvent(Application.MainForm.Handle, QCustomEvent_create(QEventType_PlaceModelFromDB, @thePoint));
end
else
begin
DMEER.SetWorkTool(wtPointer);
sendCLXEvent(Application.MainForm.Handle, QCustomEvent_create(QEventType_PlaceModelFromLibrary, @thePoint));
end;
end;
end;
end;
procedure TEERModel.MouseEnter(AControl: TControl);
begin
// set Screen.Cursor
//DMEER.SetWorkToolCurser(DMEER.CurrentWorkTool);
end;
procedure TEERModel.MouseLeave(AControl: TControl);
begin
// restore the cursor
//Screen.Cursor:=crDefault;
end;
// ---------------------------------------------------
// Zoom Fac - functions
function TEERModel.EvalZoomFac(thevalue: integer): integer;
begin
EvalZoomFac:=round(thevalue*(ZoomFac/100));
end;
function TEERModel.ReEvalZoomFac(thevalue: integer): integer;
begin
ReEvalZoomFac:=round(thevalue/(ZoomFac/100));
end;
procedure TEERModel.SetZoomFac(NewZoomFac: double; X: integer = -1; Y: integer = -1);
var hsc, vsc, hscW, hscH,
x2scroll, y2scroll: integer;
begin
DMEER.DisablePaint:=True;
try
ZoomFac:=NewZoomFac;
hsc:=TForm(parent).HorzScrollBar.Position;
vsc:=TForm(parent).VertScrollBar.Position;
if(X>-1)and(Y>-1)then
begin
x2scroll:=((X-TForm(parent).HorzScrollBar.Position)-(TForm(parent).Width div 2));
y2scroll:=((Y-TForm(parent).VertScrollBar.Position)-(TForm(parent).Height div 2))
end
else
begin
x2scroll:=0;
y2scroll:=0;
end;
hscW:=TForm(parent).HorzScrollBar.Range;
hscH:=TForm(parent).VertScrollBar.Range;
//if the model becomes bigger than the form, reset position
if(Width<TForm(parent).Width)and
(EvalZoomFac(EERModel_Width)>TForm(parent).Width)then
Left:=0;
if(Height<TForm(parent).Height)and
(EvalZoomFac(EERModel_Height)>TForm(parent).Height)then
Top:=0;
//If a scrollbar disapears, reset precached Values
if(Width>TForm(parent).Width)and
(EvalZoomFac(EERModel_Width)<TForm(parent).Width)then
begin
Width:=EvalZoomFac(EERModel_Width);
vsc:=TForm(parent).VertScrollBar.Position;
hscW:=TForm(parent).HorzScrollBar.Range;
end
else
Width:=EvalZoomFac(EERModel_Width);
//If a scrollbar disapears, reset precached Values
if(Height>TForm(parent).Height)and
(EvalZoomFac(EERModel_Height)<TForm(parent).Height)then
begin
Height:=EvalZoomFac(EERModel_Height);
hsc:=TForm(parent).HorzScrollBar.Position;
hscW:=TForm(parent).HorzScrollBar.Range;
end
else
Height:=EvalZoomFac(EERModel_Height);
if(Width>=TForm(parent).Width)then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -