TsMeter missing a property?

Viewing 18 posts - 1 through 18 (of 18 total)
  • Author
    Posts
  • #53945
    JM-DG
    Participant

      Great component indeed. 🙂

      I would like to notify a minor memory leak in the acMeter.pas with the variable ShadowLayer : TBitmap.

      At line 428, there's this code:

      Code:
      ShadowLayer := CreateBmp32(MeterSize.cx, MeterSize.cy);

      I believe, It should be replace with something like:

      Code:
      if ShadowLayer = nil then
      begin
      ShadowLayer := CreateBmp32(MeterSize.cx, MeterSize.cy)
      end else
      begin // Clear canvas
      ShadowLayer.Canvas.Brush.Style := bsClear;
      ShadowLayer.Canvas.Brush.Color := $FFFFFF;
      ShadowLayer.Canvas.FillRect(Rect(0, 0, MeterSize.cx, MeterSize.cy));
      end;

      And add this line

      ShadowLayer.Canvas.Brush.Style := bsSolid;

      in the prepareCache procedure.

      Code:
      // Shadows
      if FPaintData.FDialShadow.Visible then begin
      ShadowLayer.Canvas.Pen.Color := $AAAAAA;
      ShadowLayer.Canvas.Pen.Width := 2;
      ShadowLayer.Canvas.Brush.Style := bsSolid; // Added line <============
      ShadowLayer.Canvas.Brush.Color := $FFFFFF;
      ShadowLayer.Canvas.Ellipse(Margin + ShadowOffset.X, Margin + ShadowOffset.Y,
      MeterSize.cx – Margin -1{+ ShadowOffset.X}, MeterSize.cy – Margin{ + ShadowOffset.Y});
      end;
      #53954
      Support
      Keymaster

        Thanks for messages, I will improve this component soon.

        The issue with memory leak will be fixed in the nearest release.

        #54027
        HeDiBo
        Participant
          'Support' wrote:

          Thanks for messages, I will improve this component soon.

          Thanks for updating TsMeter.

          • It should still be possible to set a position outside Max and Min, provided a special property (like IgnoreBounds) is set to True.[*]Setting the color for PaintData.ArrowColor should not change the color of the Dial.[*]It would be a good idea if the Caption could be made to reflect the value of the current Position (adding a Boolean property like CapShowPos).[*]Also the Captions for Min and Max should reflect the Min and Max values (maybe Boolean property CapShowMinMax).


          Using this project:

          [attachment=7326:acTestMeter.zip]

          when you click the button, you will find discrepancies between the TsStaticText Caption and the TsMeter.Caption. The meter's caption seems to lag behind one value :a1: when moving from one valid position to a next valid position.

          #53942
          Support
          Keymaster

            Thank you for files, I will add it in the nearest release )

            #54094
            HeDiBo
            Participant

              Thanks for updating TsMeter.

              Most of my comment seems to have found a way into the component. Thanks :a3:

              If IgnoreBounds is False and ShowCaptionValue is True, setting a position outside the bounds does not show the proper value in the Caption (it shows the Max or Min value, it should show the position value, to show it is outside the bounds), possibly the font color should take on some signal color (add boolean Property ShowCaptionAttention).

              #54110
              Support
              Keymaster
                Quote:
                …it shows the Max or Min value, it should show the position value, to show it is outside the bounds

                I'm not sure that this behaviour is correct, Caption shows current Position, but Position is limited by Min/Max if IgnoreBounds is False…

                #54116
                HeDiBo
                Participant
                  'Support' wrote:

                  I'm not sure that this behaviour is correct, Caption shows current Position, but Position is limited by Min/Max if IgnoreBounds is False…

                  The arrow cannot point beyond Min and Max values, where Position should be able to go outside these limits.

                  It's very enlightening to show that the arrow does not reflect the Position's actual value.

                  Think of this meter as used for pressure monitoring. It would be an enormous risk, not knowing what the actual pressure was when above the maximum value. In fact, that's the moment you really want to know the actual pressure. If used for temperature both the Min and Max values are very important.

                  In other words, IgnoreBounds should only affect the arrow, not the Position property. You might add a LimitPosition boolean property to get the current effect if true.

                  #54284
                  HeDiBo
                  Participant
                    'HeDiBo' wrote:

                    In other words, IgnoreBounds should only affect the arrow, not the Position property. You might add a LimitPosition boolean property to get the current effect if true.

                    If you think of “Position” as where the arrow is pointing, you are right. But in a real life situation that is next to useless.

                    If the liquid that's tested freezes, I want to know if that's because the temperature is -5 or -30. If MIN is set to 0, that does not show. But only the value -274 would be a proper MIN value in this case, making the meter useless.

                    Please change it, so to make the meter usable.

                    Adding the suggested LimitPosition property defaulted to True, would still produce the effect that you want.

                    #54285
                    HeDiBo
                    Participant

                      It would be a very valuable addition if all values were floats i.s.o. integers.

                      Think of an instrumentation setup where a Volt meter should show the voltage of a certain component.

                      If that value must be within the range 5.87 to 6.23 the TsMeter component cannot be used for that.

                      #54410
                      HeDiBo
                      Participant

                        No change in 10.21

                        #54420
                        Support
                        Keymaster

                          I was encountered with some difficulties in changing of these properties types.

                          If property is float, then I can't specify a default value for such property.

                          For example, I can't define the Max property to 100 as default value.

                          I'm searching the good way, but have not found it yet.

                          #54431
                          HeDiBo
                          Participant
                            'Support' wrote:

                            If property is float, then I can't specify a default value for such property.

                            For example, I can't define the Max property to 100 as default value.

                            But you can. Just think of those values as whole numbers, but because they're really floats, you have the best of both worlds.

                            Think of the possibilities. If you have a range of 0 – 100, you can now have increments of 2.5 🙄

                            #54433
                            Support
                            Keymaster

                              Delphi does not allow to set default values for float properties, this is the problem.

                              I'm agree that float value will be better in this component, but I can't set default values in this case.

                              #54454
                              HeDiBo
                              Participant
                                'Support' wrote:

                                Delphi does not allow to set default values for float properties, this is the problem.

                                I'm agree that float value will be better in this component, but I can't set default values in this case.

                                Have a close look at the TcxProgressBar component from Developer Express. It has a property named Properties and in it you find the properties Min and Max of type Double. They can have a default value, but only in the special way implemented by Developer Express. That procedure is similar as what is described in http://tiku.io/quest…-is-it-possible

                                The essence of it is to define a float property like this:

                                Code:
                                property MyFloat: Float read GetValue write SetValue stored IsMyFloatStored;

                                with a Boolean function IsMyFloatStored that returns True if MyFloat doesn't have its default value

                                #54535
                                Support
                                Keymaster

                                  I have tried this way, but without success, unfortunately.

                                  #54544
                                  HeDiBo
                                  Participant
                                    'Support' wrote:

                                    I have tried this way, but without success, unfortunately.

                                    Did you try it this way (I omitted the obvious setter method SetMyDouble):

                                    Code:
                                    interface

                                    const
                                    DefaultMyDouble: Double = 2/3;

                                    type
                                    TMyObject – class(TPersistent)
                                    private
                                    FMyDouble: Double;
                                    function IsMyDoubleStored: Boolean;
                                    public
                                    constructor Create(AOwner: TComponent); override;
                                    published
                                    property MyDouble: Double read FMyDouble
                                    write SetMyDouble
                                    stored IsMyDoubleStored;
                                    end{class};

                                    implementation

                                    constructor TMyObject.Create(AOwner: TComponent);
                                    begin
                                    inherited Create(AOwner);
                                    FMyDouble := DefaultMyDouble;
                                    end;

                                    function TMyObject.IsMyDoubleStored: Boolean;
                                    begin
                                    Result := FMyDouble DefaultMyDouble;
                                    end;

                                    I believe this is the simplest way to define a float property with a default value.

                                    #54545
                                    HeDiBo
                                    Participant

                                      Here is a proof of concept.

                                      It is a very minimal component, called TFloatProps.

                                      It's default value for property MaxValue is 2.68

                                      As you can see, it keeps this default until you overwrite the value with your own.

                                      [attachment=7516:FloatPropertyDemo.zip]

                                      #54546
                                      Support
                                      Keymaster

                                        Thank you, Dick, I will check it soon.

                                        Happy New Year!

                                      Viewing 18 posts - 1 through 18 (of 18 total)
                                      • You must be logged in to reply to this topic.