Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/zamtmn/zcad
Browse files Browse the repository at this point in the history
  • Loading branch information
veb86 committed Apr 23, 2024
2 parents 3b080ce + c8425b3 commit 89057a8
Show file tree
Hide file tree
Showing 9 changed files with 330 additions and 25 deletions.
2 changes: 1 addition & 1 deletion cad_source/components/fpdwg
Submodule fpdwg updated 2 files
+12 −10 dwg_test.lpr
+69 −42 dwgproc.pp
6 changes: 5 additions & 1 deletion cad_source/components/zscript/UBaseTypeDescriptor.pas
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ TPointerTypeManipulator<T>=class(TBaseTypeManipulator<T>)
TEnumDataDescriptor=object(BaseTypeDescriptor<TEnumData,{TOrdinalTypeManipulator<PtrUint>}TOTM_PtrUint>)
constructor init;
function GetValueAsString(pinstance:Pointer):TInternalScriptString;virtual;
function GetDecoratedValueAsString(pinstance:Pointer; const f:TzeUnitsFormat):TInternalScriptString;virtual;
procedure SetValueFromString(PInstance:Pointer;_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;
destructor Done;virtual;
Expand Down Expand Up @@ -552,7 +553,10 @@ function TEnumDataDescriptor.GetValueAsString;
else
result:=PTEnumData(Pinstance)^.Enums.getData(PTEnumData(Pinstance)^.Selected);
end;

function TEnumDataDescriptor.GetDecoratedValueAsString(pinstance:Pointer; const f:TzeUnitsFormat):TInternalScriptString;
begin
result:=GetValueAsString(pinstance);
end;

constructor TCalculatedStringDescriptor.init;
begin
Expand Down
2 changes: 1 addition & 1 deletion cad_source/zcad.pas
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
{$IFNDEF DARWIN}
{$IFDEF ELECTROTECH}
//**for velec func**//
uzccommand_drawsuperline,
uzccommand_drawsuperline,uzccommand_l2sl,
uzvslagcab, //автопрокладка кабелей по именным суперлиниям
uzvagslcom, //создания именных суперлиний в комнате между извещателями
uzvstripmtext, //очистка мтекста, сделано плохо, в будущем надо переделывать мтекст и механизм.
Expand Down
129 changes: 129 additions & 0 deletions cad_source/zcad/commands/uzccommand_l2sl.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
*****************************************************************************
* *
* This file is part of the ZCAD *
* *
* See the file COPYING.txt, included in this distribution, *
* for details about the copyright. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
*****************************************************************************
}
{
@author(Andrey Zubarev <[email protected]>)
}
{$mode delphi}
unit uzccommand_l2sl;

{$INCLUDE zengineconfig.inc}

interface
uses
uzcLog,
uzccommandsabstract,uzccommandsimpl,
uzeentity,uzeentline,gzctnrVectorTypes,uzcdrawings,uzcdrawing,
zcmultiobjectcreateundocommand,uzcinterface,uzcutils,
UGDBSelectedObjArray,gzctnrSTL,uzeentsubordinated,uzeconsts,
uzventsuperline,uzcEnitiesVariablesExtender,uzeentityfactory,
UUnitManager,Varman,uzbPaths,uzcTranslations;

implementation

procedure MySetObjCreateManipulator(Owner:PGDBObjGenericWithSubordinated;out domethod,undomethod:tmethod);
begin
domethod.Code:=pointer(Owner^.GoodAddObjectToObjArray);
domethod.Data:=Owner;
undomethod.Code:=pointer(Owner^.GoodRemoveMiFromArray);
undomethod.Data:=Owner;
end;


