1 | #include "zoom_axis.hpp" |
---|
2 | #include "type.hpp" |
---|
3 | |
---|
4 | namespace xios { |
---|
5 | |
---|
6 | /// ////////////////////// Définitions ////////////////////// /// |
---|
7 | |
---|
8 | CZoomAxis::CZoomAxis(void) |
---|
9 | : CObjectTemplate<CZoomAxis>(), CZoomAxisAttributes(), CTransformation<CAxis>() |
---|
10 | { /* Ne rien faire de plus */ } |
---|
11 | |
---|
12 | CZoomAxis::CZoomAxis(const StdString & id) |
---|
13 | : CObjectTemplate<CZoomAxis>(id), CZoomAxisAttributes(), CTransformation<CAxis>() |
---|
14 | { /* Ne rien faire de plus */ } |
---|
15 | |
---|
16 | CZoomAxis::~CZoomAxis(void) |
---|
17 | {} |
---|
18 | |
---|
19 | CTransformation<CAxis>* CZoomAxis::create(const StdString& id, xml::CXMLNode* node) |
---|
20 | { |
---|
21 | CZoomAxis* zoomAxis = CZoomAxisGroup::get("zoom_axis_definition")->createChild(id); |
---|
22 | if (node) zoomAxis->parse(*node); |
---|
23 | return static_cast<CTransformation<CAxis>*>(zoomAxis); |
---|
24 | } |
---|
25 | |
---|
26 | bool CZoomAxis::registerTrans() |
---|
27 | { |
---|
28 | return registerTransformation(TRANS_ZOOM_AXIS, CZoomAxis::create); |
---|
29 | } |
---|
30 | |
---|
31 | bool CZoomAxis::_dummyRegistered = CZoomAxis::registerTrans(); |
---|
32 | |
---|
33 | //---------------------------------------------------------------- |
---|
34 | |
---|
35 | StdString CZoomAxis::GetName(void) { return StdString("zoom_axis"); } |
---|
36 | StdString CZoomAxis::GetDefName(void) { return StdString("zoom_axis"); } |
---|
37 | ENodeType CZoomAxis::GetType(void) { return eZoomAxis; } |
---|
38 | |
---|
39 | void CZoomAxis::checkValid(CAxis* axisDest) |
---|
40 | { |
---|
41 | int axisIBegin, axisNi, axisGlobalSize; |
---|
42 | int begin, end, n; |
---|
43 | |
---|
44 | axisIBegin = axisDest->begin.getValue(); |
---|
45 | axisNi = axisDest->n.getValue(); |
---|
46 | axisGlobalSize = axisDest->n_glo.getValue(); |
---|
47 | |
---|
48 | bool zoomByIndex = !this->index.isEmpty() && (0 != this->index.numElements()); |
---|
49 | |
---|
50 | if (zoomByIndex) |
---|
51 | { |
---|
52 | begin = min(this->index); |
---|
53 | end = max(this->index); |
---|
54 | n = end - begin + 1; |
---|
55 | } |
---|
56 | else |
---|
57 | { |
---|
58 | begin = (this->begin.isEmpty()) ? 0 : this->begin.getValue(); |
---|
59 | n = (this->n.isEmpty()) ? axisGlobalSize : this->n.getValue(); |
---|
60 | end = begin+n-1; |
---|
61 | } |
---|
62 | |
---|
63 | if (begin < 0 || begin > axisGlobalSize - 1 || end < 0 || end > axisGlobalSize - 1 |
---|
64 | || n < 1 || n > axisGlobalSize || begin > end) |
---|
65 | ERROR("CZoomAxis::checkValid(CAxis* axisDest)", |
---|
66 | << "One or more attributes among 'begin' (" << begin << "), 'end' (" << end << "), 'n' (" << n << ") " |
---|
67 | << "of axis transformation [ id = '" << axisDest->getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] are not well specified"); |
---|
68 | |
---|
69 | if (zoomByIndex && (!this->begin.isEmpty() || !this->n.isEmpty())) |
---|
70 | ERROR("CZoomAxis::checkValid(CAxis* axisDest)", |
---|
71 | << "Only one type of zoom is accepted. Define zoom by index with global_zoom_index or define zoom with begin and n. " |
---|
72 | << "Axis transformation [ id = '" << axisDest->getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] are not well specified"); |
---|
73 | |
---|
74 | this->begin.setValue(begin); |
---|
75 | this->n.setValue(n); |
---|
76 | |
---|
77 | } |
---|
78 | |
---|
79 | } |
---|