Recent

Author Topic: Simple Perspective program (included)  (Read 2302 times)

circular

  • Hero Member
  • *****
  • Posts: 3668
    • Personal webpage
Re: Simple Perspective program (included)
« Reply #15 on: December 17, 2020, 02:37:13 pm »
Did you put a call to Invalidate in the OnPaint event? This could make it refresh forever.
Conscience is the debugger of the mind

speter

  • Full Member
  • ***
  • Posts: 162
Re: Simple Perspective program (included)
« Reply #16 on: December 17, 2020, 03:20:35 pm »
Did you put a call to Invalidate in the OnPaint event? This could make it refresh forever.
No, I had a "refresh" at the start of scene.draw :)

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Laz 2.0.10 / FPC 3.2.0 / Windows 10 (64bit)

speter

  • Full Member
  • ***
  • Posts: 162
Re: Simple Perspective program (included)
« Reply #17 on: December 17, 2020, 03:27:24 pm »
OK, this time I have two versions of my program!
One (at least) should work in macOS.

The first (version 1.11b) moves the call to scene.draw into paintbox1paint.

The second (version 1.11c) moves the drawing code from the scene and face objects into paintbox1paint.

I hope version 1.11b works! :)

Once again, I'd really like to hear people's experiences, especially the poor folk with fruity computers.  :P

cheers
S.
PS: now I'm really heading off to try to get some sleep on this warm summer night. ;)

[Deleted ZIPs -author request]
« Last Edit: December 18, 2020, 08:07:12 am by trev »
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Laz 2.0.10 / FPC 3.2.0 / Windows 10 (64bit)

circular

  • Hero Member
  • *****
  • Posts: 3668
    • Personal webpage
Re: Simple Perspective program (included)
« Reply #18 on: December 17, 2020, 08:06:38 pm »
Cool  :)

I confirm v1.11b works fine on fruity computers.  :)
Conscience is the debugger of the mind

tetrastes

  • Jr. Member
  • **
  • Posts: 87
Re: Simple Perspective program (included)
« Reply #19 on: December 17, 2020, 09:30:44 pm »
Nice program  :)
Both versions work now on Linux qt5, not only gtk2.
But behaviour is different:
1. With qt5 you may keep "move" key pressed, and scene rotates, while with gtk2 you have to press key for each "turn".
2. With qt5 adding data in Info Panel window by pressing buttons does not move list to the end, as it does with gtk2.

And you have to rid off the mess of "move" keys with navigation and editing of controls at Panel1.

winni

  • Hero Member
  • *****
  • Posts: 2214
Re: Simple Perspective program (included)
« Reply #20 on: December 17, 2020, 09:51:12 pm »
Thanx!

Nice programm.
Not to mention the "transparent gras"
Nice feature

And about the hot summer night:

Only some days to the winter solstice.
And then our days are getting longer. And yours getting shorter ...

Winni

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1282
  • Former Delphi 1-7, 10.2 User
Re: Simple Perspective program (included)
« Reply #21 on: December 17, 2020, 11:25:01 pm »
Eureka! V1.1b works perfectly on macOS 11.1 (aarch64) and macOS 10.14.6 (Intel).

Just one small thing, the far right button "Reset Eye/Tar" is truncated immediately after "Eye".
Lazarus 2.1 r64368 FPC 3.3.1 r48100 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r64455 3.3.1 r48839   macOS 11.2.2 aarch64 Xcode 12.4
Lazarus 2.1 r61574 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 3.2.0 Win10 Parallels VM

speter

  • Full Member
  • ***
  • Posts: 162
Re: Simple Perspective program (included)
« Reply #22 on: December 18, 2020, 03:49:31 am »
G'Day FOlks,

My thanks to everyone - especially Handoko, trev & Circular. I've posted a new version of my perspective program here; and will delete the earlier versions (assuming I can delete attachments). :o

2020-12-18 v.1.12
  + moved the "instructions" to the info-panel form
  + program now calcs button-width based on caption text
  + numbers typed in the Tedit's no longer rotate the view.

