Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix-some-bugs-add-some-features #82

Merged
merged 5 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.2
0.2.0
9 changes: 5 additions & 4 deletions src/autolayout/libsbmlnetwork_autolayout.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "libsbmlnetwork_autolayout.h"
#include "../libsbmlnetwork_layout_helpers.h"
#include "../libsbmlnetwork_common.h"
#include "libsbmlnetwork_fruchterman_reingold_algorithm.h"

#include <cstdlib>
Expand Down Expand Up @@ -235,24 +236,24 @@ void updateLayoutDimensions(Layout *layout) {
double maxX;
double maxY;
extractExtents(layout, minX, minY, maxX, maxY);
layout->getDimensions()->setWidth(maxX - minX + 2 * padding);
layout->getDimensions()->setHeight(maxY - minY + 2 * padding);
layout->getDimensions()->setWidth(roundToTwoDecimalPlaces(maxX - minX));
layout->getDimensions()->setHeight(roundToTwoDecimalPlaces(maxY - minY));
}
}

const bool adjustLayoutDimensions(Layout *layout) {
std::string width = LIBSBMLNETWORK_CPP_NAMESPACE::getUserData(layout->getDimensions(), "width");
if (!width.empty()) {
double presetWidth = std::stod(width);
if (std::abs(presetWidth - layout->getDimensions()->width()) < 4 * getDefaultAutoLayoutPadding())
if (std::abs(presetWidth - layout->getDimensions()->width()) < 2 * getDefaultAutoLayoutPadding())
layout->getDimensions()->setWidth(presetWidth);
else
return false;
}
std::string height = LIBSBMLNETWORK_CPP_NAMESPACE::getUserData(layout->getDimensions(), "height");
if (!height.empty()) {
double presetHeight = std::stod(height);
if (std::abs(presetHeight - layout->getDimensions()->height()) < 4 * getDefaultAutoLayoutPadding())
if (std::abs(presetHeight - layout->getDimensions()->height()) < 2 * getDefaultAutoLayoutPadding())
layout->getDimensions()->setHeight(presetHeight);
else
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/colors/libsbmlnetwork_colors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ namespace LIBSBMLNETWORK_CPP_NAMESPACE {
}

const bool isValidHexColorCode(const std::string& value) {
if (value.size() != 7 || value.at(0) != '#')
if ((value.size() != 7 && value.size() != 9) || value.at(0) != '#')
return false;

for (unsigned int i = 1; i < value.size(); i++) {
Expand Down
30 changes: 19 additions & 11 deletions src/libsbmlnetwork_layout_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1258,11 +1258,11 @@ const bool isValidRoleValue(const std::string& role) {
}

const bool isValidBoundingBoxXValue(const double& x) {
return true;
return isValidDoubleValue(x);
}

const bool isValidBoundingBoxYValue(const double& y) {
return true;
return isValidDoubleValue(y);
}

const bool isValidBoundingBoxWidthValue(const double& width) {
Expand All @@ -1274,45 +1274,53 @@ const bool isValidBoundingBoxHeightValue(const double& height) {
}

const bool isValidCurveSegmentStartPointXValue(const double& x) {
return true;
return isValidDoubleValue(x);
}

const bool isValidCurveSegmentStartPointYValue(const double& y) {
return true;
return isValidDoubleValue(y);
}

const bool isValidCurveSegmentEndPointXValue(const double& x) {
return true;
return isValidDoubleValue(x);
}

const bool isValidCurveSegmentEndPointYValue(const double& y) {
return true;
return isValidDoubleValue(y);
}

const bool isValidCurveSegmentBasePoint1XValue(const double& x) {
return true;
return isValidDoubleValue(x);
}

const bool isValidCurveSegmentBasePoint1YValue(const double& y) {
return true;
return isValidDoubleValue(y);
}

const bool isValidCurveSegmentBasePoint2XValue(const double& x) {
return true;
return isValidDoubleValue(x);
}

const bool isValidCurveSegmentBasePoint2YValue(const double& y) {
return true;
return isValidDoubleValue(y);
}

const bool isValidDimensionValue(const double& dimensionValue) {
if (dimensionValue > 0.000)
if (isValidDoubleValue(dimensionValue) && dimensionValue > 0.000)
return true;

std::cerr << "error: A dimension value must be greater than 0" << std::endl;
return false;
}

const bool isValidDoubleValue(const double& doubleValue) {
if (!std::isnan(doubleValue) && !std::isinf(doubleValue))
return true;

std::cerr << "error: A double value must be a valid number" << std::endl;
return false;
}

const bool isValidAlignment(const std::string& alignment) {
return isValueValid(alignment, getValidAlignmentValues());
}
Expand Down
2 changes: 2 additions & 0 deletions src/libsbmlnetwork_layout_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ const bool isValidCurveSegmentBasePoint2YValue(const double& y);

const bool isValidDimensionValue(const double& dimensionValue);

const bool isValidDoubleValue(const double& doubleValue);

const bool isValidAlignment(const std::string& alignment);

const bool isValidDistributionDirection(const std::string& direction);
Expand Down
Loading
Loading