00001 // This is core/vcsl/vcsl_axis.cxx 00002 #include "vcsl_axis.h" 00003 00004 #include <vcl_cassert.h> 00005 00006 #include <vcsl/vcsl_dimension.h> 00007 #include <vcsl/vcsl_length.h> 00008 #include <vcsl/vcsl_meter.h> 00009 00010 //--------------------------------------------------------------------------- 00011 // Default constructor. Axis with length in meters and an empty label 00012 //--------------------------------------------------------------------------- 00013 vcsl_axis::vcsl_axis() 00014 { 00015 dimension_ = vcsl_length::instance().ptr(); 00016 unit_ = vcsl_meter::instance().ptr(); 00017 } 00018 00019 //--------------------------------------------------------------------------- 00020 // Constructor from dimension. Unit is the standard one. Label is empty 00021 //--------------------------------------------------------------------------- 00022 vcsl_axis::vcsl_axis(vcsl_dimension_sptr const& new_dimension) 00023 { 00024 dimension_=new_dimension; 00025 unit_=dimension_->standard_unit(); 00026 } 00027 00028 //--------------------------------------------------------------------------- 00029 // Constructor from dimension and unit. Label is empty 00030 // REQUIRE: new_dimension.compatible_unit(new_unit) 00031 //--------------------------------------------------------------------------- 00032 vcsl_axis::vcsl_axis(vcsl_dimension_sptr const& new_dimension, 00033 vcsl_unit_sptr const& new_unit) 00034 { 00035 // require 00036 assert(new_dimension->compatible_unit(new_unit)); 00037 00038 dimension_=new_dimension; 00039 unit_=new_unit; 00040 } 00041 00042 //--------------------------------------------------------------------------- 00043 // Set the dimension. The unit is set with the standard unit 00044 //--------------------------------------------------------------------------- 00045 void vcsl_axis::set_dimension(vcsl_dimension_sptr const& new_dimension) 00046 { 00047 dimension_=new_dimension; 00048 unit_=dimension_->standard_unit(); 00049 } 00050 00051 //--------------------------------------------------------------------------- 00052 // Set the dimension and the unit 00053 // REQUIRE: new_dimension.compatible_unit(new_unit) 00054 //--------------------------------------------------------------------------- 00055 void vcsl_axis::set_dimension_and_unit(vcsl_dimension_sptr const& new_dimension, 00056 vcsl_unit_sptr const& new_unit) 00057 { 00058 // require 00059 assert(new_dimension->compatible_unit(new_unit)); 00060 00061 dimension_=new_dimension; 00062 unit_=new_unit; 00063 } 00064 00065 //--------------------------------------------------------------------------- 00066 // Set the unit of the dimension 00067 // REQUIRE dimension()->compatible_unit(new_unit) 00068 //--------------------------------------------------------------------------- 00069 void vcsl_axis::set_unit(vcsl_unit_sptr const& new_unit) 00070 { 00071 // require 00072 assert(dimension()->compatible_unit(new_unit)); 00073 00074 unit_=new_unit; 00075 }