-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings_edit-generic_scale.ads
More file actions
82 lines (81 loc) · 4.11 KB
/
strings_edit-generic_scale.ads
File metadata and controls
82 lines (81 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
-- --
-- package Copyright (c) Dmitry A. Kazakov --
-- Strings_Edit.Generic_Scale Luebeck --
-- Interface Spring, 2007 --
-- --
-- Last revision : 21:03 21 Apr 2009 --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public License as --
-- published by the Free Software Foundation; either version 2 of --
-- the License, or (at your option) any later version. This library --
-- is distributed in the hope that it will be useful, but WITHOUT --
-- ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have --
-- received a copy of the GNU General Public License along with --
-- this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
--____________________________________________________________________--
--
-- This package is used for automatic evaluation of the positions of
-- the ticks on a scale. The scale looks like:
--
-- Low | High |
-- -->| Count = 5 -->|
-- | |
-- | | | | | | ||
-- || | | | | | | | | | | | | | | | | | | | | | | | | | ||
-- |\ \ \ | |
-- | First tick \ A minor tick ->|-|<-- Minor
-- -->| Low_Value A major tick
-- Low_Tick = 4 Ticks = 4
--
generic
type Value is digits <>;
package Strings_Edit.Generic_Scale is
--
-- Scale -- The scale description
--
type Scale is record
Minor : Value'Base; -- The minor tick step
Low_Value : Value; -- The first tick value
Low_Tick : Natural; -- The first tick number 0..Ticks
Ticks : Natural; -- The number of minor ticks
Small : Integer; -- The absolute precison of major ticks
end record;
--
-- Create -- Create scale
--
-- Low - The low value of the scale
-- High - The high value of the scale
-- Count - The approximate number of major tick (lower bound)
--
-- This function creates a scale fitting the parameters. The first tick
-- may differ from Low. The function tries to find a major tick length
-- such that the interval [Low, High] could be split into no less than
-- Count major ticks. Zero Count is treated as 1. The major tick length
-- on the value scale is chosen to be L={1|2|5}*10**n. The locations of
-- major ticks are selected at m*L. The minor ticks are selected
-- depending on L:
--
-- L=1*10**n | . | . | . | . | . | (1 minor tick)
-- L=2*10**n | . | . | . | . | . | (1 minor tick)
-- L=5*10**n | . . . . | . . . . | (4 minor ticks)
--
-- The field Small can be used for resonable output of the values
-- associated with the major ticks.
--
-- Exceptions :
--
-- Constraint_Error - Low >= High
--
function Create (Low, High : Value; Count : Natural) return Scale;
end Strings_Edit.Generic_Scale;