Click here to Skip to main content
15,907,149 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Get computer name ? Pin
kiran janaswamy24-Apr-06 2:14
kiran janaswamy24-Apr-06 2:14 
GeneralRe: Get computer name ? Pin
Surivevoli24-Apr-06 2:22
Surivevoli24-Apr-06 2:22 
GeneralRe: Get computer name ? Pin
Surivevoli24-Apr-06 7:00
Surivevoli24-Apr-06 7:00 
GeneralRe: Get computer name ? Pin
Eytukan24-Apr-06 2:14
Eytukan24-Apr-06 2:14 
GeneralRe: Get computer name ? Pin
Ryan Binns24-Apr-06 4:57
Ryan Binns24-Apr-06 4:57 
GeneralRe: Get computer name ? Pin
Surivevoli24-Apr-06 7:01
Surivevoli24-Apr-06 7:01 
GeneralRe: Get computer name ? Pin
David Crow24-Apr-06 7:16
David Crow24-Apr-06 7:16 
QuestionDiagrams: Axis Resolution Computation Pin
Sebastian Schneider23-Apr-06 22:36
Sebastian Schneider23-Apr-06 22:36 
Hi everybody Smile | :)

I am trying to get a program of mine to do a acceptable Axis-resolution computation. The software is intended to diplay standard graphs (value over item production id) and gaussian evaluations (i.e. "do we achieve gaussian distribution").

I have a problem with the axis computation, though. I am looking for a clever way to guarantee that (with a given max_Y and max_X) my axis ticks are useful.

This is what I have written so far:

<br />
void static calculateAxis(int& Min, int& Step, int& Max)<br />
    {<br />
        int Size = Max - Min; // Compute Axis Size<br />
        for(int i = 1; ; i *= 10) // for 10, 100, 1000... until abort=true<br />
        {<br />
            bool abort = false; <br />
            for(int j = i; j < 10 * i ; j += i) // for 10, 20, 30, ... 100, 200, 300 ...<br />
            {<br />
                if (Size < j) // is axis size within 0 .. j<br />
                {<br />
                    Step = j / 10; // try 1/10th of j as step size<br />
                    if (Min < 0) //negative minimum?<br />
                    {<br />
                        // set minimum to nearest multiple of stepsize<br />
                        Min = Min - (Min % (j / 10)); <br />
                        Min -= (j / 10);<br />
                    }<br />
                    else Min = (Min/i)*i; <br />
<br />
                    if (Step == 0) Step = 1; // minimum stepsize: 1<br />
                    if ((Max % Step) > (Step / 2))   <br />
                        if      ( (j-i) > 0 ) <br />
                            Step = (j-i) / 10; // set stepsize to one tenth of difference<br />
                    abort = true; // we are done here<br />
                    break;<br />
                }<br />
            }<br />
            if (abort) break;<br />
        }<br />
}


My problem here is: I totally forgot that my Y_Max could be something like "0.44", which makes my integer-based approach useless.

Any suggestions, hints or links would be welcome.

Edit:
I think I forgot to make this clear Wink | ;)
What I get when I "hard"-divide a max-val by 10 is not useful to be. Noone would be able to
derive values from that diagram if the corresponding "axis tick"-label reads 1283.34 and the
increment for each tick is 641.7-something. I need "readable" tick-labels. Thats what I am after.

Edit2: Tried to add some explanatory comments.

Cheers,
Sebastian

--
Contra vim mortem non est medicamen in hortem.

-- modified at 5:09 Monday 24th April, 2006
AnswerRe: Diagrams: Axis Resolution Computation Pin
Cedric Moonen23-Apr-06 22:56
Cedric Moonen23-Apr-06 22:56 
GeneralRe: Diagrams: Axis Resolution Computation Pin
Sebastian Schneider23-Apr-06 23:32
Sebastian Schneider23-Apr-06 23:32 
GeneralRe: Diagrams: Axis Resolution Computation Pin
Sebastian Schneider26-Apr-06 2:33
Sebastian Schneider26-Apr-06 2:33 
GeneralRe: Diagrams: Axis Resolution Computation Pin
Cedric Moonen26-Apr-06 2:43
Cedric Moonen26-Apr-06 2:43 
QuestionInstaniating objects of unknown class definitions Pin
christopher.carver23-Apr-06 20:23
christopher.carver23-Apr-06 20:23 
AnswerRe: Instaniating objects of unknown class definitions Pin
Michael Dunn23-Apr-06 20:33
sitebuilderMichael Dunn23-Apr-06 20:33 
AnswerRe: Instaniating objects of unknown class definitions Pin
Cedric Moonen23-Apr-06 20:38
Cedric Moonen23-Apr-06 20:38 
AnswerRe: Instaniating objects of unknown class definitions Pin
Steve Echols23-Apr-06 20:55
Steve Echols23-Apr-06 20:55 
QuestionNative Applicaion Pin
rajeevktripathi23-Apr-06 19:49
rajeevktripathi23-Apr-06 19:49 
AnswerRe: Native Applicaion Pin
includeh1023-Apr-06 20:40
includeh1023-Apr-06 20:40 
GeneralRe: Native Applicaion Pin
Stephen Hewitt23-Apr-06 21:36
Stephen Hewitt23-Apr-06 21:36 
AnswerRe: Native Applicaion Pin
Stephen Hewitt23-Apr-06 21:41
Stephen Hewitt23-Apr-06 21:41 
QuestionHelp me!!! Pin
sieucauthu23-Apr-06 19:21
sieucauthu23-Apr-06 19:21 
AnswerRe: Help me!!! Pin
Manish K. Agarwal23-Apr-06 19:37
Manish K. Agarwal23-Apr-06 19:37 
GeneralRe: Help me!!! Pin
sieucauthu23-Apr-06 19:46
sieucauthu23-Apr-06 19:46 
AnswerRe: Help me!!! Pin
Le Thanh Cong23-Apr-06 20:21
Le Thanh Cong23-Apr-06 20:21 
AnswerRe: Help me!!! Pin
Michael Dunn23-Apr-06 20:39
sitebuilderMichael Dunn23-Apr-06 20:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.