Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Scene2D/TextureBaseSceneLayer.cpp @ 1787:6e8105942146
safeguard in TextureBaseSceneLayer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 15 May 2021 11:47:55 +0200 |
parents | fca942f4b4a7 |
children | 3889ae96d2e9 |
comparison
equal
deleted
inserted
replaced
1786:748bfa7df18b | 1787:6e8105942146 |
---|---|
25 #include <Logging.h> | 25 #include <Logging.h> |
26 #include <OrthancException.h> | 26 #include <OrthancException.h> |
27 | 27 |
28 namespace OrthancStone | 28 namespace OrthancStone |
29 { | 29 { |
30 void TextureBaseSceneLayer::CheckNoManualTransform() const | |
31 { | |
32 if (transform_.get() != NULL) | |
33 { | |
34 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls, | |
35 "A transform has been manually set, first call ClearTransform()"); | |
36 } | |
37 } | |
38 | |
39 | |
30 void TextureBaseSceneLayer::SetTexture(Orthanc::ImageAccessor* texture) | 40 void TextureBaseSceneLayer::SetTexture(Orthanc::ImageAccessor* texture) |
31 { | 41 { |
32 if (texture == NULL) | 42 if (texture == NULL) |
33 { | 43 { |
34 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | 44 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
79 | 89 |
80 | 90 |
81 void TextureBaseSceneLayer::SetOrigin(double x, | 91 void TextureBaseSceneLayer::SetOrigin(double x, |
82 double y) | 92 double y) |
83 { | 93 { |
94 CheckNoManualTransform(); | |
95 | |
84 originX_ = x; | 96 originX_ = x; |
85 originY_ = y; | 97 originY_ = y; |
86 IncrementRevision(); | 98 IncrementRevision(); |
87 } | 99 } |
88 | 100 |
89 | 101 |
90 void TextureBaseSceneLayer::SetPixelSpacing(double sx, | 102 void TextureBaseSceneLayer::SetPixelSpacing(double sx, |
91 double sy) | 103 double sy) |
92 { | 104 { |
105 CheckNoManualTransform(); | |
106 | |
93 if (sx <= 0 || | 107 if (sx <= 0 || |
94 sy <= 0) | 108 sy <= 0) |
95 { | 109 { |
96 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 110 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
97 } | 111 } |
104 } | 118 } |
105 | 119 |
106 | 120 |
107 void TextureBaseSceneLayer::SetAngle(double angle) | 121 void TextureBaseSceneLayer::SetAngle(double angle) |
108 { | 122 { |
123 CheckNoManualTransform(); | |
124 | |
109 angle_ = angle; | 125 angle_ = angle; |
110 IncrementRevision(); | 126 IncrementRevision(); |
111 } | 127 } |
112 | 128 |
113 | 129 |
118 } | 134 } |
119 | 135 |
120 | 136 |
121 void TextureBaseSceneLayer::SetFlipX(bool flip) | 137 void TextureBaseSceneLayer::SetFlipX(bool flip) |
122 { | 138 { |
139 CheckNoManualTransform(); | |
140 | |
123 flipX_ = flip; | 141 flipX_ = flip; |
124 IncrementRevision(); | 142 IncrementRevision(); |
125 } | 143 } |
126 | 144 |
127 | 145 |
128 void TextureBaseSceneLayer::SetFlipY(bool flip) | 146 void TextureBaseSceneLayer::SetFlipY(bool flip) |
129 { | 147 { |
148 CheckNoManualTransform(); | |
149 | |
130 flipY_ = flip; | 150 flipY_ = flip; |
131 IncrementRevision(); | 151 IncrementRevision(); |
132 } | 152 } |
133 | 153 |
134 | 154 |