优化了bad smells

LayerStyleContainer::boundingBoxAffectedValue()
dev-LayerStyle
ArgonarioD 2023-03-19 01:20:32 +08:00
parent 1378997f64
commit 47ada04c3a
2 changed files with 15 additions and 10 deletions

View File

@ -194,18 +194,23 @@ bool LayerStyleContainer::dropStyle(const QString& styleName)
return true;
}
float LayerStyleContainer::boundingBoxAffectValue() {
float LayerStyleContainer::boundingBoxAffectValue() const {
float maxLineWidth = 0;
auto strokeStyle = styles[StrokeElementLayerStyle::displayName()];
if (strokeStyle != nullptr) {
auto strokeElementLayerStyle = dynamic_cast<StrokeElementLayerStyle*>(strokeStyle.get());
if (strokeElementLayerStyle != nullptr) {
auto leftStyleStroke = strokeElementLayerStyle->strokePair.first;
auto rightStyleStroke = strokeElementLayerStyle->strokePair.second;
if (leftStyleStroke != nullptr) {
const auto strokeStyle = styles.at(StrokeElementLayerStyle::displayName());
if (strokeStyle != nullptr)
{
if (const auto strokeElementLayerStyle =
std::dynamic_pointer_cast<StrokeElementLayerStyle>(strokeStyle);
strokeElementLayerStyle != nullptr)
{
const auto& leftStyleStroke = strokeElementLayerStyle->strokePair.first;
const auto& rightStyleStroke = strokeElementLayerStyle->strokePair.second;
if (leftStyleStroke != nullptr)
{
maxLineWidth = std::max(maxLineWidth, leftStyleStroke->halfWidth);
}
if (rightStyleStroke != nullptr) {
if (rightStyleStroke != nullptr)
{
maxLineWidth = std::max(maxLineWidth, rightStyleStroke->halfWidth);
}
}

View File

@ -65,7 +65,7 @@ public:
std::unique_ptr<LayerStyle> makeUnusedStyle(const QString& styleName) const;
bool useStyle(const std::shared_ptr<LayerStyle>& style);
bool dropStyle(const QString& styleName);
float boundingBoxAffectValue();
float boundingBoxAffectValue() const;
size_t getHash() const;
/**