Skip to content

Commit

Permalink
Начало #88, градусы вроде работают
Browse files Browse the repository at this point in the history
  • Loading branch information
zamtmn committed Jan 15, 2024
1 parent 86a1850 commit da6c455
Show file tree
Hide file tree
Showing 14 changed files with 139 additions and 73 deletions.
6 changes: 6 additions & 0 deletions cad_source/components/zmath/uzemathutils.pas
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function zeDimensionToUnicodeString(const value:Double; const f:TzeUnitsFormat):
function zeNonDimensionToString(const value:Double; const f:TzeUnitsFormat):String;
function zeAngleDegToString(const value:Double; const f:TzeUnitsFormat):String;
function zeAngleToString(const value:Double; const f:TzeUnitsFormat):String;
function zeStringToAngle(const value:String; const f:TzeUnitsFormat):Double;
function CreateDefaultUnitsFormat:TzeUnitsFormat;
implementation
const
Expand Down Expand Up @@ -261,6 +262,11 @@ function GetAngleDegreesMinutesSeconds:String;
end;
end;
end;
function zeStringToAngle(const value:String; const f:TzeUnitsFormat):Double;
begin
result:=degtorad(StrToFloat(value));
end;

function zeAngleDegToString(const value:Double; const f:TzeUnitsFormat):String;
var
ff:TzeUnitsFormat;
Expand Down
4 changes: 2 additions & 2 deletions cad_source/components/zobjectinspector/zcobjectinspector.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,7 @@ procedure TGDBobjinsp.MouseMove(Shift: TShiftState; X, Y: Integer);
//Freemem(pointer(peditor));
EDContext.ppropcurrentedit:=pp;
end;
PEditor:=pp^.PTypeManager^.CreateEditor(@self,pp.rect,pp^.valueAddres,nil,false,'этого не должно тут быть',rowh).Editor;
PEditor:=pp^.PTypeManager^.CreateEditor(@self,pp.rect,pp^.valueAddres,nil,false,'этого не должно тут быть',rowh,CurrUnitsFormat).Editor;
if PEditor<>nil then
begin
//PEditor^.show;
Expand Down Expand Up @@ -1719,7 +1719,7 @@ procedure TGDBobjinsp.createeditor(pp:PPropertyDeskriptor);
if assigned(pp^.Decorators.OnCreateEditor) then
TED:=pp^.Decorators.OnCreateEditor(self,tr,pp^.valueAddres,@vsa,false,pp^.PTypeManager)
else
TED:=pp^.PTypeManager^.CreateEditor(self,tr,pp^.valueAddres,@vsa,{false}true,initialvalue,rowh);
TED:=pp^.PTypeManager^.CreateEditor(self,tr,pp^.valueAddres,@vsa,{false}true,initialvalue,rowh,CurrUnitsFormat);
case ted.Mode of
TEM_Integrate:begin
TED.Editor.SetEditorBounds(pp,INTFObjInspShowOnlyHotFastEditors);
Expand Down
24 changes: 12 additions & 12 deletions cad_source/components/zobjectinspector/zcobjectinspectoreditors.pas
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ interface
UEnumDescriptor,zcobjectinspector,Forms,sysutils,
Graphics,LCLType,Themes,uzctnrvectorstrings,
varmandef,Varman,uzbtypes,usupportgui,
gzctnrVectorTypes,StdCtrls,Controls,Classes,uzbstrproc;
gzctnrVectorTypes,StdCtrls,Controls,Classes,uzbstrproc,uzedimensionaltypes;
type
TBaseTypesEditors=class
class function BaseCreateEditor (TheOwner:TPropEditorOwner;rect:trect;pinstance:pointer;psa:PTZctnrVectorStrings;FreeOnLostFocus:boolean;InitialValue:String;ptdesc:PUserTypeDescriptor;preferedHeight:integer):TEditorDesc;
class function BooleanCreateEditor (TheOwner:TPropEditorOwner;rect:trect;pinstance:pointer;psa:PTZctnrVectorStrings;FreeOnLostFocus:boolean;InitialValue:String;ptdesc:PUserTypeDescriptor;preferedHeight:integer):TEditorDesc;
class function TEnumDataCreateEditor (TheOwner:TPropEditorOwner;rect:trect;pinstance:pointer;psa:PTZctnrVectorStrings;FreeOnLostFocus:boolean;InitialValue:String;ptdesc:PUserTypeDescriptor;preferedHeight:integer):TEditorDesc;
class function EnumDescriptorCreateEditor (TheOwner:TPropEditorOwner;rect:trect;pinstance:pointer;psa:PTZctnrVectorStrings;FreeOnLostFocus:boolean;InitialValue:String;ptdesc:PUserTypeDescriptor;preferedHeight:integer):TEditorDesc;
class function BaseCreateEditor (TheOwner:TPropEditorOwner;rect:trect;pinstance:pointer;psa:PTZctnrVectorStrings;FreeOnLostFocus:boolean;InitialValue:String;ptdesc:PUserTypeDescriptor;preferedHeight:integer;f:TzeUnitsFormat):TEditorDesc;
class function BooleanCreateEditor (TheOwner:TPropEditorOwner;rect:trect;pinstance:pointer;psa:PTZctnrVectorStrings;FreeOnLostFocus:boolean;InitialValue:String;ptdesc:PUserTypeDescriptor;preferedHeight:integer;f:TzeUnitsFormat):TEditorDesc;
class function TEnumDataCreateEditor (TheOwner:TPropEditorOwner;rect:trect;pinstance:pointer;psa:PTZctnrVectorStrings;FreeOnLostFocus:boolean;InitialValue:String;ptdesc:PUserTypeDescriptor;preferedHeight:integer;f:TzeUnitsFormat):TEditorDesc;
class function EnumDescriptorCreateEditor (TheOwner:TPropEditorOwner;rect:trect;pinstance:pointer;psa:PTZctnrVectorStrings;FreeOnLostFocus:boolean;InitialValue:String;ptdesc:PUserTypeDescriptor;preferedHeight:integer;f:TzeUnitsFormat):TEditorDesc;
end;
implementation
class function TBaseTypesEditors.BaseCreateEditor;
Expand All @@ -47,12 +47,12 @@ class function TBaseTypesEditors.BaseCreateEditor;
result.mode:=TEM_Nothing;
if (psa=nil)or(psa^.count=0) then
begin
propeditor:=TPropEditor.Create(theowner,PInstance,ptdesc^,FreeOnLostFocus);
propeditor:=TPropEditor.Create(theowner,PInstance,ptdesc^,FreeOnLostFocus,f);