Nice program  :)
Both versions work now on Linux qt5, not only gtk2.
But behaviour is different:
1. With qt5 you may keep "move" key pressed, and scene rotates, while with gtk2 you have to press key for each "turn".
2. With qt5 adding data in Info Panel window by pressing buttons does not move list to the end, as it does with gtk2.
@tetrastes: (1) In Windows 10 the user needs to press the move key to rotate (holding it down does nothing). So the performance with qt5 is what I'd expect. (2) I don't know how to scroll a memo to then end (except in Windows via a windows-message); I haven't included any code to scroll to the end of the memo; so again the behaviour with qt5 is what I would expect. ;)

cheers
S.

Edit: I can't work out how to delete the previous ZIP files. :(
« Last Edit: December 18, 2020, 03:56:31 am by speter »
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Laz 2.0.10 / FPC 3.2.0 / Windows 10 (64bit)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1282
  • Former Delphi 1-7, 10.2 User
Re: Simple Perspective program (included)
« Reply #23 on: December 18, 2020, 08:13:38 am »
1. The last button text is truncated.
2. The Open dialog again takes me to the executable folder inside the macOS Application bundle
3. No way to get back the instructions after clearing the Info Panel .

It does work very nicely though :)

I've deleted the previous zips for you.
Lazarus 2.1 r64368 FPC 3.3.1 r48100 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r64455 3.3.1 r48839   macOS 11.2.2 aarch64 Xcode 12.4
Lazarus 2.1 r61574 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 3.2.0 Win10 Parallels VM

tetrastes

  • Jr. Member
  • **
  • Posts: 87
Re: Simple Perspective program (included)
« Reply #24 on: December 18, 2020, 11:18:41 am »

Nice program  :)
Both versions work now on Linux qt5, not only gtk2.
But behaviour is different:
1. With qt5 you may keep "move" key pressed, and scene rotates, while with gtk2 you have to press key for each "turn".
2. With qt5 adding data in Info Panel window by pressing buttons does not move list to the end, as it does with gtk2.
@tetrastes: (1) In Windows 10 the user needs to press the move key to rotate (holding it down does nothing). So the performance with qt5 is what I'd expect. (2) I don't know how to scroll a memo to then end (except in Windows via a windows-message); I haven't included any code to scroll to the end of the memo; so again the behaviour with qt5 is what I would expect. ;)

I tested your last version in Windows 10, and it behaves like gtk2, not qt5. May be my English is bad...
By the way, auto rotation at qt5 looks very nice  ;)

In your last version, if you use arrow keys to rotate, sooner or later you come to one of TEdits, and then rotation stops, until you leave TEdit somehow.

speter

  • Full Member
  • ***
  • Posts: 162
Re: Simple Perspective program (included)
« Reply #25 on: December 18, 2020, 11:47:53 am »
G'Day Folks,

@trev: Thanks very much for deleting the old zips.

@tetrastes: Thanks for your comments! I am not sure what you mean by your last sentence though (... sooner or later you come to one of Tedits...)?

Attached to this message is version 1.13 in persp.zip.
  + setting the forms' width to fit all the buttons etc
  + added "instructions" button to Info-Panel form.
  + adjusting the height of panel1 (the button container) to fit the captions.
  + I also tweaked some of the colours in the hut scene.

I am not sure how to set the file-open dialog's initial directory, so that it works in Windows, Linux & macOS.

cheers
S. :)
« Last Edit: December 18, 2020, 11:51:41 am by speter »
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Laz 2.0.10 / FPC 3.2.0 / Windows 10 (64bit)

tetrastes

  • Jr. Member
  • **
  • Posts: 87
Re: Simple Perspective program (included)
« Reply #26 on: December 18, 2020, 12:13:27 pm »
@tetrastes: Thanks for your comments! I am not sure what you mean by your last sentence though (... sooner or later you come to one of Tedits...)?

Did you ever notice that pressing arrow keys also navigates through the controls of Panel1?

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1282
  • Former Delphi 1-7, 10.2 User
