Skip to content

Commit

Permalink
Fix the issue with setting the color values as hex color codes
Browse files Browse the repository at this point in the history
  • Loading branch information
adelhpour committed Oct 30, 2024
1 parent 2d65299 commit 90d7b43
Show file tree
Hide file tree
Showing 6 changed files with 374 additions and 371 deletions.
47 changes: 20 additions & 27 deletions src/libsbmlnetwork_layout_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,58 +70,55 @@ int setDefaultLocalRenderInformationFeatures(SBMLDocument* document, Layout* lay
return -1;
}

int setCompartmentStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& stroke) {
int setCompartmentStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& strokeColorId, const std::string& strokeColorValue) {
if (layout == NULL || localRenderInformation == NULL)
return -1;

Style* style = NULL;
for (unsigned int i = 0; i < layout->getNumCompartmentGlyphs(); i++) {
style = getStyleById(localRenderInformation, layout->getCompartmentGlyph(i));
if (style) {
addColor(localRenderInformation, stroke);
if (setStrokeColor(style, stroke))
if (setStrokeColor(style, strokeColorId, strokeColorValue))
return -1;
}
}

return 0;
}

int setSpeciesStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& stroke) {
int setSpeciesStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& strokeColorId, const std::string& strokeColorValue) {
if (layout == NULL || localRenderInformation == NULL)
return -1;

Style *style = NULL;
for (unsigned int i = 0; i < layout->getNumSpeciesGlyphs(); i++) {
style = getStyleById(localRenderInformation, layout->getSpeciesGlyph(i));
if (style) {
addColor(localRenderInformation, stroke);
if (setStrokeColor(style, stroke))
if (setStrokeColor(style, strokeColorId, strokeColorValue))
return -1;
}
}

return 0;
}

int setReactionStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& stroke) {
int setReactionStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& strokeColorId, const std::string& strokeColorValue) {
if (layout == NULL || localRenderInformation == NULL)
return -1;

Style *style = NULL;
for (unsigned int i = 0; i < layout->getNumReactionGlyphs(); i++) {
style = getStyleById(localRenderInformation, layout->getReactionGlyph(i));
if (style) {
addColor(localRenderInformation, stroke);
if (setStrokeColor(style, stroke))
if (setStrokeColor(style, strokeColorId, strokeColorValue))
return -1;
}
}

return 0;
}

int setSpeciesReferenceStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& stroke) {
int setSpeciesReferenceStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& strokeColorId, const std::string& strokeColorValue) {
if (layout == NULL || localRenderInformation == NULL)
return -1;

Expand All @@ -130,8 +127,7 @@ int setSpeciesReferenceStrokeColor(Layout* layout, LocalRenderInformation* local
for (unsigned int j = 0; j < layout->getReactionGlyph(i)->getNumSpeciesReferenceGlyphs(); j++) {
style = getStyleById(localRenderInformation, layout->getReactionGlyph(i)->getSpeciesReferenceGlyph(j));
if (style) {
addColor(localRenderInformation, stroke);
if (setStrokeColor(style, stroke))
if (setStrokeColor(style, strokeColorId, strokeColorValue))
return -1;
}
}
Expand Down Expand Up @@ -206,7 +202,7 @@ int setSpeciesReferenceStrokeWidth(Layout* layout, LocalRenderInformation* local
return 0;
}

int setCompartmentFontColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fontColor) {
int setCompartmentFontColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fontColorId, const std::string& fontColorValue) {
if (layout == NULL || localRenderInformation == NULL)
return -1;

Expand All @@ -216,7 +212,7 @@ int setCompartmentFontColor(Layout* layout, LocalRenderInformation* localRenderI
for (unsigned int j = 0; j < textGlyphs.size(); j++) {
style = getStyleById(localRenderInformation, textGlyphs.at(j));
if (style) {
if (setFontColor(style, fontColor))
if (setFontColor(style, fontColorId, fontColorValue))
return -1;
}
}
Expand All @@ -225,7 +221,7 @@ int setCompartmentFontColor(Layout* layout, LocalRenderInformation* localRenderI
return 0;
}

int setSpeciesFontColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fontColor) {
int setSpeciesFontColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fontColorId, const std::string& fontColorValue) {
if (layout == NULL || localRenderInformation == NULL)
return -1;

Expand All @@ -235,7 +231,7 @@ int setSpeciesFontColor(Layout* layout, LocalRenderInformation* localRenderInfor
for (unsigned int j = 0; j < textGlyphs.size(); j++) {
style = getStyleById(localRenderInformation, textGlyphs.at(j));
if (style) {
if (setFontColor(style, fontColor))
if (setFontColor(style, fontColorId, fontColorValue))
return -1;
}
}
Expand All @@ -244,7 +240,7 @@ int setSpeciesFontColor(Layout* layout, LocalRenderInformation* localRenderInfor
return 0;
}

int setReactionFontColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fontColor) {
int setReactionFontColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fontColorId, const std::string& fontColorValue) {
if (layout == NULL || localRenderInformation == NULL)
return -1;

Expand All @@ -254,7 +250,7 @@ int setReactionFontColor(Layout* layout, LocalRenderInformation* localRenderInfo
for (unsigned int j = 0; j < textGlyphs.size(); j++) {
style = getStyleById(localRenderInformation, textGlyphs.at(j));
if (style) {
if (setFontColor(style, fontColor))
if (setFontColor(style, fontColorId, fontColorValue))
return -1;
}
}
Expand Down Expand Up @@ -632,16 +628,15 @@ int setReactionVTextAnchor(Layout* layout, LocalRenderInformation* localRenderIn
return 0;
}

int setCompartmentFillColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fillColor) {
int setCompartmentFillColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fillColorId, const std::string& fillColorValue) {
if (layout == NULL || localRenderInformation == NULL)
return -1;

Style *style = NULL;
for (unsigned int i = 0; i < layout->getNumCompartmentGlyphs(); i++) {
style = getStyleById(localRenderInformation, layout->getCompartmentGlyph(i));
if (style) {
addColor(localRenderInformation, fillColor);
if (setFillColor(style, fillColor))
if (setFillColor(style, fillColorId, fillColorValue))
return -1;
}
}
Expand All @@ -665,16 +660,15 @@ int setCompartmentFillColorAsGradient(Layout* layout, LocalRenderInformation* lo
return 0;
}

int setSpeciesFillColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fillColor) {
int setSpeciesFillColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fillColorId, const std::string& fillColorValue) {
if (layout == NULL || localRenderInformation == NULL)
return -1;

Style *style = NULL;
for (unsigned int i = 0; i < layout->getNumSpeciesGlyphs(); i++) {
style = getStyleById(localRenderInformation, layout->getSpeciesGlyph(i));
if (style) {
addColor(localRenderInformation, fillColor);
if (setFillColor(style, fillColor))
if (setFillColor(style, fillColorId, fillColorValue))
return -1;
}
}
Expand All @@ -698,16 +692,15 @@ int setSpeciesFillColorAsGradient(Layout* layout, LocalRenderInformation* localR
return 0;
}

int setReactionFillColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fillColor) {
int setReactionFillColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fillColorId, const std::string& fillColorValue) {
if (layout == NULL || localRenderInformation == NULL)
return -1;

Style *style = NULL;
for (unsigned int i = 0; i < layout->getNumReactionGlyphs(); i++) {
style = getStyleById(localRenderInformation, layout->getReactionGlyph(i));
if (style) {
addColor(localRenderInformation, fillColor);
if (setFillColor(style, fillColor))
if (setFillColor(style, fillColorId, fillColorValue))
return -1;
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/libsbmlnetwork_layout_render.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ LIBSBMLNETWORK_EXTERN int removeAllLocalRenderInformation(Layout* layout);
/// @return integer value indicating success/failure of the function.
LIBSBMLNETWORK_EXTERN int setDefaultLocalRenderInformationFeatures(SBMLDocument* document, Layout* layout, LocalRenderInformation* localRenderInformation);

LIBSBMLNETWORK_EXTERN int setCompartmentStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& stroke);
LIBSBMLNETWORK_EXTERN int setCompartmentStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& strokeColorId, const std::string& strokeColorValue);

LIBSBMLNETWORK_EXTERN int setSpeciesStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& stroke);
LIBSBMLNETWORK_EXTERN int setSpeciesStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& strokeColorId, const std::string& strokeColorValue);

LIBSBMLNETWORK_EXTERN int setReactionStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& stroke);
LIBSBMLNETWORK_EXTERN int setReactionStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& strokeColorId, const std::string& strokeColorValue);

LIBSBMLNETWORK_EXTERN int setSpeciesReferenceStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& stroke);
LIBSBMLNETWORK_EXTERN int setSpeciesReferenceStrokeColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& strokeColorId, const std::string& strokeColorValue);

