Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Open Source Projects
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Open Source Projects The place to discuss Basic4ppc open source applications.


Drawing Program


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-22-2008, 05:23 PM
Senior Member
 
Join Date: Jul 2007
Posts: 147
Awards Showcase
Beta Tester 
Total Awards: 1
Default Drawing Program

This is something I started and need a lot of help with. I put a wordpad file and source code with dll's that I started with. The wordpad file discribes the basic way I have it set up to function with whats done so far.

edit:
updated zip file.
Attached Files
File Type: zip SnapZip.zip (127.8 KB, 76 views)
__________________
Using 6.30
dennishea

Last edited by dennishea : 05-27-2008 at 04:07 PM.
Reply With Quote
  #2 (permalink)  
Old 05-24-2008, 10:20 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 707
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

Hi dennishea,

I had a look at your program and have some questions and suggestions.

Questions:
- what is the main purpose of the program ?
- do you want bitmap graphics or vector graphics, in the second case don't you need scaling with zoom and unzoom ?
- still in the second do you want to have closed surfaces, then they could be solid or hollow ?

Suggestions:
Data structure, for vector graphics:
You could have a structure like:
- a list of points
with the coordinates x,y

- a list of lines
with Type and Data depending on the type
Ex:
Type: Line Data: 1st point index, 2nd point index not the coordinates !
Type: Arc1 Data: center point index, radius, angle1, angle2
Type: Arc2 Data: 1st point index, 2nd point index, radius
Type: Arc3 Data: 1st point index, 2nd point index, 3rd point index

- a list of surfaces
with Type and Data depending on the type, solid or hollow
Ex:
Type: Rectangle Data: upper left point index, lower right point index
the two other points are calculated (angle if you want to rotate it)
Type: Circle1 Data: center point index, radius
Type: Sector1 Data: radius1 line index, radius2 line index, arc index
Type: General Data: number of lines, line indexes

Advantage:
If you have a line with segments the end point of a segment and the beginning point of the next segment is the same point. If you change the coordinates of that point both segments will be changed and the surface too.

A rectangle can be defined by 2 points (and angle) or 4 lines.
in the first case if you change the coordinates of one point both lines should be changed.
in the second case it's not really a rectangle but a special case of a General surface, if you change the coordinates of one point it will no longer be a rectangle.

I hope this is understandable!

Program:
As a user I would prefer having buttons in a toolbox instead of the menu it gives a better overview of the possibilities and active functions.

For the circle it would be interesting to be able to move the mouse for the radius, and display the circle in function of the mouse position and with the MouseUp event set the final values. Same for rectangle and ellipse.

For the grid I would suggest you to use a variable for the grid width instead of a number so if once you want to change it you just change the variable value and the rest is automatic, otherwise you would have to change x times the number.

To calculate the radius you don't need to use the Max and Min functions, a power of two is always positive.

Your routine to draw the arcs is only valid for small radiuses, with a radius of 100 the arc becomes a dotted line. Colin9876's routine is more universal in setting the angle step to the inverse of the radius.

In the drawing routines it would be more universal to transmit variables instead of dealing with the textbox contents in the routine.
Ex: DrawLine(x1, y1, x2, y2, col)

I put some of these suggestions in the joined program.

Best regards and good luck !
Attached Files
File Type: sbp SnapPointsKlaus.sbp (8.8 KB, 49 views)
__________________
Klaus
Switzerland
Reply With Quote
  #3 (permalink)  
Old 05-25-2008, 04:04 AM
Senior Member
 
Join Date: May 2007
Posts: 130
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi dennishea,

I like the idea once the application could produce an accurate scaled drawings.

It will be useful for its scale accurateness once printed-out on several paper sizes.

Once the application have zoom and pan feature, then this is way to go!

By the way...have you thought that the application should have drawing operation steps or style based on some popular CAD applications, like AutoCAD, Microstation or similar?

Best regards,
__________________
Rioven

Sony Ericsson XPERIA X1i WM6.1
480x800 Display Resolution
with QWERTY keyboard
Reply With Quote
  #4 (permalink)  
Old 05-25-2008, 02:52 PM
Senior Member
 
Join Date: Jul 2007
Posts: 147
Awards Showcase
Beta Tester 
Total Awards: 1
Default

@klaus & rioven

PHP Code:
My intention is to have a super stripped down version of autocad lite
Things it needs
         
1zoom.
         
2snap to.
                
aintersection.
                
bmid point.
                
cend point.
                
dcenter point "for circle and arc".
                
ethere are others but not sure they are a necessity.
         
3ability to size the drawing before starting.
         
4scroll leftrightupdown.
         
5it needs to be scalable to as tight as tolerance as possible.
         
6snap two points on drawing and get distance or angle           
         7
enter relative or absolute data manually
         8
printing would be nice but bmp is printable.
         
9offset 

bitmap 
or vector  I do not know difference or which is better for task.

In your list of surfaces you use the word indexcould you explain in simpler or 
more detailedAt this point I realize I don't have the education to do this by 
myself. I don'
t expect people to do this for me but a tiny example or point me 
in right direction 
for informationThanks for both your time and klauss examples.

p.s
I hope I have given enough to shed some light
__________________
Using 6.30
dennishea
Reply With Quote
  #5 (permalink)  
Old 05-25-2008, 04:32 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 707
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

Hi dennishea,

Yes, now the light is switched on !

To do what you want to do, you need to use vector graphics.

