Delgine 3D Tools & Content DeleD Community Edition
Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DeleD CE source code updates!

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Development
View previous topic :: View next topic  
Author Message
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Sun Jan 24, 2010 10:48 pm    Post subject: DeleD CE source code updates! Reply with quote

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
View user's profile Send private message
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Tue Jan 26, 2010 9:16 pm    Post subject: Reply with quote

Nice!
Back to top
View user's profile Send private message Visit poster's website
paul_nicholls
DeleD PRO user


Joined: 05 Dec 2007
Posts: 356
Location: Hobart, Tasmania, Australia

PostPosted: Thu Jan 28, 2010 9:53 pm    Post subject: Reply with quote

Attention:

New updates have now been committed to the code base Smile

See below for notes:

Quote:
Added initial version of TPath primitive. Works with lathe tool, and scenes with path(s) can be saved/loaded as normal. The 2 subdivision routines, Catmull-Clark and Doo-Sabin ignore this primitive type and have no effect on them.

https://sourceforge.net/tracker/?func=detail&aid=2933270&group_id=293758&atid=1241130


cheers,
Paul
_________________
Long live DeleD!

Hi ho...hi ho...it's off 3d modeling I go...
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Development All times are GMT
Page 1 of 1

 
Jump to:  
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