1 {
2 *****************************************************************************
3 *                                                                           *
4 *  This file is part of the ZCAD                                            *
5 *                                                                           *
6 *  See the file COPYING.modifiedLGPL.txt, included in this distribution,    *
7 *  for details about the copyright.                                         *
8 *                                                                           *
9 *  This program is distributed in the hope that it will be useful,          *
10 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
11 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     *
12 *                                                                           *
13 *****************************************************************************
14 }
15 {
16 @author(Andrey Zubarev <zamtmn@yandex.ru>)
17 }
18 
19 unit uzeroot;
20 {$INCLUDE def.inc}
21 
22 interface
23 Uses
24    uzgldrawcontext,uzedrawingdef,uzecamera,uzeentitiestree,uzbtypesbase,uzbtypes,
25    uzeconsts,uzeentity,uzeentgenericsubentry,uzeentconnected,uzeentsubordinated,
26    gzctnrvectortypes,uzbgeomtypes,uzegeometry;
27 type
28 {REGISTEROBJECTTYPE GDBObjRoot}
29 {Export+}
30 PGDBObjRoot=^GDBObjRoot;
31 GDBObjRoot={$IFNDEF DELPHI}packed{$ENDIF} object(GDBObjGenericSubEntry)
32                  constructor initnul;
33                  destructor done;virtual;
ImEditednull34                  //function ImEdited(pobj:PGDBObjSubordinated;pobjinarray:GDBInteger):GDBInteger;virtual;
35                  procedure FormatAfterEdit(var drawing:TDrawingDef;var DC:TDrawContext);virtual;
36                  procedure AfterDeSerialize(SaveFlag:GDBWord; membuf:GDBPointer);virtual;
getownernull37                  function getowner:PGDBObjSubordinated;virtual;
GetMainOwnernull38                  function GetMainOwner:PGDBObjSubordinated;virtual;
39                  procedure getoutbound(var DC:TDrawContext);virtual;
FindVariablenull40                  //function FindVariable(varname:GDBString):pvardesk;virtual;
41                  function GetHandle:GDBPlatformint;virtual;
42                  procedure EraseMi(pobj:pGDBObjEntity;pobjinarray:GDBInteger;var drawing:TDrawingDef);virtual;
43 
GetMatrixnull44                  function GetMatrix:PDMatrix4D;virtual;
45                  procedure DrawWithAttrib(var DC:TDrawContext{visibleactualy:TActulity;subrender:GDBInteger});virtual;
CalcInFrustumnull46                  function CalcInFrustum(frustum:ClipArray;infrustumactualy:TActulity;visibleactualy:TActulity;var totalobj,infrustumobj:GDBInteger; ProjectProc:GDBProjectProc;const zoom,currentdegradationfactor:GDBDouble):GDBBoolean;virtual;
47                  procedure CalcInFrustumByTree(frustum:ClipArray;infrustumactualy:TActulity;visibleactualy:TActulity;var enttree:TEntTreeNode;var totalobj,infrustumobj:GDBInteger; ProjectProc:GDBProjectProc;const zoom,currentdegradationfactor:GDBDouble);virtual;
48                  procedure calcbb(var DC:TDrawContext);virtual;
FindShellByClassnull49                  //function FindShellByClass(_type:TDeviceClass):PGDBObjSubordinated;virtual;
50                  function GetObjType:TObjID;virtual;
51            end;
52 
53 {Export-}
54 implementation
55 //uses
56 //    log;
GDBObjRoot.GetMainOwnernull57 function GDBObjRoot.GetMainOwner:PGDBObjSubordinated;
58 begin
59      result:=@self;
60 end;
61 {function GDBObjRoot.FindShellByClass(_type:TDeviceClass):PGDBObjSubordinated;
62 begin
63      result:=nil;
64 end;}
65 procedure GDBObjRoot.calcbb;
66 begin
67      inherited;
68      vp.BoundingBox.LBN:=VectorTransform3D(vp.BoundingBox.LBN,ObjMatrix);
69      vp.BoundingBox.RTF:=VectorTransform3D(vp.BoundingBox.RTF,ObjMatrix);
70 end;
71 procedure GDBObjRoot.CalcInFrustumByTree(frustum:ClipArray;infrustumactualy:TActulity;visibleactualy:TActulity;var enttree:TEntTreeNode;var totalobj,infrustumobj:GDBInteger; ProjectProc:GDBProjectProc;const zoom,currentdegradationfactor:GDBDouble);
72 var
73    myfrustum:ClipArray;
74 begin
75      myfrustum:=FrustumTransform(frustum,ObjMatrix);
76      ProcessTree(myfrustum,infrustumactualy,visibleactualy,enttree,IRPartially,TDTFulDraw,totalobj,infrustumobj,ProjectProc,zoom,currentdegradationfactor);
77      self.VisibleOBJBoundingBox:=ObjArray.calcvisbb({gdb.GetCurrentDWG.pcamera^.POSCOUNT}{visibleactualy}infrustumactualy);
78 end;
GDBObjRoot.CalcInFrustumnull79 function GDBObjRoot.CalcInFrustum;
80 var
81    myfrustum:ClipArray;
82 begin
83      myfrustum:=FrustumTransform(frustum,ObjMatrix);
84      result:=inherited CalcInFrustum(myfrustum,infrustumactualy,visibleactualy,totalobj,infrustumobj, ProjectProc,zoom,currentdegradationfactor);
85 end;
86 procedure GDBObjRoot.DrawWithAttrib;
87 begin
88      DC.drawer.pushMatrixAndSetTransform(objmatrix);
89      //oglsm.myglpushmatrix;
90      //oglsm.myglMultMatrixD(objmatrix);
91      inherited;//self.ObjArray.DrawWithattrib;
92      DC.drawer.popMatrix;
93      //oglsm.myglpopmatrix;
94 
95 end;
GDBObjRoot.GetMatrixnull96 function GDBObjRoot.GetMatrix;
97 begin
98      result:=@self.ObjMatrix{ @OneMatrix};
99 end;
100 procedure GDBObjRoot.EraseMi(pobj:pGDBObjEntity;pobjinarray:GDBInteger;var drawing:TDrawingDef);
101 var p:PGDBObjConnected;
102     ir:itrec;
103 begin
104      inherited EraseMi(pobj,pobjinarray,drawing);
105      p:=self.ObjToConnectedArray.beginiterate(ir);
106      if p<>nil then
107      repeat
108            //if p=pobj then
109                          //ppointer(ir.itp)^:=nil;
110 
111            p:=self.ObjToConnectedArray.iterate(ir);
112      until p=nil;
113 end;
GDBObjRoot.GetHandlenull114 function GDBObjRoot.GetHandle:GDBPlatformint;
115 begin
116      result:=H_Root;
117 end;
118 {function GDBObjRoot.FindVariable;
119 begin
120      result:=PTObjectUnit(ou.Instance)^.FindVariable(varname);
121 end;}
122 procedure GDBObjRoot.getoutbound;
123 begin
124      vp.BoundingBox.LBN:=NulVertex;
125      vp.BoundingBox.RTF:=NulVertex;
126      inherited;
127 end;
GDBObjRoot.getownernull128 function GDBObjRoot.getowner;
129 begin
130      result:=nil;
131 end;
132 procedure GDBObjRoot.AfterDeSerialize;
133 begin
134      //inherited AfterDeSerialize(SaveFlag,membuf);
135      correctobjects(nil,-1);
136      //format;
137 end;
138 destructor GDBObjRoot.done;
139 begin
140      ObjArray.Done;
141      self.ObjCasheArray.Done;
142      self.
143      ObjToConnectedArray.Done;
144      inherited done;
145 end;
146 constructor GDBObjRoot.initnul;
147 {var
148     prootonit:ptunit;}
149 begin
150      inherited initnul(nil);
151      bp.ListPos.owner:=nil;
152      //vp.ID:=GDBRootId;
153      //bp.PSelfInOwnerArray:=nil;
154      bp.ListPos.SelfIndex:=-1;
155      ObjToConnectedArray.init({$IFDEF DEBUGBUILD}'{0AD3CD18-E887-4038-BADA-7616D9F52963}',{$ENDIF}100);
156      {prootonit:=units.findunit('objroot');
157      if prootonit<>nil then
158                            PTObjectUnit(ou.Instance)^.copyfrom(units.findunit('objroot'));}
159      //uunitmanager.units.loadunit(expandpath('*blocks\objroot.pas'),@ou);
160 end;
GDBObjRoot.GetObjTypenull161 function GDBObjRoot.GetObjType;
162 begin
163      result:=GDBRootId;
164 end;
165 procedure GDBObjRoot.formatafteredit;
166 var pobj:PGDBObjConnected;
167     p:pGDBObjEntity;
168     ir:itrec;
169 begin
170 
171      //inherited formatafteredit;
172        ObjCasheArray.Formatafteredit(drawing,dc);
173 
174        p:=ObjCasheArray.beginiterate(ir);
175        if p<>nil then
176        repeat
177              if p^.bp.TreePos.Owner<>nil then
178              begin
179                   self.ObjArray.RemoveFromTree(p);
180                   self.ObjArray.ObjTree.AddObjectToNodeTree(p^);
181              end;
182             p:=ObjCasheArray.iterate(ir);
183        until p=nil;
184 
185        ObjCasheArray.clear;
186        calcbb(dc);
187 
188 
189      pobj:=self.ObjToConnectedArray.beginiterate(ir);
190      if pobj<>nil then
191      repeat
192            pobj^.connectedtogdb(@self,drawing);
193 
194            pobj:=self.ObjToConnectedArray.iterate(ir);
195      until pobj=nil;
196      self.ObjToConnectedArray.clear;
197 
198 
199   {ObjCasheArray.Format;
200   ObjCasheArray.clear;
201   vp.BoundingBox:=objarray.calcbb;
202   restructure;}
203 end;
204 begin
205 end.
206 
207