Skip to content

Commit f7dc8a8

Browse files
committed
revert to string for filepath due to msys error. Override customDraw ofNode function.
1 parent e353686 commit f7dc8a8

File tree

6 files changed

+24
-21
lines changed

6 files changed

+24
-21
lines changed

addons/ofxSvg/src/ofxSvg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,7 @@ glm::mat4 ofxSvg::setTransformFromSvgMatrixString( string aStr, std::shared_ptr<
20162016
// aele->pos.x = pos3.x;
20172017
// aele->pos.y = pos3.y;
20182018

2019-
ofLogNotice("ofxSvg::setTransformFromSvgMatrixString") << "pos: " << aele->getPosition() << " rotation: " << trotation << " scale: " << aele->getScale();
2019+
ofLogVerbose("ofxSvg::setTransformFromSvgMatrixString") << "pos: " << aele->getPosition() << " rotation: " << trotation << " scale: " << aele->getScale();
20202020

20212021
// apos.x = matrixF[4];
20222022
// apos.y = matrixF[5];

addons/ofxSvg/src/ofxSvgElements.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ void ofxSvgPath::applyStyle(ofxSvgCssClass& aclass) {
220220
}
221221

222222
//--------------------------------------------------------------
223-
void ofxSvgPath::draw() {
223+
void ofxSvgPath::customDraw() {
224224
// ofPushMatrix(); {
225-
transformGL(); {
225+
// transformGL(); {
226226
ofSetColor( ofColor::orange );
227227
// ofDrawCircle(0, 0, 15);
228228

@@ -255,7 +255,7 @@ void ofxSvgPath::draw() {
255255
}
256256
}
257257
}
258-
} restoreTransformGL();
258+
// } restoreTransformGL();
259259
// } ofPopMatrix();
260260
}
261261

@@ -276,22 +276,22 @@ void ofxSvgImage::load() {
276276
}
277277