In vector graphics the points are stored in a list with their physical coordinates, the point index is it's position in that list. Lines are referred to these points and the graphic is a 'just' a display of it. The accuracy is garantied by the physical values.

In bitmap graphics you 'just color dots' the pixels. If you want to zoom you loose accuracy.

What do I mean with indexes?
Take the example of a line:
The line is determined by two points:
let's say point 3 and point 4 in the point list, 3 and 4 are the indexes.
In the line parameters the points are referred to by their position in the point list rather than with the points coordinates.
A same point can belong to more than one line.

The line belongs to a surface, in the surface parameter only the position of the line in the line list is stored.

I will look to make a first sample how I would see a program like this, and submit it as soon as there is something testable.

Best regards.
__________________
Klaus
Switzerland

Last edited by klaus : 05-25-2008 at 04:51 PM.
Reply With Quote
  #6 (permalink)  
Old 05-25-2008, 05:54 PM
Senior Member
 
Join Date: Jul 2007
Posts: 147
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi klaus Thanks very much for your .
__________________
Using 6.30
dennishea
Reply With Quote
  #7 (permalink)  
Old 05-27-2008, 04:30 PM
Knows the basics
 
Join Date: May 2008
Posts: 86
Default Cad

Hi Klaus and Dennishea

What I have done is to give the user an input sheet, where the person can enter the limits of the 4 corners of the screen. I then calculate a ratio between the screen size and the limits entered. This constant is then applied to the X and Y positions on the screen. The drawing information that is kept in the database is still correct, but when it gets plotted on the PPC, it gets adjusted by this ratio.

Vice versa is also true. When you plot a line on the PPC, it gets adjusted by this ratio...i.e. line(1000,1000,2000,2000) will get plotted on the screen as (50,50,100,100) depending on the ratio.

I should finish all the basic drawing stuff (lines, circles, arc...) by the end of the week and I will post it here again.

I have not given the zoom functions much attention yet.

Thanks
Michael
Reply With Quote
  #8 (permalink)  
Old 05-28-2008, 10:06 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 707
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

Hi Micheal,
Having a scaling factor for the pixel with the physical area and the display pixel dimensions was obvious to me. For me the open question was, when the these parameters are defined the scaling factor is given and there is no way to change it afterwords. And also in connection with the zoom.

Hi dennishea,
In all my programs I use variables for the parameters and save them just in simple text files.
At loading I allocate the values to the variables.
I used, until now, tables only when I needed them to display data.

Best regards.
__________________
Klaus
Switzerland

Last edited by klaus : 05-28-2008 at 10:15 AM.
Reply With Quote
  #9 (permalink)  
Old 05-28-2008, 01:05 PM
Senior Member
 
Join Date: Jul 2007
Posts: 147
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi klaus & ceaser

At klaus

Do you mean like an ini file for setting variable default or last used settings? Like default grid size, drawing size, inches or mm's, etc etc. In auto cad lite I believe min x,y or 0,0 is bottom left and max top right. Drawing size would be determined by the size of what I'm drawing. I'm assuming that the data you save would also contain drawing size, weather it was set up in inche
's or mm's with the coordinates of your lines, circles, arcs, and what not following. The table I've created holds the beginning and end points for lines, the center xy beginning angle end angle and radius for arc, and xy center and radius for circles. If there is a more efficient way of saving all the coordinates I would really like to learn it, the reason I used table is because it was the easiest for me. I will create and ini file for settings I want a template to start with and if I change them the changes can stay with that drawing file. I am just giving information for why I did what I did and if it's not the best direction for this type of program I would appreciate any help getting pointed in the right direction.

At ceaser

I like your image buttons. They do give visual support that this is a cad like program. In order to get the program to fire up I copied your zoomall jpg to create zoomin, zoomout and zoombox so the program would fire. I haven't tried to look thru it to see what works.

Thanks again for the support and help you both have given.

Denny
__________________
Using 6.30
dennishea

Last edited by dennishea : 05-28-2008 at 01:38 PM.
Reply With Quote
  #10 (permalink)  
Old 05-28-2008, 01:45 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 707
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

In my mind there would be 3 files.

- An *.ini, init file saving the general parameters of the program, independant of the drawing data.
Like:
- Do you want to be prompted before leaving the program ?
- Load the last used file at start-up ?
- Selcted language
etc.

- A *.cfg , configuration file for the general parameters of the drawing (grid size, darwing size etc.) with the last used values. But these parameters must also be saved in the *.dat file.

- A *.dat or any other extension (*.c2d for example), the data of the geomety, this file must include the congig data used for that particular drawing. But, when beginning a new drawing the user can choose another configuration.

An example of how I use this is in the Wine Cellar application Wine cellar manager,
where the *.cfg files exist in different languages.
Wine.ini init file
WineE.cfg english config file
WineF.cfg french config file
*.vin data files.

All these files are simple text files.

That's, for me, the simple way to do it.

I hope that in a few days I will have something to show.
At the moment I am still defining the user interface and the data structure.

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sketch drawing program klaus Share Your Creations 5 11-11-2008 04:55 PM
Back to the drawing board ...... taximania Chit Chat 13 06-17-2008 11:55 AM
Pen width and XOR drawing enonod Questions & Help Needed 2 06-01-2008 07:43 PM
drawing on/in gamewindow enonod Questions & Help Needed 2 05-25-2008 11:28 PM
RPaint - Drawing tool Stanl3yCZ Share Your Creations 0 01-21-2008 02:54 PM


All times are GMT. The time now is 04:38 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0