ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  How to change Linear Meter scale width?
Posted by Steve Valliere on May-17-2018 23:46
Attachments:
I have been searching through the help file and sample code to find out how to change the width (or thickness?) of the part of a linear meter that the value pointers point into and this does not seem to be possible.  I would *REALLY* like to be able to make that area narrower for some of my uses and I suppose that would mean making the pointer shorter as well.  In case I'm not clear, I'm attaching a sample image showing the part of the linear meters that I would like to adjust.

I tried changing the tick length (with setTickLength) but that only changes the tick lines themselves, not the area.  Also, the default tick length is documented as the same as the width of the area I want to alter, but there doesn't appear to be any way to discover or change that default width.

I hope that some seemingly unrelated setting (at least to me) such as setRail is what I need, but if so I am completely missing the association.

Help?
LinearMeterQuestion.png

  Re: How to change Linear Meter scale width?
Posted by Peter Kwan on May-18-2018 01:53
Hi Steve,

In the code that creates the meter, there is a line that sets the width and height of the part you want to change. It is:

// Set the scale region top-left corner at (14, 23), with size of 218 x 20 pixels. The scale
// labels are located on the top (implies horizontal meter)
m->setMeter(14, 23, 218, 20, Chart::Top);

In the above, the height is 20 pixels (it is for a horizontal meter). If you change it to 10 pixels, the "scale region" will be narrower.

Hope this can help.

Regards
Peter Kwan

  Re: How to change Linear Meter scale width?
Posted by Steve Valliere on May-18-2018 04:13
Actually, it doesn't help much.  After reading your reply I tried a few extreme size changes and did notice that the width is changing, but it appears completely dependent on the size of the exterior of the meter (or vice-versa).  I was trying to set the two sizes independently, which appears to be impossible.

Please tell me that I'm wrong.  <smile>  Thanks for your (always great) help either way!

  Re: How to change Linear Meter scale width?
Posted by Peter Kwan on May-18-2018 05:04
Hi Steve,

Sorry, I am not too sure what you mean by "completely dependent on the size of the exterior of the meter (or vice-versa)". Are you referring to the "rail" on which the meter pointer slides on?

The "rail" of a meter is like the x-axis or y-axis of an XYChart. The x-axis and y-axis is always "docked" to the border of the plot area, and the "rail" is docked to the side of the "meter plot area". You can use LinearMeter.setRail to configure the gap between the "meter plot area" and the rail. So if you want the rail not to move with the "meter plot area", you just need to adjust the rail gap by the same amount in the opposite direction.

If the above is not what you need, is it possible to include a "mock up" meter image to help me understand what you need?

Regards
Peter Kwan

  Re: How to change Linear Meter scale width?
Posted by Steve Valliere on May-18-2018 20:03
Attachments:
OK, I attached an image with several examples that will hopefully help me explain what I'm trying to ask/say.  For reference, I am going to refer to the green/yellow/red part of each meter as the scale (the numbers above/left would be the scale labels) and I am including the rail and value pointer as part of the scale.

Simply put, I wish I had the ability to set the position and size of the scale area independently within the meter area.

The examples appear to show that the scaling of the scale area is independent of any additional text objects added.

The examples also show that the scaling is oddly imperfect since the ends of the scale area may be cut off by (or at least too close to) frame on the short vertical version, while the tall vertical version ended up with quite a bit of unused space.  The horizontal examples show similar issues, especially with the height of the scale area vs the amount of empty space.  As the horizontal meter is made thinner (in hopes of eliminating empty space) the scale labels eventually get chopped off just as the empty space is eliminated.

My perfect meter would be a meter showing the scale area only, filling the size of the thinnest horizontal examples.

I am also attaching the test functions I am using.  By say of explanation, I typically start by scaling your example's measurements to the size I want so that all of the parts keep the same relative positions, which worked great for angular meters and *I think* is working as intended for these linear meters, too.  I usually start with your sample and tweak/add until I get what I need.  All of our projects are in C, except were required for using ChartDirector -- there is no .NET, MFC or any other framework in use.  We are building for Windows 10 Pro x64.

