[TD]Standard Line Styles - App components

This commit is contained in:
wandererfan
2023-11-16 11:32:48 -05:00
committed by WandererFan
parent a4db18af56
commit 8a7e8effb3
11 changed files with 789 additions and 5 deletions

View File

@@ -54,6 +54,7 @@ LineFormat::LineFormat()
m_weight = getDefEdgeWidth();
m_color= getDefEdgeColor();
m_visible = true;
m_lineNumber = InvalidLine;
}
LineFormat::LineFormat(const int style,
@@ -63,7 +64,8 @@ LineFormat::LineFormat(const int style,
m_style(style),
m_weight(weight),
m_color(color),
m_visible(visible)
m_visible(visible),
m_lineNumber(InvalidLine)
{
}
@@ -96,7 +98,7 @@ App::Color LineFormat::getDefEdgeColor()
int LineFormat::getDefEdgeStyle()
{
return Preferences::getPreferenceGroup("Decorations")->GetInt("CosmoCLStyle", 2); //dashed
return Preferences::getPreferenceGroup("Decorations")->GetInt("CenterLineStyle", 2); //dashed
}
//******************************************
@@ -378,6 +380,7 @@ GeomFormat::GeomFormat() :
m_format.m_weight = LineFormat::getDefEdgeWidth();
m_format.m_color = LineFormat::getDefEdgeColor();
m_format.m_visible = true;
m_format.setLineNumber(LineFormat::InvalidLine);
createNewTag();
}
@@ -389,6 +392,7 @@ GeomFormat::GeomFormat(const GeomFormat* gf)
m_format.m_weight = gf->m_format.m_weight;
m_format.m_color = gf->m_format.m_color;
m_format.m_visible = gf->m_format.m_visible;
m_format.setLineNumber(gf->m_format.getLineNumber());
createNewTag();
}
@@ -401,6 +405,7 @@ GeomFormat::GeomFormat(const int idx,
m_format.m_weight = fmt.m_weight;
m_format.m_color = fmt.m_color;
m_format.m_visible = fmt.m_visible;
m_format.setLineNumber(fmt.getLineNumber());
createNewTag();
}
@@ -433,10 +438,13 @@ void GeomFormat::Save(Base::Writer &writer) const
{
const char v = m_format.m_visible?'1':'0';
writer.Stream() << writer.ind() << "<GeomIndex value=\"" << m_geomIndex << "\"/>" << endl;
// style is deprecated in favour of line number, but we still save and restore it
// to avoid problems with old documents.
writer.Stream() << writer.ind() << "<Style value=\"" << m_format.m_style << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Weight value=\"" << m_format.m_weight << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Color value=\"" << m_format.m_color.asHexString() << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Visible value=\"" << v << "\"/>" << endl;
writer.Stream() << writer.ind() << "<LineNumber value=\"" << m_format.getLineNumber() << "\"/>" << endl;
}
void GeomFormat::Restore(Base::XMLReader &reader)
@@ -449,6 +457,8 @@ void GeomFormat::Restore(Base::XMLReader &reader)
// get the value of my Attribute
m_geomIndex = reader.getAttributeAsInteger("value");
// style is deprecated in favour of line number, but we still save and restore it
// to avoid problems with old documents.
reader.readElement("Style");
m_format.m_style = reader.getAttributeAsInteger("value");
reader.readElement("Weight");
@@ -458,6 +468,22 @@ void GeomFormat::Restore(Base::XMLReader &reader)
m_format.m_color.fromHexString(temp);
reader.readElement("Visible");
m_format.m_visible = (int)reader.getAttributeAsInteger("value")==0?false:true;
// older documents may not have the LineNumber element, so we need to check the
// next entry. if it is a start element, then we check if it is a start element
// for LineNumber.
// test for ISOLineNumber can be removed after testing. It is a left over for the earlier
// ISO only line handling.
if (reader.readNextElement()) {
if(strcmp(reader.localName(),"LineNumber") == 0 ||
strcmp(reader.localName(),"ISOLineNumber") == 0 ) { // this GeomFormat has an LineNumber attribute
m_format.setLineNumber(reader.getAttributeAsInteger("value"));
} else {
// LineNumber not found.
// TODO: line number should be set to DashedLineGenerator.fromQtStyle(m_format.m_style),
// but DashedLineGenerator lives on the gui side, and is not accessible here.
m_format.setLineNumber(LineFormat::InvalidLine);
}
}
}
boost::uuids::uuid GeomFormat::getTag() const
@@ -508,6 +534,7 @@ GeomFormat* GeomFormat::copy() const
newFmt->m_format.m_weight = m_format.m_weight;
newFmt->m_format.m_color = m_format.m_color;
newFmt->m_format.m_visible = m_format.m_visible;
newFmt->m_format.setLineNumber(m_format.getLineNumber());
return newFmt;
}