edit:=TEdit.Create(propeditor);
edit.AutoSize:=false;
if initialvalue='' then
edit.Text:=ptdesc^.GetValueAsString(pinstance)
edit.Text:=ptdesc^.GetFormattedValueAsString(pinstance,f)
else
edit.Text:=initialvalue;
edit.OnKeyPress:=propeditor.keyPress;
Expand All @@ -64,13 +64,13 @@ class function TBaseTypesEditors.BaseCreateEditor;
end
else
begin
propeditor:=TPropEditor.Create(theowner,PInstance,ptdesc^,FreeOnLostFocus);
propeditor:=TPropEditor.Create(theowner,PInstance,ptdesc^,FreeOnLostFocus,f);
cbedit:=TComboBox.Create(propeditor);
{$IFNDEF DELPHI}
cbedit.AutoSize:=false;
{$ENDIF}
if initialvalue='' then
cbedit.Text:=ptdesc^.GetValueAsString(pinstance)
cbedit.Text:=ptdesc^.GetFormattedValueAsString(pinstance,f)
else
cbedit.Text:=initialvalue;
cbedit.OnKeyPress:=propeditor.keyPress;
Expand Down Expand Up @@ -101,7 +101,7 @@ class function TBaseTypesEditors.BooleanCreateEditor;
cbedit:TComboBox;
propeditor:TPropEditor;
begin
propeditor:=TPropEditor.Create(theowner,PInstance,ptdesc^,FreeOnLostFocus);
propeditor:=TPropEditor.Create(theowner,PInstance,ptdesc^,FreeOnLostFocus,f);
cbedit:=TComboBox.Create(propeditor);
cbedit.Text:=ptdesc^.GetValueAsString(pinstance);
cbedit.OnChange:=propeditor.EditingProcess;
Expand All @@ -127,7 +127,7 @@ class function TBaseTypesEditors.TEnumDataCreateEditor;
ir:itrec;
p:pString;
begin
propeditor:=TPropEditor.Create(theowner,PInstance,ptdesc^,FreeOnLostFocus);
propeditor:=TPropEditor.Create(theowner,PInstance,ptdesc^,FreeOnLostFocus,f);
cbedit:=TComboBox.Create(propeditor);
cbedit.Text:=ptdesc^.GetValueAsString(pinstance);
cbedit.OnChange:=propeditor.EditingProcess;
Expand Down Expand Up @@ -157,7 +157,7 @@ class function TBaseTypesEditors.EnumDescriptorCreateEditor;
number:LongWord;
p:pString;
begin
propeditor:=TPropEditor.Create(theowner,PInstance,ptdesc^,FreeOnLostFocus);
propeditor:=TPropEditor.Create(theowner,PInstance,ptdesc^,FreeOnLostFocus,f);
cbedit:=TComboBox.Create(propeditor);
cbedit.Text:=ptdesc^.GetValueAsString(pinstance);
cbedit.OnChange:=propeditor.EditingProcess;
Expand Down
51 changes: 48 additions & 3 deletions cad_source/components/zscript/UBaseTypeDescriptor.pas
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,37 @@ TBaseTypeManipulator<T>=class
TOrdinalTypeManipulator<T>=class(TBaseTypeManipulator<T>)
class function GetValueAsString(const data:T):TInternalScriptString;
class function GetFormattedValueAsString(const data:T; const f:TzeUnitsFormat):TInternalScriptString;
class procedure setFormattedValueAsString(var data:T; const f:TzeUnitsFormat;Value:TInternalScriptString);
class procedure SetValueFromString(var data:T;Value:TInternalScriptString);
end;
TBoolTypeManipulator<T>=class(TBaseTypeManipulator<T>)
class function GetValueAsString(const data:T):TInternalScriptString;
class function GetFormattedValueAsString(const data:T; const f:TzeUnitsFormat):TInternalScriptString;
class procedure setFormattedValueAsString(var data:T; const f:TzeUnitsFormat;Value:TInternalScriptString);
class procedure SetValueFromString(var data:T;Value:TInternalScriptString);
end;
TFloatTypeManipulator<T>=class(TBaseTypeManipulator<T>)
class function GetValueAsString(const data:T):TInternalScriptString;
class function GetFormattedValueAsString(const data:T; const f:TzeUnitsFormat):TInternalScriptString;
class procedure setFormattedValueAsString(var data:T; const f:TzeUnitsFormat;Value:TInternalScriptString);
class procedure SetValueFromString(var data:T;Value:TInternalScriptString);
end;
TStringTypeManipulator<T>=class(TBaseTypeManipulator<T>)
class function GetValueAsString(const data:T):TInternalScriptString;
class function GetFormattedValueAsString(const data:T; const f:TzeUnitsFormat):TInternalScriptString;
class procedure setFormattedValueAsString(var data:T; const f:TzeUnitsFormat;Value:TInternalScriptString);
class procedure SetValueFromString(var data:T;Value:TInternalScriptString);
end;
TAnsiStringTypeManipulator<T>=class(TBaseTypeManipulator<T>)
class function GetValueAsString(const data:T):TInternalScriptString;
class function GetFormattedValueAsString(const data:T; const f:TzeUnitsFormat):TInternalScriptString;
class procedure setFormattedValueAsString(var data:T; const f:TzeUnitsFormat;Value:TInternalScriptString);
class procedure SetValueFromString(var data:T;Value:TInternalScriptString);
end;
TPointerTypeManipulator<T>=class(TBaseTypeManipulator<T>)
class function GetValueAsString(const data:T):TInternalScriptString;
class function GetFormattedValueAsString(const data:T; const f:TzeUnitsFormat):TInternalScriptString;
class procedure setFormattedValueAsString(var data:T; const f:TzeUnitsFormat;Value:TInternalScriptString);
class procedure SetValueFromString(var data:T;Value:TInternalScriptString);
end;
PBaseTypeDescriptor=^{BaseTypeDescriptor}TUserTypeDescriptor;
Expand All @@ -72,7 +78,8 @@ TPointerTypeManipulator<T>=class(TBaseTypeManipulator<T>)
constructor init(tname:string;pu:pointer);

