Profile Picture

Gauge Axis Questions

Posted By Lou Laskey 11 Years Ago
Author
Message
Lou Laskey
Posted 11 Years Ago
View Quick Profile
Junior Member

Junior Member (24 reputation)Junior Member (24 reputation)Junior Member (24 reputation)Junior Member (24 reputation)Junior Member (24 reputation)Junior Member (24 reputation)Junior Member (24 reputation)Junior Member (24 reputation)Junior Member (24 reputation)

Group: Forum Members
Last Active: 9 Years Ago
Posts: 24, Visits: 2

1. Update labels.

 I still am not seeing the updated lables on the screen.  Here is the code I am using:

 public void ModifyScaleLabels(NGaugeAxis axis,
                                                 List<ScaleItemsStruct> argScaleItems)

 {
      // only set the local label struct if this isn't it
      if (!argScaleItems.Equals(scaleItems))
      {
        scaleItems.Clear();
        scaleItems.AddRange(argScaleItems);
      }

      // get the scale configurator
      NLinearScaleConfigurator configurator = (NLinearScaleConfigurator)axis.ScaleConfigurator;

      // clear old labels
      configurator.Labels.Clear();

      // set range and viewrange
      axis.Scale.ViewRange = new NRange1DD(0, argScaleItems.Count - 1);
      axis.Range = new NRange1DD(0, argScaleItems.Count - 1);

      // add the new lables
      foreach (ScaleItemsStruct sis in argScaleItems)
      {
        configurator.Labels.Add(sis.itemText);
      }

      // update the scale
      axis.UpdateScale();

      // if loading flag is not set then refresh all
      if (!bLoading)
        Refresh();
    }

   As I mentioned, if I look at the the ScaleConfigurator -> Labels via the editor they are correct.

2. Hit test

   This solution worked perfectly.

Thanks,

Lou



Nevron Support
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Lou,

1. You need to call:

someAxis.UpdateScale();

where someAxis is the gauge axis you modify. In general the scale configurator when attached to an axis will update the scale automatically, however in the case of labels you need to update it from code.

2. You can use the following code to accomplish this:

NPointF modelPoint = someGaugePanel.TransformViewToModelPoint(new NPointF(e.X, e.Y));
double scaleValue = axis.TransformModelToScale(modelPoint.X, false);

where "e" is mouse event args.

Let us know if you meet any problems...



Best Regards,
Nevron Support Team



Lou Laskey
Posted 11 Years Ago
View Quick Profile
Junior Member

Junior Member (24 reputation)Junior Member (24 reputation)Junior Member (24 reputation)Junior Member (24 reputation)Junior Member (24 reputation)Junior Member (24 reputation)Junior Member (24 reputation)Junior Member (24 reputation)Junior Member (24 reputation)

Group: Forum Members
Last Active: 9 Years Ago
Posts: 24, Visits: 2

I have a couple questions regarding gauges and thought I would put them in one post:

1. Axis labels not changing.

I have a linear gauge with my labels on the axis (autoLabels = false).  Initially it is fine but I sometimes need to change the labels while running.  I set the new labels by clearing old (.Labels.Clear()) then adding the labels (.Labels.Add(someText)).  The new lables are not displaying.  If I access the chart editor after changing the labels I can see the new text in the Labels list in the ScaleConfigurator but not on the form.  I have tried Refresh at all levels (Gauge panel, chart control, form) to no avail.

2. HitTest on gauge axis

When a mouse down event occurs and the hit is on the gauge axis I want to be able to move the indicator to that value.  I can determine that the hit occurred on the axis but I am having some issue converting it to a value.  There was a response on here how to accomplish this on a chart but not a gauge, unless I am missing something simple (which is certainly a possibility) and I am making this more difficult than it is (which, according to some, is the more likely).

TIA,

Lou





Similar Topics


Reading This Topic