278278
//--------------------------------------------------------------
279-
void ofxSvgImage::draw() {
279+
void ofxSvgImage::customDraw() {
280280
if( !bTryLoad ) {
281281
load();
282282
}
283283

284284
if( isVisible() ) {
285285
if( img.isAllocated() ) {
286286
// ofPushMatrix(); {
287-
transformGL(); {
287+
// transformGL(); {
288288
// ofTranslate( pos.x, pos.y );
289289
// if( rotation != 0.0 ) ofRotateZDeg( rotation );
290290
// ofScale( scale.x, scale.y );
291291
if(bUseShapeColor) ofSetColor( getColor() );
292292
img.draw( 0, 0 );
293293
// } ofPopMatrix();
294-
} restoreTransformGL();
294+
// } restoreTransformGL();
295295
}
296296
}
297297
}
@@ -738,7 +738,7 @@ void ofxSvgText::create() {
738738
}
739739

740740
//--------------------------------------------------------------
741-
void ofxSvgText::draw() {
741+
void ofxSvgText::customDraw() {
742742
if( !isVisible() ) return;
743743

744744
if(bUseShapeColor) {
@@ -751,7 +751,7 @@ void ofxSvgText::draw() {
751751
create();
752752
}
753753

754-
transformGL(); {
754+
// transformGL(); {
755755
ofTexture* tex = NULL;
756756
for( mainIt = meshes.begin(); mainIt != meshes.end(); ++mainIt ) {
757757
string fontKey = mainIt->first;
@@ -788,7 +788,7 @@ void ofxSvgText::draw() {
788788
tMeshMesh.enableColors();
789789
}
790790
}
791-
} restoreTransformGL();
791+
// } restoreTransformGL();
792792
}
793793

794794
//--------------------------------------------------------------

addons/ofxSvg/src/ofxSvgElements.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ofxSvgElement : public ofNode {
5555

5656
// override this in ofxSvgGroup
5757
virtual void setVisible( bool ab ) { bVisible = ab; }
58-
bool isVisible() { return bVisible; }
58+
bool isVisible() const { return bVisible; }
5959

6060
virtual void setAlpha( float aAlpha ) {
6161
alpha = aAlpha;
@@ -72,7 +72,8 @@ class ofxSvgElement : public ofNode {
7272
float layer = -1.f;
7373
bool bVisible=true;
7474

75-
virtual void draw() {}
75+
/// \brief Override the function in ofNode meant for drawing
76+
virtual void customDraw() override {};
7677

7778
virtual void applyStyle(ofxSvgCssClass& aclass) {};
7879

@@ -144,7 +145,7 @@ class ofxSvgPath : public ofxSvgElement {
144145

145146
virtual void applyStyle(ofxSvgCssClass& aclass) override;
146147

147-
virtual void draw() override;
148+
virtual void customDraw() override;
148149

149150
bool isFilled() { return path.isFilled(); }
150151
ofColor getFillColor() { return path.getFillColor(); }
@@ -269,7 +270,7 @@ class ofxSvgImage : public ofxSvgElement {
269270
return (img.isAllocated() && img.getWidth() > 0 && img.getHeight() > 0);
270271
}
271272

272-
virtual void draw() override;
273+
virtual void customDraw() override;
273274
// glm::vec2 getAnchorPointForPercent( float ax, float ay );
274275

275276
const std::filesystem::path& getFilePath() { return filepath; }
@@ -504,14 +505,14 @@ class ofxSvgText : public ofxSvgElement {
504505

505506
void setText( const std::string& astring, std::string aFontFamily, int aFontSize, float aMaxWidth );
506507
void create();
507-
void draw() override;
508+
void customDraw() override;
508509
void draw(const std::string &astring, bool abCentered );
509510
void draw(const std::string &astring, const ofColor& acolor, bool abCentered );
510511

511512
void setFontDirectory( std::string aPath ) {
512513
fdirectory = aPath;
513514
}
514-
of::filesystem::path getFontDirectory() {
515+
std::string getFontDirectory() {
515516
return fdirectory;
516517
}
517518

@@ -549,7 +550,7 @@ class ofxSvgText : public ofxSvgElement {
549550
bool bCentered = false;
550551

551552
protected:
552-
of::filesystem::path fdirectory;
553+
std::string fdirectory;
553554

554555
ofxSvgCssClass mSvgCssClass;
555556

addons/ofxSvg/src/ofxSvgFontBook.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bool ofxSvgFontBook::loadFont( const std::string& aDirectory, const std::string&
3434
bool bHasFontDirectory = false;
3535
// cout << "checking directory: " << fdirectory+"/fonts/" << endl;
3636
std::string fontsDirectory = "";// = ofToDataPath("", true);
37-
if( aDirectory != "" ) {
37+
if( !aDirectory.empty() ) {
3838
fontsDirectory = aDirectory;
3939
}
4040

addons/ofxSvg/src/ofxSvgGroup.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ using std::shared_ptr;
66
using std::string;
77

88
//--------------------------------------------------------------
9-
void ofxSvgGroup::draw() {
9+
void ofxSvgGroup::draw() const {
1010
if( !isVisible() ) return;
11+
1112
std::size_t numElements = mChildren.size();
1213
for( std::size_t i = 0; i < numElements; i++ ) {
1314
mChildren[i]->draw();

addons/ofxSvg/src/ofxSvgGroup.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ class ofxSvgGroup : public ofxSvgElement {
5858
return *this;
5959
}
6060

61-
62-
virtual void draw() override;
61+
// we need to override this so that we can draw the children correctly
62+
// without this transform getting applied to the children
63+
virtual void draw() const override;
6364

6465
/// \brief Set the visibility of the group. Does not set visibility of each child. The group only draws its children if the group is visible.
6566
/// \param bool aBVisible set to true for visible.

0 commit comments

Comments
 (0)