function GetValueAsString(pinstance:Pointer):TInternalScriptString;virtual;
function GetFormattedValueAsString(PInstance:Pointer; const f:TzeUnitsFormat):TInternalScriptString;virtual;
function GetFormattedValueAsString(PInstance:Pointer;const f:TzeUnitsFormat):TInternalScriptString;virtual;
procedure SetFormattedValueFromString(PInstance:Pointer;const f:TzeUnitsFormat;Value:TInternalScriptString);virtual;
function CreateProperties(const f:TzeUnitsFormat;mode:PDMode;PPDA:PTPropertyDeskriptorArray;Name:TInternalScriptString;PCollapsed:Pointer;ownerattrib:Word;var bmode:Integer;const addr:Pointer;ValKey,ValType:TInternalScriptString):PTPropertyDeskriptorArray;virtual;
procedure SetValueFromString(PInstance:Pointer;Value:TInternalScriptString);virtual;
procedure InitInstance(PInstance:Pointer);virtual;
Expand Down Expand Up @@ -302,13 +309,24 @@ class function TOrdinalTypeManipulator<T>.GetFormattedValueAsString(const data:T
begin
result:=GetValueAsString(data);
end;
class procedure TOrdinalTypeManipulator<T>.setFormattedValueAsString(var data:T; const f:TzeUnitsFormat;Value:TInternalScriptString);
var
td:T;
e:integer;
begin
val(Value,td,e);
if e=0 then
data:=td;
end;

class function TFloatTypeManipulator<T>.GetValueAsString(const data:T):TInternalScriptString;
begin
//Str(data:10:10,result);
result:=data.tostring;
if pos('.',result)<1 then
result:=result+'.0';
end;

class function TFloatTypeManipulator<T>.GetFormattedValueAsString(const data:T; const f:TzeUnitsFormat):TInternalScriptString;
begin
result:=zeDimensionToString(data,f);
Expand All @@ -322,7 +340,15 @@ class procedure TFloatTypeManipulator<T>.SetValueFromString(var data:T;Value:TIn
if error=0 then
data:=td;
end;

class procedure TFloatTypeManipulator<T>.setFormattedValueAsString(var data:T; const f:TzeUnitsFormat;Value:TInternalScriptString);
var
td:T;
error:integer;
begin
val(value,td,error);
if error=0 then
data:=td;
end;
class function TStringTypeManipulator<T>.GetValueAsString(const data:T):TInternalScriptString;
begin
result:=uni2cp(data);
Expand All @@ -335,7 +361,10 @@ class procedure TStringTypeManipulator<T>.SetValueFromString(var data:T;Value:TI
begin
data:=cp2uni(Value);
end;

class procedure TStringTypeManipulator<T>.setFormattedValueAsString(var data:T; const f:TzeUnitsFormat;Value:TInternalScriptString);
begin
data:=cp2uni(Value);
end;

class function TAnsiStringTypeManipulator<T>.GetValueAsString(const data:T):TInternalScriptString;
begin
Expand All @@ -349,6 +378,11 @@ class procedure TAnsiStringTypeManipulator<T>.SetValueFromString(var data:T;Valu
begin
data:=cp2ansi(Value);
end;
class procedure TAnsiStringTypeManipulator<T>.setFormattedValueAsString(var data:T; const f:TzeUnitsFormat;Value:TInternalScriptString);
begin
data:=cp2uni(Value);
end;


class function TBoolTypeManipulator<T>.GetValueAsString(const data:T):TInternalScriptString;
begin
Expand All @@ -362,6 +396,10 @@ class function TBoolTypeManipulator<T>.GetFormattedValueAsString(const data:T; c
begin
result:=GetValueAsString(data);
end;
class procedure TBoolTypeManipulator<T>.setFormattedValueAsString(var data:T; const f:TzeUnitsFormat;Value:TInternalScriptString);
begin
data:=StrToBoolDef(Value,False);
end;
constructor BaseTypeDescriptor<T,TManipulator>.init(tname:string;pu:pointer);
begin
inherited init(sizeof(t),tname,pu);
Expand Down Expand Up @@ -425,6 +463,10 @@ procedure BaseTypeDescriptor<T,TManipulator>.SetValueFromString;
begin
TManipulator.SetValueFromString(TManipulator.pt(PInstance)^,Value);
end;
procedure BaseTypeDescriptor<T,TManipulator>.SetFormattedValueFromString(PInstance:Pointer;const f:TzeUnitsFormat;Value:TInternalScriptString);
begin
TManipulator.setFormattedValueAsString(TManipulator.pt(PInstance)^,f,Value);
end;
procedure BaseTypeDescriptor<T,TManipulator>.InitInstance(PInstance:Pointer);
begin
TManipulator.Initialize(TManipulator.pt(PInstance)^);
Expand Down Expand Up @@ -462,6 +504,9 @@ class function TPointerTypeManipulator<T>.GetValueAsString(const data:T):TIntern
class procedure TPointerTypeManipulator<T>.SetValueFromString(var data:T;Value:TInternalScriptString);
begin
end;
class procedure TPointerTypeManipulator<T>.setFormattedValueAsString(var data:T; const f:TzeUnitsFormat;Value:TInternalScriptString);
begin
end;
class function TPointerTypeManipulator<T>.GetFormattedValueAsString(const data:T; const f:TzeUnitsFormat):TInternalScriptString;
begin
result:=GetValueAsString(data);
Expand Down
4 changes: 2 additions & 2 deletions cad_source/components/zscript/UEnumDescriptor.pas
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface
Value:PTByteVector;
constructor init(size:Integer;tname:string;pu:pointer);
function CreateProperties(const f:TzeUnitsFormat;mode:PDMode;PPDA:PTPropertyDeskriptorArray;Name:TInternalScriptString;PCollapsed:Pointer;ownerattrib:Word;var bmode:Integer;const addr:Pointer;ValKey,ValType:TInternalScriptString):PTPropertyDeskriptorArray;virtual;
function CreateEditor(TheOwner:TPropEditorOwner;rect:trect;pinstance:pointer;psa:PTZctnrVectorStrings;FreeOnLostFocus:boolean;InitialValue:TInternalScriptString;preferedHeight:integer):TEditorDesc;virtual;
function CreateEditor(TheOwner:TPropEditorOwner;rect:trect;pinstance:pointer;psa:PTZctnrVectorStrings;FreeOnLostFocus:boolean;InitialValue:TInternalScriptString;preferedHeight:integer;f:TzeUnitsFormat):TEditorDesc;virtual;
function GetNumberInArrays(addr:Pointer;out number:LongWord):Boolean;virtual;
//function Serialize(PInstance:Pointer;SaveFlag:Word;var membuf:PTZctnrVectorBytes;var linkbuf:PGDBOpenArrayOfTObjLinkRecord;var sub:integer):integer;virtual;
//function DeSerialize(PInstance:Pointer;SaveFlag:Word;var membuf:TZctnrVectorBytes;linkbuf:PGDBOpenArrayOfTObjLinkRecord):integer;virtual;
Expand Down Expand Up @@ -181,7 +181,7 @@ function EnumDescriptor.CreateEditor;
result:=inherited;
if (result.editor=nil)and(result.mode=TEM_Nothing)then
if assigned(EnumGlobalEditor) then
result:=EnumGlobalEditor(TheOwner,rect,pinstance,psa,FreeOnLostFocus,initialvalue,@self,preferedHeight)
result:=EnumGlobalEditor(TheOwner,rect,pinstance,psa,FreeOnLostFocus,initialvalue,@self,preferedHeight,f)
else
begin
result.editor:=nil;
Expand Down
4 changes: 2 additions & 2 deletions cad_source/components/zscript/UPointerDescriptor.pas
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface
//function DeSerialize(PInstance:Pointer;SaveFlag:Word;var membuf:TZctnrVectorBytes;linkbuf:PGDBOpenArrayOfTObjLinkRecord):integer;virtual;
procedure Format;virtual;
function GetTypeAttributes:TTypeAttr;virtual;
function CreateEditor(TheOwner:TPropEditorOwner;rect:trect{x,y,w,h:Integer};pinstance:pointer;psa:PTZctnrVectorStrings;FreeOnLostFocus:boolean;InitialValue:TInternalScriptString;preferedHeight:integer):TEditorDesc{TPropEditor};virtual;
function CreateEditor(TheOwner:TPropEditorOwner;rect:trect{x,y,w,h:Integer};pinstance:pointer;psa:PTZctnrVectorStrings;FreeOnLostFocus:boolean;InitialValue:TInternalScriptString;preferedHeight:integer;f:TzeUnitsFormat):TEditorDesc{TPropEditor};virtual;
procedure SavePasToMem(var membuf:TZctnrVectorBytes;PInstance:Pointer;prefix:TInternalScriptString);virtual;
destructor Done;virtual;
end;
Expand Down Expand Up @@ -71,7 +71,7 @@ function GDBPointerDescriptor.CreateEditor;
begin
if assigned(TypeOf)and assigned(pointer(pinstance^)) then

result:=TypeOf^.CreateEditor(theowner,rect,pointer(pinstance^),nil,FreeOnLostFocus,initialvalue,preferedHeight)
result:=TypeOf^.CreateEditor(theowner,rect,pointer(pinstance^),nil,FreeOnLostFocus,initialvalue,preferedHeight,f)
end;

constructor GDBPointerDescriptor.init;
Expand Down
Loading

0 comments on commit da6c455

Please sign in to comment.