(Related wish:  I wish I could completely eliminate everything that is NOT part of the scale area (i.e. the dark green border and the light green area surrounding the scale area.)  I know I could make them black, but the image would still occupy much more screen area that I would like.)

(Another Related wish:  I wish the Windows version of the library included a function that could correctly transfer ChartDirector output to a device context (screen/printer) so that the Chart::Transparent color could safely be used.  It seems like a big oversite for a library dedicated to generating graphics to provide no way to display them.)
vlmeter.cpp
vlmeter.cpp

8.37 Kb
hlmeter.cpp
hlmeter.cpp

8.90 Kb
   
Meter Test Page_2.png

  Re: How to change Linear Meter scale width?
Posted by Peter Kwan on May-19-2018 02:38
Hi Steve,

In ChartDirector, the sizes of most of the chart objects are specified by your code. If your code specifies that the entire meter is 300 x 100 in size, then the size of the entire meter is 300 x 100. If your code specifies the font size is 20 points, then the font size is 20 points. So for certain parameters, it is entirely possible for some contents to overflow the chart. Your code would need to use reasonable parameters to avoid overflowing.

If you always use the same font size, then the text height is quite predictable, and your code should be able to determine the chart size that is sufficient to contain all the contents in the chart.

The chart will not have an outside rounded frame unless your code adds the frame. For example, in your code, you use:

LinearMeter *m = new LinearMeter(sMeter.cx, sMeter.cy, bgColor, borderColor);
m->setRoundedFrame(exteriorColor);//Chart::Transparent);
m->setThickFrame(3);

The above code adds the rounded frame with the setRoundFrame and setThickFrame method call. If you leave out these two lines, the chart will have no rounded frame. The background color and the border color of the chart is also specified by your code (the bgColor and borderColor parameters). You can specify other colors if you like.

Drawing the chart output to the printer device context is the function of the Windows API, not ChartDirector. In your code, I see that you use StretchDIBits. As mentioned in my other message, StretchDIBits does not handle transparency well. In our own code in CChartViewer.cpp, we use AlphaBlend. See also:

http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1525787125#N1525847392

For printing, a common method to handle transparency is to simply use white as the background color. It is because most printers cannot print the white color. (Most printers use RGB inks or toners, and it is not possible to print the white color. There are special printers that have white inks, but there are very rare.) So most printers will handle the white color by not printing anything. That is, the white color is equivalent to transparent for a printer.

Regards
Peter Kwan

  Re: How to change Linear Meter scale width?
Posted by Steve Valliere on May-18-2018 21:08
Please ignore my long response from earlier.  I finally figured it out -- at least the part I was asking about.  Somehow, I totally missed that m->setMeter() was responsible for both of the values I was trying to set!  I apologize for my confusion -- I'm an old C programmer trying to use a (very well crafted) C++ library.

That said, there are some other things I'm curious about:

#1:  I wish I could completely eliminate everything that is NOT part of the scale area (i.e. the dark green border and the light green area surrounding the scale area.)  I know I could make them black, but the image would still occupy much more screen area that I would like and if I'm trying to be very narrow the outer edge may cut off the scale labels (you can see that in the narrowest horizontal linear meters from my longer post).

I can probably get close to this by not using the rounded corners (obviously) and setting the thickFrame to 1 or even zero, if that will work.

#2:  Is there any chance that you might add a new special color for Chart::Inverse that uses the opposite color from the pixels being replaced?  I can see several uses for that color in my projects.

#3:  I wish the Windows version of the library included a function that could correctly transfer ChartDirector output to a device context (screen/printer) so that the Chart::Transparent color could safely be used.  It seems like a big oversite for a library dedicated to generating graphics to provide no way to display them.