LIBSBMLNETWORK_EXTERN int setCompartmentStrokeWidth(Layout* layout, LocalRenderInformation* localRenderInformation, const double& width);

Expand All @@ -68,11 +68,11 @@ LIBSBMLNETWORK_EXTERN int setReactionStrokeWidth(Layout* layout, LocalRenderInfo

LIBSBMLNETWORK_EXTERN int setSpeciesReferenceStrokeWidth(Layout* layout, LocalRenderInformation* localRenderInformation, const double& width);

LIBSBMLNETWORK_EXTERN int setCompartmentFontColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fontColor);
LIBSBMLNETWORK_EXTERN int setCompartmentFontColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fontColorId, const std::string& fontColorValue);

LIBSBMLNETWORK_EXTERN int setSpeciesFontColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fontColor);
LIBSBMLNETWORK_EXTERN int setSpeciesFontColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fontColorId, const std::string& fontColorValue);

LIBSBMLNETWORK_EXTERN int setReactionFontColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fontColor);
LIBSBMLNETWORK_EXTERN int setReactionFontColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fontColorId, const std::string& fontColorValue);

LIBSBMLNETWORK_EXTERN int setCompartmentFontFamily(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fontFamily);

Expand Down Expand Up @@ -116,15 +116,15 @@ LIBSBMLNETWORK_EXTERN int setSpeciesVTextAnchor(Layout* layout, LocalRenderInfor

LIBSBMLNETWORK_EXTERN int setReactionVTextAnchor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& vTextAnchor);

LIBSBMLNETWORK_EXTERN int setCompartmentFillColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fillColor);
LIBSBMLNETWORK_EXTERN int setCompartmentFillColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fillColorId, const std::string& fillColorValue);

LIBSBMLNETWORK_EXTERN int setCompartmentFillColorAsGradient(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& gradientId);

LIBSBMLNETWORK_EXTERN int setSpeciesFillColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fillColor);
LIBSBMLNETWORK_EXTERN int setSpeciesFillColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fillColor, const std::string& fillColorValue);

LIBSBMLNETWORK_EXTERN int setSpeciesFillColorAsGradient(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& gradientId);

LIBSBMLNETWORK_EXTERN int setReactionFillColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fillColor);
LIBSBMLNETWORK_EXTERN int setReactionFillColor(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& fillColor, const std::string& fillColorValue);

LIBSBMLNETWORK_EXTERN int setReactionFillColorAsGradient(Layout* layout, LocalRenderInformation* localRenderInformation, const std::string& gradientId);

Expand Down
Loading

0 comments on commit 90d7b43

Please sign in to comment.