vcsl_axis.cxx
Go to the documentation of this file.
1 // This is core/vcsl/vcsl_axis.cxx
2 #include "vcsl_axis.h"
3 
4 #include <cassert>
5 #ifdef _MSC_VER
6 # include <vcl_msvc_warnings.h>
7 #endif
8 
9 #include <vcsl/vcsl_dimension.h>
10 #include <vcsl/vcsl_length.h>
11 #include <vcsl/vcsl_meter.h>
12 
13 //---------------------------------------------------------------------------
14 // Default constructor. Axis with length in meters and an empty label
15 //---------------------------------------------------------------------------
17 {
20 }
21 
22 //---------------------------------------------------------------------------
23 // Constructor from dimension. Unit is the standard one. Label is empty
24 //---------------------------------------------------------------------------
26 {
27  dimension_=new_dimension;
28  unit_=dimension_->standard_unit();
29 }
30 
31 //---------------------------------------------------------------------------
32 // Constructor from dimension and unit. Label is empty
33 // REQUIRE: new_dimension.compatible_unit(new_unit)
34 //---------------------------------------------------------------------------
36  vcsl_unit_sptr const& new_unit)
37 {
38  // require
39  assert(new_dimension->compatible_unit(new_unit));
40 
41  dimension_=new_dimension;
42  unit_=new_unit;
43 }
44 
45 //---------------------------------------------------------------------------
46 // Set the dimension. The unit is set with the standard unit
47 //---------------------------------------------------------------------------
49 {
50  dimension_=new_dimension;
51  unit_=dimension_->standard_unit();
52 }
53 
54 //---------------------------------------------------------------------------
55 // Set the dimension and the unit
56 // REQUIRE: new_dimension.compatible_unit(new_unit)
57 //---------------------------------------------------------------------------
59  vcsl_unit_sptr const& new_unit)
60 {
61  // require
62  assert(new_dimension->compatible_unit(new_unit));
63 
64  dimension_=new_dimension;
65  unit_=new_unit;
66 }
67 
68 //---------------------------------------------------------------------------
69 // Set the unit of the dimension
70 // REQUIRE dimension()->compatible_unit(new_unit)
71 //---------------------------------------------------------------------------
72 void vcsl_axis::set_unit(vcsl_unit_sptr const& new_unit)
73 {
74  // require
75  assert(dimension()->compatible_unit(new_unit));
76 
77  unit_=new_unit;
78 }
vcsl_axis()
Default constructor. Axis with length in meters and an empty label.
Definition: vcsl_axis.cxx:16
void set_unit(vcsl_unit_sptr const &new_unit)
Set the unit of the dimension.
Definition: vcsl_axis.cxx:72
vcsl_unit_sptr unit_
Unit of the dimension.
Definition: vcsl_axis.h:98
vcsl_dimension_sptr dimension_
Dimension.
Definition: vcsl_axis.h:95
Standard unit associated to the length dimension.
static vcsl_length_sptr instance()
Return the reference to the unique vcsl_length object.
Definition: vcsl_length.cxx:24
void set_dimension(vcsl_dimension_sptr const &new_dimension)
Set the dimension. The unit is set with the standard unit.
Definition: vcsl_axis.cxx:48
Axis descriptor: a dimension, a unit, a label.
void set_dimension_and_unit(vcsl_dimension_sptr const &new_dimension, vcsl_unit_sptr const &new_unit)
Set the dimension and the unit.
Definition: vcsl_axis.cxx:58
static vcsl_meter_sptr instance()
Return the reference to the unique vcsl_meter object.
Definition: vcsl_meter.cxx:7
Length dimension.
vcsl_dimension_sptr dimension() const
Return the dimension.
Definition: vcsl_axis.h:62
T * ptr() const
Abstract dimension.