function L2SL_com(const Context:TZCADCommandContext;operands:TCommandOperands):TCommandResult;
var
pv:PGDBObjLine;
Pair:TMyMapCounter<PGDBObjGenericWithSubordinated>.TDictionaryPair;
ir:itrec;
Count:integer;
domethod,undomethod:tmethod;
psd:PSelectedObjDesc;
Counter:TMyMapCounter<PGDBObjGenericWithSubordinated>;
psuperline:PGDBObjSuperLine;
pvarext:TVariablesExtender;
psu:ptunit;
begin
if (drawings.GetCurrentROOT^.ObjArray.count = 0)or(drawings.GetCurrentDWG^.wa.param.seldesc.Selectedobjcount=0) then exit;
//счетчик владельцев выделеных примитивов
Counter:=TMyMapCounter<PGDBObjGenericWithSubordinated>.Create;
Count:=0;
//считаем владельцев выделеных линий
//считаем выделеные линии
psd:=drawings.GetCurrentDWG.SelObjArray.beginiterate(ir);
if psd<>nil then repeat
pv:=pointer(psd^.objaddr);
if pv^.GetObjType=GDBLineID then begin
Counter.CountKey(pv^.bp.ListPos.Owner);
inc(Count);
end;
psd:=drawings.GetCurrentDWG.SelObjArray.iterate(ir);
until psd=nil;
//если нашли что конвертировать то
if Count>0 then begin
PTZCADDrawing(drawings.GetCurrentDWG)^.UndoStack.PushStartMarker('L2SL');
//создаем суперлинии
psd:=drawings.GetCurrentDWG.SelObjArray.beginiterate(ir);
if psd<>nil then repeat
pv:=pointer(psd^.objaddr);
if pv^.GetObjType=GDBLineID then begin
psuperline := AllocEnt(GDBSuperLineID);
psuperline^.init(nil,nil,0,pv^.CoordInWCS.lBegin,pv^.CoordInWCS.lEnd);
pvarext:=psuperline^.GetExtension<TVariablesExtender>;
if pvarext<>nil then begin
psu:=units.findunit(GetSupportPath,InterfaceTranslate,'superline');
if psu<>nil then
pvarext.entityunit.copyfrom(psu);
end;
zcSetEntPropFromCurrentDrawingProp(psuperline);
psuperline^.vp:=pv^.vp;
zcAddEntToCurrentDrawingWithUndo(psuperline);
end;
psd:=drawings.GetCurrentDWG.SelObjArray.iterate(ir);
until psd=nil;
//удаляем оригинальные линии
for Pair in Counter do begin
MySetObjCreateManipulator(Pair.key,undomethod,domethod);
with PushMultiObjectCreateCommand(PTZCADDrawing(drawings.GetCurrentDWG)^.UndoStack,tmethod(domethod),tmethod(undomethod),Pair.Value) do begin
psd:=drawings.GetCurrentDWG.SelObjArray.beginiterate(ir);
if psd<>nil then repeat
pv:=pointer(psd^.objaddr);
if (pv^.GetObjType=GDBLineID)and(pv^.bp.ListPos.Owner=Pair.key) then begin
AddObject(pv);
pv^.Selected:=false;
end;
psd:=drawings.GetCurrentDWG.SelObjArray.iterate(ir);
until psd=nil;
FreeArray:=false;
comit;
end;
end;
PTZCADDrawing(drawings.GetCurrentDWG)^.UndoStack.PushEndMarker;

drawings.GetCurrentDWG^.wa.param.seldesc.Selectedobjcount:=0;
drawings.GetCurrentDWG^.wa.param.seldesc.OnMouseObject:=nil;
drawings.GetCurrentDWG^.wa.param.seldesc.LastSelectedObject:=nil;
drawings.GetCurrentDWG^.wa.param.lastonmouseobject:=nil;
ZCMsgCallBackInterface.Do_GUIaction(nil,ZMsgID_GUIReturnToDefaultObject);
clearcp;
zcRedrawCurrentDrawing;
end;
result:=cmd_ok;
end;