Re: Simple Perspective program (included)
« Reply #27 on: December 19, 2020, 12:56:16 am »
I am not sure how to set the file-open dialog's initial directory, so that it works in Windows, Linux & macOS.

This works for me:

Code: Pascal  [Select][+][-]
  1. uses
  2.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, Math,
  3.   spworld, sceneu, infou
  4.   {$IFDEF Darwin}
  5.   ,macOSAll
  6.   {$ENDIF}
  7.   ;  

Code: Pascal  [Select][+][-]
  1. {$IFDEF Darwin}
  2. //----------------------------------------------------------
  3. function GetBundlePath(): string;
  4. //----------------------------------------------------------
  5. var
  6.   pathRef: CFURLRef;
  7.   pathCFStr: CFStringRef;
  8.   pathStr: shortstring;
  9.   status: Boolean = false;
  10. begin
  11.   pathRef := CFBundleCopyBundleURL(CFBundleGetMainBundle());
  12.   pathCFStr := CFURLCopyFileSystemPath(pathRef, kCFURLPOSIXPathStyle);
  13.  
  14.   status := CFStringGetPascalString(pathCFStr, @pathStr, 255, CFStringGetSystemEncoding());
  15.  
  16.   if(status = true) then
  17.     Result := pathStr
  18.   else
  19.     raise Exception.Create('Error in GetBundlePath()');
  20. end;
  21. {$ENDIF}  

Code: Pascal  [Select][+][-]
  1. //----------------------------------------------------------
  2. procedure TForm1.Button_file_openClick(Sender: TObject);
  3. //----------------------------------------------------------
  4. begin
  5.   {$IF DEFINED(Windows)}
  6.   opendialog1.InitialDir:=ExtractFilePath(ParamStr(0));
  7.   {$ELSEIF DEFINED(Darwin)}
  8.   opendialog1.InitialDir:=ExtractFilePath(GetBundlePath);
  9.   {$ELSEIF DEFINED(UNIX)}
  10.   opendialog1.InitialDir:='.';
  11.   {$ENDIF}
  12.  
  13.   if opendialog1.execute then
  14.     file_open(opendialog1.filename);
  15. end;  

I've checked macOS but not the rest (my VMs are currently out of action).
Lazarus 2.1 r64368 FPC 3.3.1 r48100 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r64455 3.3.1 r48839   macOS 11.2.2 aarch64 Xcode 12.4
Lazarus 2.1 r61574 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 3.2.0 Win10 Parallels VM

speter

  • Full Member
  • ***
  • Posts: 162
Re: Simple Perspective program (included)
« Reply #28 on: December 19, 2020, 12:57:52 am »
@tetrastes: Thanks for your comments! I am not sure what you mean by your last sentence though (... sooner or later you come to one of Tedits...)?

Did you ever notice that pressing arrow keys also navigates through the controls of Panel1?
No! Actually, I don't use "arrow" keys... that's horrible! :(

I guess I'll need to remove the TEdits from the tab-stop sequence.

Thanks for letting me know!!

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Laz 2.0.10 / FPC 3.2.0 / Windows 10 (64bit)

speter

  • Full Member
  • ***
  • Posts: 162
Re: Simple Perspective program (included)
« Reply #29 on: December 19, 2020, 05:39:05 am »
G'Day Folks,

Once again, my thanks to everyone for their help in sorting out "features".   :D

In particular:
  @trev: a big thank-you for the code to set file-open's initial directory;
  @tetrastes: I had no idea Laz (and presumably Delphi) made the arrow keys act like Tab;
      also I had no idea setting tabstop=false had so little effect. :P

Attached to this message you will find v1.14 (persp.zip).

2020-12-19 v.1.14
  + added code from user 'trev' to set file-open's initial directory
  + changed eye / tar Tedits into Tlabel
  + "GoTo" button now shows a dialog to set the eye / tar.
  + tweaked the GUI - moved GoTo button & eye / tar pos label to separate panel.
  + made the program's main-form initial size at bit smaller (1000x750px).

cheers
S. :)
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Laz 2.0.10 / FPC 3.2.0 / Windows 10 (64bit)

 

TinyPortal © 2005-2018