[219] | 1 | #include "axis.hpp" |
---|
| 2 | |
---|
[352] | 3 | #include "attribute_template.hpp" |
---|
| 4 | #include "object_template.hpp" |
---|
| 5 | #include "group_template.hpp" |
---|
| 6 | #include "message.hpp" |
---|
| 7 | #include "type.hpp" |
---|
| 8 | #include "xmlioserver_spl.hpp" |
---|
[219] | 9 | |
---|
[335] | 10 | namespace xios { |
---|
[566] | 11 | |
---|
[219] | 12 | /// ////////////////////// Définitions ////////////////////// /// |
---|
| 13 | |
---|
| 14 | CAxis::CAxis(void) |
---|
| 15 | : CObjectTemplate<CAxis>() |
---|
| 16 | , CAxisAttributes(), isChecked(false), relFiles() |
---|
| 17 | { /* Ne rien faire de plus */ } |
---|
| 18 | |
---|
| 19 | CAxis::CAxis(const StdString & id) |
---|
| 20 | : CObjectTemplate<CAxis>(id) |
---|
| 21 | , CAxisAttributes(), isChecked(false), relFiles() |
---|
| 22 | { /* Ne rien faire de plus */ } |
---|
| 23 | |
---|
| 24 | CAxis::~CAxis(void) |
---|
| 25 | { /* Ne rien faire de plus */ } |
---|
| 26 | |
---|
| 27 | ///--------------------------------------------------------------- |
---|
| 28 | |
---|
| 29 | const std::set<StdString> & CAxis::getRelFiles(void) const |
---|
| 30 | { |
---|
| 31 | return (this->relFiles); |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | bool CAxis::IsWritten(const StdString & filename) const |
---|
| 35 | { |
---|
| 36 | return (this->relFiles.find(filename) != this->relFiles.end()); |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | void CAxis::addRelFile(const StdString & filename) |
---|
| 40 | { |
---|
| 41 | this->relFiles.insert(filename); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | //---------------------------------------------------------------- |
---|
| 45 | |
---|
| 46 | StdString CAxis::GetName(void) { return (StdString("axis")); } |
---|
| 47 | StdString CAxis::GetDefName(void){ return (CAxis::GetName()); } |
---|
| 48 | ENodeType CAxis::GetType(void) { return (eAxis); } |
---|
| 49 | |
---|
| 50 | //---------------------------------------------------------------- |
---|
| 51 | |
---|
| 52 | void CAxis::checkAttributes(void) |
---|
| 53 | { |
---|
| 54 | if (this->isChecked) return; |
---|
[351] | 55 | if (this->size.isEmpty()) |
---|
[566] | 56 | ERROR("CAxis::checkAttributes(void)", |
---|
| 57 | << "Attribute <size> of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be specified"); |
---|
[219] | 58 | StdSize size = this->size.getValue(); |
---|
[566] | 59 | |
---|
| 60 | StdSize zoom_begin,zoom_end, zoom_size; |
---|
| 61 | |
---|
| 62 | zoom_begin = (this->zoom_begin.isEmpty()) ? 1 : this->zoom_begin.getValue(); |
---|
| 63 | zoom_end = (this->zoom_end.isEmpty()) ? size : this->zoom_end.getValue(); |
---|
| 64 | zoom_size = (this->zoom_size.isEmpty()) ? size : this->zoom_size.getValue(); |
---|
| 65 | |
---|
| 66 | if (this->zoom_begin.isEmpty()) zoom_begin=zoom_end-zoom_size+1; |
---|
| 67 | if (this->zoom_end.isEmpty()) zoom_end=zoom_begin+zoom_size-1; |
---|
| 68 | if (this->zoom_size.isEmpty()) zoom_size=zoom_end-zoom_begin+1; |
---|
| 69 | |
---|
[351] | 70 | if ( (zoom_begin < 1) || (zoom_begin > size) || (zoom_end<1) || (zoom_end>size) || (zoom_size<1) || (zoom_size>size) || (zoom_begin>zoom_end)) |
---|
[566] | 71 | ERROR("CAxis::checkAttributes(void)", |
---|
| 72 | << "One or more attributes among <zoom_begin>, <zoom_end>, <zoom_size> of axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] are not well specified"); |
---|
| 73 | this->zoom_begin.setValue(zoom_begin); |
---|
| 74 | this->zoom_end.setValue(zoom_end); |
---|
| 75 | this->zoom_size.setValue(zoom_size); |
---|
| 76 | |
---|
[369] | 77 | StdSize true_size = value.numElements(); |
---|
[219] | 78 | if (size != true_size) |
---|
| 79 | ERROR("CAxis::checkAttributes(void)", |
---|
[566] | 80 | << "The array \'value\' of axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] has a different size that the one defined by the \'size\' attribute"); |
---|
[219] | 81 | |
---|
[609] | 82 | if (!bounds.isEmpty()) |
---|
| 83 | { |
---|
[713] | 84 | if (bounds.extent(0) != 2 || bounds.extent(1) != size) |
---|
[609] | 85 | ERROR("CAxis::checkAttributes(void)", |
---|
[713] | 86 | << "The bounds array of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be of dimension axis 2 x size" << endl |
---|
[609] | 87 | << "Axis size is " << size << endl |
---|
| 88 | << "Bounds size is "<< bounds.extent(0) << " x " << bounds.extent(1)); |
---|
| 89 | } |
---|
| 90 | |
---|
[219] | 91 | this->isChecked = true; |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | ///--------------------------------------------------------------- |
---|
| 95 | |
---|
[335] | 96 | } // namespace xios |
---|