initialization
programlog.LogOutFormatStr('Unit "%s" initialization',[{$INCLUDE %FILE%}],LM_Info,UnitsInitializeLMId);
CreateZCADCommand(@L2SL_com,'L2SL',CADWG,0);
finalization
ProgramLog.LogOutFormatStr('Unit "%s" finalization',[{$INCLUDE %FILE%}],LM_Info,UnitsFinalizeLMId);
end.
38 changes: 20 additions & 18 deletions cad_source/zcad/gui/forms/uzcfnavigatordevices.pas
Original file line number Diff line number Diff line change
Expand Up @@ -486,24 +486,26 @@ procedure TNavigatorDevices.VTFocuschanged(Sender: TBaseVirtualTree; Node: PVirt
pnd:PTNodeData;
s:string;
begin
pnd := Sender.GetNodeData(Node);
if assigned(pnd) then begin
if pnd^.Ident.pent<>nil then
begin
CurrentSel:=pnd^;
if (LastAutoselectedEnt<>pnd^.Ident.pent)and( not pnd^.Ident.pent^.Selected) then begin
s:='SelectObjectByAddres('+inttostr(PtrUInt(pnd^.Ident.pent))+')';
//commandmanager.executecommandsilent(@s[1],drawings.GetCurrentDWG,drawings.GetCurrentOGLWParam);
Application.QueueAsyncCall(AsyncRunCommand,PtrInt(@s[1]));
pointer(s):=nil;
LastAutoselectedEnt:=pnd^.Ident.pent;
end else begin
//if not LastAutoselectedEnt^.Selected then
// LastAutoselectedEnt:=nil;
end;
end else
CurrentSel.Ident.pent:=nil;
end
if Sender.Focused then begin
pnd := Sender.GetNodeData(Node);
if assigned(pnd) then begin
if pnd^.Ident.pent<>nil then
begin
CurrentSel:=pnd^;
if (LastAutoselectedEnt<>pnd^.Ident.pent)and( not pnd^.Ident.pent^.Selected) then begin
s:='SelectObjectByAddres('+inttostr(PtrUInt(pnd^.Ident.pent))+')';
//commandmanager.executecommandsilent(@s[1],drawings.GetCurrentDWG,drawings.GetCurrentOGLWParam);
Application.QueueAsyncCall(AsyncRunCommand,PtrInt(@s[1]));
pointer(s):=nil;
LastAutoselectedEnt:=pnd^.Ident.pent;
end else begin
//if not LastAutoselectedEnt^.Selected then
// LastAutoselectedEnt:=nil;
end;
end else
CurrentSel.Ident.pent:=nil;
end
end;
end;
function TNavigatorDevices.GetPartsCount(const parts:string):integer;
begin
Expand Down
2 changes: 2 additions & 0 deletions cad_source/zcad/gui/odjectinspector/uzcoidecorations.pas
Original file line number Diff line number Diff line change
Expand Up @@ -584,5 +584,7 @@ procedure DecorateSysTypes;
AddFastEditorToType(SysUnit.TypeName2PTD('TMSEntsLinetypesDetector'),@OIUI_FE_ButtonGetPrefferedSize,@OIUI_FE_ButtonHLineDraw,@DeselectEntsByLinetype,true);
AddFastEditorToType(SysUnit.TypeName2PTD('TMSEntsLinetypesDetector'),@OIUI_FE_ButtonGetPrefferedSize,@OIUI_FE_ButtonMultiplyDraw,@SelectOnlyThisEntsByLinetype,true);

AddFastEditorToType(SysUnit.TypeName2PTD('TMSEntsExtendersDetector'),@OIUI_FE_ButtonGetPrefferedSize,@OIUI_FE_ButtonHLineDraw,@DeselectEntsByExtender,true);
AddFastEditorToType(SysUnit.TypeName2PTD('TMSEntsExtendersDetector'),@OIUI_FE_ButtonGetPrefferedSize,@OIUI_FE_ButtonMultiplyDraw,@SelectOnlyThisEntsByExtender,true);
end;
end.
85 changes: 82 additions & 3 deletions cad_source/zcad/gui/odjectinspector/uzcoimultiobjects.pas
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface
gzctnrVectorTypes,uzbtypes,uzcdrawings,varmandef,uzeentity,
Varman,uzctnrvectorstrings,UGDBSelectedObjArray,uzcoimultipropertiesutil,
uzeExtdrAbstractEntityExtender,uzelongprocesssupport,uzbLogIntf,uzcutils,
zUndoCmdChgVariable,uzcdrawing,zUndoCmdChgTypes;
zUndoCmdChgVariable,uzcdrawing,zUndoCmdChgTypes,uzeBaseExtender;
type
TObjIDWithExtender2Counter=TMyMapCounter<TObjIDWithExtender>;
{Export+}
Expand All @@ -53,6 +53,8 @@ interface
TMSEntsLayersDetector=TEnumDataWithOtherPointers;
{REGISTERRECORDTYPE TMSEntsLinetypesDetector}
TMSEntsLinetypesDetector=TEnumDataWithOtherPointers;
{REGISTERRECORDTYPE TMSEntsExtendersDetector}
TMSEntsExtendersDetector=TEnumDataWithOtherPointers;
{REGISTEROBJECTTYPE TMSEditor}
TMSEditor= object(TWrapper2ObjInsp)
TxtEntType:TMSPrimitiveDetector;(*'Process primitives'*)
Expand Down Expand Up @@ -93,10 +95,12 @@ procedure DeselectBlocsByName(PInstance:Pointer);
procedure DeselectTextsByStyle(PInstance:Pointer);
procedure DeselectEntsByLayer(PInstance:Pointer);
procedure DeselectEntsByLinetype(PInstance:Pointer);
procedure DeselectEntsByExtender(PInstance:Pointer);
procedure SelectOnlyThisBlocsByName(PInstance:Pointer);
procedure SelectOnlyThisTextsByStyle(PInstance:Pointer);
procedure SelectOnlyThisEntsByLayer(PInstance:Pointer);
procedure SelectOnlyThisEntsByLinetype(PInstance:Pointer);
procedure SelectOnlyThisEntsByExtender(PInstance:Pointer);
var
MSEditor:TMSEditor;
i:integer;
Expand Down Expand Up @@ -955,6 +959,49 @@ procedure DeselectEntsByLinetype(PInstance:Pointer);
ZCMsgCallBackInterface.Do_GUIaction(drawings.GetCurrentDWG.wa,ZMsgID_GUIActionSelectionChanged);
end;

procedure DeselectEntsByExtender(PInstance:Pointer);
var
pv:pGDBObjEntity;
ir:itrec;
count,selected:integer;
extdrClass:TMetaEntityExtender;
begin
selected:=PTEnumDataWithOtherPointers(PInstance)^.Selected;
extdrClass:=PTEnumDataWithOtherPointers(PInstance)^.Pointers.getData(selected);
count:=0;
pv:=drawings.GetCurrentROOT.ObjArray.beginiterate(ir);
if pv<>nil then
repeat
if pv^.Selected then
if (selected=0)or(pv^.GetExtension(extdrClass)<>nil)then
begin
inc(count);
pv^.DeSelect(drawings.GetCurrentDWG.wa.param.SelDesc.Selectedobjcount,drawings.CurrentDWG^.DeSelector);
end;
pv:=drawings.GetCurrentROOT.ObjArray.iterate(ir);
until pv=nil;
ZCMsgCallBackInterface.TextMessage(sysutils.Format(rscmNEntitiesDeselected,[count]),TMWOHistoryOut);
if count>0 then
ZCMsgCallBackInterface.Do_GUIaction(drawings.GetCurrentDWG.wa,ZMsgID_GUIActionSelectionChanged);
end;

procedure Extendrs2ExtendersCounterIterateProc(pdata:Pointer;ChangedData:TChangedData;mp:TMultiProperty;fistrun:boolean;ecp:TEntChangeProc; const f:TzeUnitsFormat);
var
p:TEntityExtensions;
i:integer;
begin
p:=pointer(ppointer(ChangedData.PGetDataInEtity)^);
if p<>nil then begin
if assigned(p.fEntityExtensions)then
for i:=0 to p.fEntityExtensions.Size-1 do
if p.fEntityExtensions[i]<>nil then begin
PTPointerCounterData(pdata)^.counter.CountKey(p.fEntityExtensions[i].ClassType,1);
inc(PTPointerCounterData(pdata)^.totalcount);
end;
end;
end;




procedure SelectOnlyThisBlocsByName(PInstance:Pointer);
Expand Down Expand Up @@ -1097,8 +1144,40 @@ procedure SelectOnlyThisEntsByLinetype(PInstance:Pointer);
end;
end;



procedure SelectOnlyThisEntsByExtender(PInstance:Pointer);
var
pv:pGDBObjEntity;
ir:itrec;
count,selected:integer;
extdrClass:TMetaEntityExtender;
begin
selected:=PTEnumDataWithOtherPointers(PInstance)^.Selected;
extdrClass:=PTEnumDataWithOtherPointers(PInstance)^.Pointers.getData(selected);
//if NeededObjType<>0 then
begin
count:=0;
pv:=drawings.GetCurrentROOT.ObjArray.beginiterate(ir);
if pv<>nil then
repeat
if pv^.Selected then
//if (pv^.GetObjType=GDBtextID)or(pv^.GetObjType=GDBMTextID) then
begin
if (selected<>0)and(pv^.GetExtension(extdrClass)=nil) then begin
inc(count);
pv^.DeSelect(drawings.GetCurrentDWG.wa.param.SelDesc.Selectedobjcount,drawings.CurrentDWG^.DeSelector);
end;
end else
begin
inc(count);
pv^.DeSelect(drawings.GetCurrentDWG.wa.param.SelDesc.Selectedobjcount,drawings.CurrentDWG^.DeSelector);
end;
pv:=drawings.GetCurrentROOT.ObjArray.iterate(ir);
until pv=nil;
ZCMsgCallBackInterface.TextMessage(sysutils.Format(rscmNEntitiesDeselected,[count]),TMWOHistoryOut);
if count>0 then
ZCMsgCallBackInterface.Do_GUIaction(drawings.GetCurrentDWG.wa,ZMsgID_GUIActionSelectionChanged);
end;
end;

procedure SelectOnlyThisEnts(PInstance:Pointer);
var
Expand Down
Loading

0 comments on commit 89057a8

Please sign in to comment.