|
DeleD Community Edition Forums
|
View previous topic :: View next topic |
Author |
Message |
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Sun Jan 24, 2010 10:48 pm Post subject: DeleD CE source code updates! |
|
|
Hi all,
I just checked-in a re-factoring change to help with adding new primitives to the DeleD GUI code. I have tested the changes and nothing seems to be broken.
See changes below:
Description:
Quote: |
Added loop check and removed hard-coded indices when selecting tvCreate item in TfrmCreateEdit.SetPrimitive (Forms/frmCreateEditForm.pas).
This should make it easier to add in new primitives in the future without having to worry about what index each item uses. |
Unified diff so you can see changes:
Code: |
Index: frmCreateEditForm.pas
===================================================================
--- frmCreateEditForm.pas (revision 9)
+++ frmCreateEditForm.pas (revision 10)
@@ -612,6 +612,9 @@
end;
procedure TfrmCreateEdit.SetPrimitive(APrimitive: TObjectType);
+var
+ PrimitiveIndex : Integer;
+ ItemIndex : Integer;
begin
fDefaultPrimitive := APrimitive; // note: this is the DefaultPrimitive of TfrmCreateEdit
@@ -623,99 +626,93 @@
if Assigned(fOnSelectDefaultPrimitive) then
fOnSelectDefaultPrimitive(self);
+ PrimitiveIndex := -1;
+
+ for ItemIndex := 0 to tvCreate.Items.Count - 1 do
+ if ObjectTypeToString(APrimitive) = tvCreate.Items[ItemIndex].Text then begin
+ PrimitiveIndex := ItemIndex;
+ Break;
+ end;
+
+ if PrimitiveIndex <> -1 then
+ tvCreate.Items[PrimitiveIndex].Selected := true;
+
case APrimitive of
otGrid:
begin
- tvCreate.Items[1].Selected := true;
LoadCreatePropFrame(TfraCreatePropGrid,panProperties);
end;
otPolyline:
begin
- tvCreate.Items[2].Selected := true;
LoadCreatePropFrame(TfraCreatePropPolyline,panProperties);
end;
otRectangle:
begin
- tvCreate.Items[3].Selected := true;
LoadCreatePropFrame(TfraCreatePropRectangle,panProperties);
end;
otCube:
begin
- tvCreate.Items[4].Selected := true;
LoadCreatePropFrame(TfraCreatePropCube,panProperties);
end;
otEllipse:
begin
- tvCreate.Items[5].Selected := true;
LoadCreatePropFrame(TfraCreatePropEllipse,panProperties);
end;
otPyramid:
begin
- tvCreate.Items[6].Selected := true;
LoadCreatePropFrame(TfraCreatePropPyramid,panProperties);
end;
otCylinder:
begin
- tvCreate.Items[7].Selected := true;
LoadCreatePropFrame(TfraCreatePropCylinder,panProperties);
end;
otSphere:
begin
- tvCreate.Items[8].Selected := true;
LoadCreatePropFrame(TfraCreatePropSphere,panProperties);
end;
otTorus:
begin
- tvCreate.Items[9].Selected := true;
LoadCreatePropFrame(TfraCreatePropTorus,panProperties);
end;
otText:
begin
- tvCreate.Items[10].Selected := true;
LoadCreatePropFrame(TfraCreatePropNone,panProperties);
end;
otJoint:
begin
- tvCreate.Items[12].Selected := true;
LoadCreatePropFrame(TfraCreatePropNone,panProperties);
end;
otAnimation:
begin
- tvCreate.Items[13].Selected := true;
LoadCreatePropFrame(TfraCreatePropAnimation,panProperties);
end;
otPointlight:
begin
- tvCreate.Items[15].Selected := true;
LoadCreatePropFrame(TfraCreatePropNone,panProperties);
end;
otDirectionallight:
begin
- tvCreate.Items[16].Selected := true;
LoadCreatePropFrame(TfraCreatePropNone,panProperties);
end;
otSpotlight:
begin
- tvCreate.Items[17].Selected := true;
LoadCreatePropFrame(TfraCreatePropNone,panProperties);
end;
end;
-
-
end;
// get the allowance for this control |
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
Paul-Jan Site Admin
Joined: 08 Aug 2004 Posts: 3066 Location: Lage Zwaluwe
|
Posted: Tue Jan 26, 2010 9:16 pm Post subject: |
|
|
Nice! |
|
Back to top |
|
|
paul_nicholls DeleD PRO user
Joined: 05 Dec 2007 Posts: 356 Location: Hobart, Tasmania, Australia
|
Posted: Thu Jan 28, 2010 9:53 pm Post subject: |
|
|
Attention:
New updates have now been committed to the code base
See below for notes:
cheers,
Paul _________________ Long live DeleD!
Hi ho...hi ho...it's off 3d modeling I go... |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|