Base: Move App::Color to Base
Every basic data type is stored in Base module, color is standing out as one that does not. Moving it to Base opens possibilities to integrate it better with the rest of FreeCAD.
This commit is contained in:
@@ -109,7 +109,7 @@ bool ReaderOBJ::Load(std::istream& str)
|
||||
float b = std::min<int>(std::atof(what[12].first), 255) / 255.0F;
|
||||
meshPoints.push_back(MeshPoint(Base::Vector3f(fX, fY, fZ)));
|
||||
|
||||
App::Color c(r, g, b);
|
||||
Base::Color c(r, g, b);
|
||||
unsigned long prop = static_cast<uint32_t>(c.getPackedValue());
|
||||
meshPoints.back().SetProperty(prop);
|
||||
rgb_value = MeshIO::PER_VERTEX;
|
||||
@@ -123,7 +123,7 @@ bool ReaderOBJ::Load(std::istream& str)
|
||||
float b = static_cast<float>(std::atof(what[16].first));
|
||||
meshPoints.push_back(MeshPoint(Base::Vector3f(fX, fY, fZ)));
|
||||
|
||||
App::Color c(r, g, b);
|
||||
Base::Color c(r, g, b);
|
||||
unsigned long prop = static_cast<uint32_t>(c.getPackedValue());
|
||||
meshPoints.back().SetProperty(prop);
|
||||
rgb_value = MeshIO::PER_VERTEX;
|
||||
@@ -213,7 +213,7 @@ bool ReaderOBJ::Load(std::istream& str)
|
||||
|
||||
for (const auto& it : meshPoints) {
|
||||
unsigned long prop = it._ulProp;
|
||||
App::Color c;
|
||||
Base::Color c;
|
||||
c.setPackedValue(static_cast<uint32_t>(prop));
|
||||
_material->diffuseColor.push_back(c);
|
||||
}
|
||||
@@ -224,7 +224,7 @@ bool ReaderOBJ::Load(std::istream& str)
|
||||
// calling instance but the color list is pre-filled with a default value
|
||||
if (_material) {
|
||||
_material->binding = MeshIO::PER_FACE;
|
||||
_material->diffuseColor.resize(meshFacets.size(), App::Color(0.8F, 0.8F, 0.8F));
|
||||
_material->diffuseColor.resize(meshFacets.size(), Base::Color(0.8F, 0.8F, 0.8F));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,27 +259,27 @@ bool ReaderOBJ::LoadMaterial(std::istream& str)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::map<std::string, App::Color> materialAmbientColor;
|
||||
std::map<std::string, App::Color> materialDiffuseColor;
|
||||
std::map<std::string, App::Color> materialSpecularColor;
|
||||
std::map<std::string, Base::Color> materialAmbientColor;
|
||||
std::map<std::string, Base::Color> materialDiffuseColor;
|
||||
std::map<std::string, Base::Color> materialSpecularColor;
|
||||
std::map<std::string, float> materialTransparency;
|
||||
std::string materialName;
|
||||
std::vector<App::Color> ambientColor;
|
||||
std::vector<App::Color> diffuseColor;
|
||||
std::vector<App::Color> specularColor;
|
||||
std::vector<Base::Color> ambientColor;
|
||||
std::vector<Base::Color> diffuseColor;
|
||||
std::vector<Base::Color> specularColor;
|
||||
std::vector<float> transparency;
|
||||
|
||||
auto readColor = [](const std::vector<std::string>& tokens) -> App::Color {
|
||||
auto readColor = [](const std::vector<std::string>& tokens) -> Base::Color {
|
||||
if (tokens.size() == 2) {
|
||||
// If only R is given then G and B will be equal
|
||||
float r = boost::lexical_cast<float>(tokens[1]);
|
||||
return App::Color(r, r, r);
|
||||
return Base::Color(r, r, r);
|
||||
}
|
||||
if (tokens.size() == 4) {
|
||||
float r = boost::lexical_cast<float>(tokens[1]);
|
||||
float g = boost::lexical_cast<float>(tokens[2]);
|
||||
float b = boost::lexical_cast<float>(tokens[3]);
|
||||
return App::Color(r, g, b);
|
||||
return Base::Color(r, g, b);
|
||||
}
|
||||
|
||||
throw std::length_error("Unexpected number of tokens");
|
||||
@@ -322,21 +322,21 @@ bool ReaderOBJ::LoadMaterial(std::istream& str)
|
||||
{
|
||||
auto jt = materialAmbientColor.find(it.first);
|
||||
if (jt != materialAmbientColor.end()) {
|
||||
std::vector<App::Color> mat(it.second, jt->second);
|
||||
std::vector<Base::Color> mat(it.second, jt->second);
|
||||
ambientColor.insert(ambientColor.end(), mat.begin(), mat.end());
|
||||
}
|
||||
}
|
||||
{
|
||||
auto jt = materialDiffuseColor.find(it.first);
|
||||
if (jt != materialDiffuseColor.end()) {
|
||||
std::vector<App::Color> mat(it.second, jt->second);
|
||||
std::vector<Base::Color> mat(it.second, jt->second);
|
||||
diffuseColor.insert(diffuseColor.end(), mat.begin(), mat.end());
|
||||
}
|
||||
}
|
||||
{
|
||||
auto jt = materialSpecularColor.find(it.first);
|
||||
if (jt != materialSpecularColor.end()) {
|
||||
std::vector<App::Color> mat(it.second, jt->second);
|
||||
std::vector<Base::Color> mat(it.second, jt->second);
|
||||
specularColor.insert(specularColor.end(), mat.begin(), mat.end());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,13 +122,13 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
auto transformColors = [](const std::vector<App::Color>& input) {
|
||||
auto transformColors = [](const std::vector<Base::Color>& input) {
|
||||
std::vector<Base::ColorRGB> output;
|
||||
output.reserve(input.size());
|
||||
std::transform(input.cbegin(),
|
||||
input.cend(),
|
||||
std::back_inserter(output),
|
||||
[](const App::Color& col) {
|
||||
[](const Base::Color& col) {
|
||||
return Base::ColorRGB {col.r, col.g, col.b};
|
||||
});
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ using namespace MeshCore;
|
||||
|
||||
struct WriterOBJ::Color_Less
|
||||
{
|
||||
bool operator()(const App::Color& x, const App::Color& y) const
|
||||
bool operator()(const Base::Color& x, const Base::Color& y) const
|
||||
{
|
||||
if (x.r != y.r) {
|
||||
return x.r < y.r;
|
||||
@@ -131,7 +131,7 @@ bool WriterOBJ::Save(std::ostream& out)
|
||||
}
|
||||
|
||||
if (exportColorPerVertex) {
|
||||
App::Color c;
|
||||
Base::Color c;
|
||||
if (_material->binding == MeshIO::PER_VERTEX) {
|
||||
c = _material->diffuseColor[index];
|
||||
}
|
||||
@@ -171,14 +171,14 @@ bool WriterOBJ::Save(std::ostream& out)
|
||||
// facet indices (no texture and normal indices)
|
||||
|
||||
// make sure to use the 'usemtl' statement as less often as possible
|
||||
std::vector<App::Color> colors = _material->diffuseColor;
|
||||
std::vector<Base::Color> colors = _material->diffuseColor;
|
||||
std::sort(colors.begin(), colors.end(), Color_Less());
|
||||
colors.erase(std::unique(colors.begin(), colors.end()), colors.end());
|
||||
|
||||
std::size_t index = 0;
|
||||
App::Color prev;
|
||||
Base::Color prev;
|
||||
int faceIdx = 1;
|
||||
const std::vector<App::Color>& Kd = _material->diffuseColor;
|
||||
const std::vector<Base::Color>& Kd = _material->diffuseColor;
|
||||
for (auto it = rFacets.begin(); it != rFacets.end(); ++it, index++) {
|
||||
if (index == 0 || prev != Kd[index]) {
|
||||
prev = Kd[index];
|
||||
@@ -209,13 +209,13 @@ bool WriterOBJ::Save(std::ostream& out)
|
||||
else {
|
||||
if (exportColorPerFace) {
|
||||
// make sure to use the 'usemtl' statement as less often as possible
|
||||
std::vector<App::Color> colors = _material->diffuseColor;
|
||||
std::vector<Base::Color> colors = _material->diffuseColor;
|
||||
std::sort(colors.begin(), colors.end(), Color_Less());
|
||||
colors.erase(std::unique(colors.begin(), colors.end()), colors.end());
|
||||
|
||||
bool first = true;
|
||||
App::Color prev;
|
||||
const std::vector<App::Color>& Kd = _material->diffuseColor;
|
||||
Base::Color prev;
|
||||
const std::vector<Base::Color>& Kd = _material->diffuseColor;
|
||||
|
||||
for (const auto& gt : _groups) {
|
||||
out << "g " << Base::Tools::escapedUnicodeFromUtf8(gt.name.c_str()) << '\n';
|
||||
@@ -263,7 +263,7 @@ bool WriterOBJ::SaveMaterial(std::ostream& out)
|
||||
if (_material) {
|
||||
if (_material->binding == MeshIO::PER_FACE) {
|
||||
|
||||
std::vector<App::Color> Kd = _material->diffuseColor;
|
||||
std::vector<Base::Color> Kd = _material->diffuseColor;
|
||||
std::sort(Kd.begin(), Kd.end(), Color_Less());
|
||||
Kd.erase(std::unique(Kd.begin(), Kd.end()), Kd.end());
|
||||
|
||||
|
||||
@@ -481,7 +481,7 @@ bool MeshInput::LoadOFF(std::istream& input)
|
||||
boost::cmatch what;
|
||||
|
||||
bool colorPerVertex = false;
|
||||
std::vector<App::Color> diffuseColor;
|
||||
std::vector<Base::Color> diffuseColor;
|
||||
MeshPointArray meshPoints;
|
||||
MeshFacetArray meshFacets;
|
||||
|
||||
@@ -1808,7 +1808,7 @@ bool MeshOutput::SaveAsymptote(std::ostream& out) const
|
||||
bool saveFaceColor = (_material && _material->binding == MeshIO::PER_FACE
|
||||
&& _material->diffuseColor.size() == rFacets.size());
|
||||
// global mesh color
|
||||
App::Color mc(0.8F, 0.8F, 0.8F);
|
||||
Base::Color mc(0.8F, 0.8F, 0.8F);
|
||||
if (_material && _material->binding == MeshIO::OVERALL && _material->diffuseColor.size() == 1) {
|
||||
mc = _material->diffuseColor[0];
|
||||
}
|
||||
@@ -1831,7 +1831,7 @@ bool MeshOutput::SaveAsymptote(std::ostream& out) const
|
||||
const MeshFacet& face = rFacets[index];
|
||||
out << ",\n new pen[] {";
|
||||
for (int i = 0; i < 3; i++) {
|
||||
const App::Color& c = _material->diffuseColor[face._aulPoints[i]];
|
||||
const Base::Color& c = _material->diffuseColor[face._aulPoints[i]];
|
||||
out << "rgb(" << c.r << ", " << c.g << ", " << c.b << ")";
|
||||
if (i < 2) {
|
||||
out << ", ";
|
||||
@@ -1840,7 +1840,7 @@ bool MeshOutput::SaveAsymptote(std::ostream& out) const
|
||||
out << "}));\n";
|
||||
}
|
||||
else if (saveFaceColor) {
|
||||
const App::Color& c = _material->diffuseColor[index];
|
||||
const Base::Color& c = _material->diffuseColor[index];
|
||||
out << "),\n rgb(" << c.r << ", " << c.g << ", " << c.b << "));\n";
|
||||
}
|
||||
else {
|
||||
@@ -1912,7 +1912,7 @@ bool MeshOutput::SaveOFF(std::ostream& out) const
|
||||
}
|
||||
|
||||
if (exportColor) {
|
||||
App::Color c;
|
||||
Base::Color c;
|
||||
if (_material->binding == MeshIO::PER_VERTEX) {
|
||||
c = _material->diffuseColor[index];
|
||||
}
|
||||
@@ -1984,7 +1984,7 @@ bool MeshOutput::SaveBinaryPLY(std::ostream& out) const
|
||||
os << p.x << p.y << p.z;
|
||||
}
|
||||
if (saveVertexColor) {
|
||||
const App::Color& c = _material->diffuseColor[i];
|
||||
const Base::Color& c = _material->diffuseColor[i];
|
||||
uint8_t r = uint8_t(255.0F * c.r);
|
||||
uint8_t g = uint8_t(255.0F * c.g);
|
||||
uint8_t b = uint8_t(255.0F * c.b);
|
||||
@@ -2046,7 +2046,7 @@ bool MeshOutput::SaveAsciiPLY(std::ostream& out) const
|
||||
out << p.x << " " << p.y << " " << p.z;
|
||||
}
|
||||
|
||||
const App::Color& c = _material->diffuseColor[i];
|
||||
const Base::Color& c = _material->diffuseColor[i];
|
||||
int r = (int)(255.0F * c.r);
|
||||
int g = (int)(255.0F * c.g);
|
||||
int b = (int)(255.0F * c.b);
|
||||
@@ -2359,7 +2359,7 @@ bool MeshOutput::SaveX3DContent(std::ostream& out, bool exportViewpoints) const
|
||||
bbox = bbox.Transformed(_transform);
|
||||
}
|
||||
|
||||
App::Color mat(0.65F, 0.65F, 0.65F);
|
||||
Base::Color mat(0.65F, 0.65F, 0.65F);
|
||||
if (_material && _material->binding == MeshIO::Binding::OVERALL) {
|
||||
if (!_material->diffuseColor.empty()) {
|
||||
mat = _material->diffuseColor.front();
|
||||
@@ -2679,7 +2679,7 @@ bool MeshOutput::SaveVRML(std::ostream& output) const
|
||||
<< " Material {\n";
|
||||
if (_material && _material->binding == MeshIO::OVERALL) {
|
||||
if (!_material->diffuseColor.empty()) {
|
||||
App::Color c = _material->diffuseColor.front();
|
||||
Base::Color c = _material->diffuseColor.front();
|
||||
output << " diffuseColor " << c.r << " " << c.g << " " << c.b << "\n";
|
||||
}
|
||||
else {
|
||||
@@ -2828,7 +2828,7 @@ void MeshCleanup::RemoveInvalidFacets()
|
||||
// adjust the material array if needed
|
||||
if (materialArray && materialArray->binding == MeshIO::PER_FACE
|
||||
&& materialArray->diffuseColor.size() == facetArray.size()) {
|
||||
std::vector<App::Color> colors;
|
||||
std::vector<Base::Color> colors;
|
||||
colors.reserve(facetArray.size() - countInvalidFacets);
|
||||
for (std::size_t index = 0; index < facetArray.size(); index++) {
|
||||
if (facetArray[index].IsValid()) {
|
||||
@@ -2887,7 +2887,7 @@ void MeshCleanup::RemoveInvalidPoints()
|
||||
// adjust the material array if needed
|
||||
if (materialArray && materialArray->binding == MeshIO::PER_VERTEX
|
||||
&& materialArray->diffuseColor.size() == pointArray.size()) {
|
||||
std::vector<App::Color> colors;
|
||||
std::vector<Base::Color> colors;
|
||||
colors.reserve(validPoints);
|
||||
for (std::size_t index = 0; index < pointArray.size(); index++) {
|
||||
if (pointArray[index].IsValid()) {
|
||||
|
||||
@@ -82,10 +82,10 @@ struct MeshExport Material
|
||||
MeshIO::Binding binding {MeshIO::OVERALL};
|
||||
mutable std::string library;
|
||||
|
||||
std::vector<App::Color> ambientColor; /**< Defines the ambient color. */
|
||||
std::vector<App::Color> diffuseColor; /**< Defines the diffuse color. */
|
||||
std::vector<App::Color> specularColor; /**< Defines the specular color. */
|
||||
std::vector<App::Color> emissiveColor; /**< Defines the emissive color. */
|
||||
std::vector<Base::Color> ambientColor; /**< Defines the ambient color. */
|
||||
std::vector<Base::Color> diffuseColor; /**< Defines the diffuse color. */
|
||||
std::vector<Base::Color> specularColor; /**< Defines the specular color. */
|
||||
std::vector<Base::Color> emissiveColor; /**< Defines the emissive color. */
|
||||
std::vector<float> shininess;
|
||||
std::vector<float> transparency;
|
||||
|
||||
|
||||
@@ -65,19 +65,19 @@ void Importer::load(const std::string& fileName)
|
||||
}
|
||||
}
|
||||
|
||||
void Importer::addVertexColors(Feature* feature, const std::vector<App::Color>& colors)
|
||||
void Importer::addVertexColors(Feature* feature, const std::vector<Base::Color>& colors)
|
||||
{
|
||||
addColors(feature, "VertexColors", colors);
|
||||
}
|
||||
|
||||
void Importer::addFaceColors(Feature* feature, const std::vector<App::Color>& colors)
|
||||
void Importer::addFaceColors(Feature* feature, const std::vector<Base::Color>& colors)
|
||||
{
|
||||
addColors(feature, "FaceColors", colors);
|
||||
}
|
||||
|
||||
void Importer::addColors(Feature* feature,
|
||||
const std::string& property,
|
||||
const std::vector<App::Color>& colors)
|
||||
const std::vector<Base::Color>& colors)
|
||||
{
|
||||
App::PropertyColorList* prop = static_cast<App::PropertyColorList*>(
|
||||
feature->addDynamicProperty("App::PropertyColorList", property.c_str()));
|
||||
@@ -105,7 +105,7 @@ void Importer::createMeshFromSegments(const std::string& name,
|
||||
if (mat.binding == MeshCore::MeshIO::PER_FACE
|
||||
&& mat.diffuseColor.size() == mesh.countFacets()) {
|
||||
|
||||
std::vector<App::Color> diffuseColor;
|
||||
std::vector<Base::Color> diffuseColor;
|
||||
diffuseColor.reserve(group.getIndices().size());
|
||||
for (const auto& it : group.getIndices()) {
|
||||
diffuseColor.push_back(mat.diffuseColor[it]);
|
||||
|
||||
@@ -48,9 +48,9 @@ public:
|
||||
void load(const std::string& fileName);
|
||||
|
||||
private:
|
||||
void addVertexColors(Feature*, const std::vector<App::Color>&);
|
||||
void addFaceColors(Feature*, const std::vector<App::Color>&);
|
||||
void addColors(Feature*, const std::string& property, const std::vector<App::Color>&);
|
||||
void addVertexColors(Feature*, const std::vector<Base::Color>&);
|
||||
void addFaceColors(Feature*, const std::vector<Base::Color>&);
|
||||
void addColors(Feature*, const std::string& property, const std::vector<Base::Color>&);
|
||||
Feature* createMesh(const std::string& name, MeshObject&);
|
||||
void createMeshFromSegments(const std::string& name, MeshCore::Material& mat, MeshObject& mesh);
|
||||
|
||||
|
||||
@@ -415,22 +415,22 @@ MeshCore::MeshIO::Binding PropertyMaterial::getBinding() const
|
||||
return _material.binding;
|
||||
}
|
||||
|
||||
const std::vector<App::Color>& PropertyMaterial::getAmbientColor() const
|
||||
const std::vector<Base::Color>& PropertyMaterial::getAmbientColor() const
|
||||
{
|
||||
return _material.ambientColor;
|
||||
}
|
||||
|
||||
const std::vector<App::Color>& PropertyMaterial::getDiffuseColor() const
|
||||
const std::vector<Base::Color>& PropertyMaterial::getDiffuseColor() const
|
||||
{
|
||||
return _material.diffuseColor;
|
||||
}
|
||||
|
||||
const std::vector<App::Color>& PropertyMaterial::getSpecularColor() const
|
||||
const std::vector<Base::Color>& PropertyMaterial::getSpecularColor() const
|
||||
{
|
||||
return _material.specularColor;
|
||||
}
|
||||
|
||||
const std::vector<App::Color>& PropertyMaterial::getEmissiveColor() const
|
||||
const std::vector<Base::Color>& PropertyMaterial::getEmissiveColor() const
|
||||
{
|
||||
return _material.emissiveColor;
|
||||
}
|
||||
@@ -452,28 +452,28 @@ void PropertyMaterial::setValue(const MeshCore::Material& value)
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterial::setAmbientColor(const std::vector<App::Color>& value)
|
||||
void PropertyMaterial::setAmbientColor(const std::vector<Base::Color>& value)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_material.ambientColor = value;
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterial::setDiffuseColor(const std::vector<App::Color>& value)
|
||||
void PropertyMaterial::setDiffuseColor(const std::vector<Base::Color>& value)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_material.diffuseColor = value;
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterial::setSpecularColor(const std::vector<App::Color>& value)
|
||||
void PropertyMaterial::setSpecularColor(const std::vector<Base::Color>& value)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_material.specularColor = value;
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyMaterial::setEmissiveColor(const std::vector<App::Color>& value)
|
||||
void PropertyMaterial::setEmissiveColor(const std::vector<Base::Color>& value)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_material.emissiveColor = value;
|
||||
@@ -503,7 +503,7 @@ void PropertyMaterial::setBinding(MeshCore::MeshIO::Binding bind)
|
||||
|
||||
PyObject* PropertyMaterial::getPyObject()
|
||||
{
|
||||
auto getColorList = [](const std::vector<App::Color>& color) {
|
||||
auto getColorList = [](const std::vector<Base::Color>& color) {
|
||||
Py::List list;
|
||||
for (const auto& it : color) {
|
||||
list.append(Py::TupleN(Py::Float(it.r), Py::Float(it.g), Py::Float(it.b)));
|
||||
@@ -534,7 +534,7 @@ PyObject* PropertyMaterial::getPyObject()
|
||||
void PropertyMaterial::setPyObject(PyObject* obj)
|
||||
{
|
||||
auto getColorList = [](const Py::Dict& dict, const std::string& key) {
|
||||
std::vector<App::Color> color;
|
||||
std::vector<Base::Color> color;
|
||||
if (dict.hasKey(key)) {
|
||||
Py::Sequence list(dict.getItem(key));
|
||||
color.reserve(list.size());
|
||||
@@ -610,7 +610,7 @@ void PropertyMaterial::Restore(Base::XMLReader& reader)
|
||||
void PropertyMaterial::SaveDocFile(Base::Writer& writer) const
|
||||
{
|
||||
Base::OutputStream str(writer.Stream());
|
||||
auto saveColor = [&str](const std::vector<App::Color>& color) {
|
||||
auto saveColor = [&str](const std::vector<Base::Color>& color) {
|
||||
uint32_t count = static_cast<uint32_t>(color.size());
|
||||
str << count;
|
||||
for (const auto& it : color) {
|
||||
@@ -640,7 +640,7 @@ void PropertyMaterial::SaveDocFile(Base::Writer& writer) const
|
||||
void PropertyMaterial::RestoreDocFile(Base::Reader& reader)
|
||||
{
|
||||
Base::InputStream str(reader);
|
||||
auto restoreColor = [&str](std::vector<App::Color>& color) {
|
||||
auto restoreColor = [&str](std::vector<Base::Color>& color) {
|
||||
uint32_t count = 0;
|
||||
str >> count;
|
||||
color.resize(count);
|
||||
@@ -702,7 +702,7 @@ unsigned int PropertyMaterial::getMemSize() const
|
||||
{
|
||||
auto size = (_material.ambientColor.size() + _material.diffuseColor.size()
|
||||
+ _material.emissiveColor.size() + _material.specularColor.size())
|
||||
* sizeof(App::Color)
|
||||
* sizeof(Base::Color)
|
||||
+ (_material.shininess.size() + _material.transparency.size()) * sizeof(float)
|
||||
+ _material.library.size() + sizeof(_material);
|
||||
return static_cast<unsigned int>(size);
|
||||
|
||||
@@ -189,19 +189,19 @@ public:
|
||||
/** Sets the property
|
||||
*/
|
||||
void setValue(const MeshCore::Material& value);
|
||||
void setAmbientColor(const std::vector<App::Color>& value);
|
||||
void setDiffuseColor(const std::vector<App::Color>& value);
|
||||
void setSpecularColor(const std::vector<App::Color>& value);
|
||||
void setEmissiveColor(const std::vector<App::Color>& value);
|
||||
void setAmbientColor(const std::vector<Base::Color>& value);
|
||||
void setDiffuseColor(const std::vector<Base::Color>& value);
|
||||
void setSpecularColor(const std::vector<Base::Color>& value);
|
||||
void setEmissiveColor(const std::vector<Base::Color>& value);
|
||||
void setShininess(const std::vector<float>&);
|
||||
void setTransparency(const std::vector<float>&);
|
||||
void setBinding(MeshCore::MeshIO::Binding);
|
||||
|
||||
const MeshCore::Material& getValue() const;
|
||||
const std::vector<App::Color>& getAmbientColor() const;
|
||||
const std::vector<App::Color>& getDiffuseColor() const;
|
||||
const std::vector<App::Color>& getSpecularColor() const;
|
||||
const std::vector<App::Color>& getEmissiveColor() const;
|
||||
const std::vector<Base::Color>& getAmbientColor() const;
|
||||
const std::vector<Base::Color>& getDiffuseColor() const;
|
||||
const std::vector<Base::Color>& getSpecularColor() const;
|
||||
const std::vector<Base::Color>& getEmissiveColor() const;
|
||||
const std::vector<float>& getShininess() const;
|
||||
const std::vector<float>& getTransparency() const;
|
||||
MeshCore::MeshIO::Binding getBinding() const;
|
||||
|
||||
@@ -47,14 +47,14 @@ MeshTexture::MeshTexture(const Mesh::MeshObject& mesh, const MeshCore::Material&
|
||||
}
|
||||
|
||||
void MeshTexture::apply(const Mesh::MeshObject& mesh,
|
||||
const App::Color& defaultColor,
|
||||
const Base::Color& defaultColor,
|
||||
MeshCore::Material& material)
|
||||
{
|
||||
apply(mesh, true, defaultColor, -1.0F, material);
|
||||
}
|
||||
|
||||
void MeshTexture::apply(const Mesh::MeshObject& mesh,
|
||||
const App::Color& defaultColor,
|
||||
const Base::Color& defaultColor,
|
||||
float max_dist,
|
||||
MeshCore::Material& material)
|
||||
{
|
||||
@@ -63,31 +63,31 @@ void MeshTexture::apply(const Mesh::MeshObject& mesh,
|
||||
|
||||
void MeshTexture::apply(const Mesh::MeshObject& mesh, MeshCore::Material& material)
|
||||
{
|
||||
App::Color defaultColor;
|
||||
Base::Color defaultColor;
|
||||
apply(mesh, false, defaultColor, -1.0F, material);
|
||||
}
|
||||
|
||||
void MeshTexture::apply(const Mesh::MeshObject& mesh, float max_dist, MeshCore::Material& material)
|
||||
{
|
||||
App::Color defaultColor;
|
||||
Base::Color defaultColor;
|
||||
apply(mesh, false, defaultColor, max_dist, material);
|
||||
}
|
||||
|
||||
void MeshTexture::apply(const Mesh::MeshObject& mesh,
|
||||
bool addDefaultColor,
|
||||
const App::Color& defaultColor,
|
||||
const Base::Color& defaultColor,
|
||||
float max_dist,
|
||||
MeshCore::Material& material)
|
||||
{
|
||||
// copy the color values because the passed material could be the same instance as
|
||||
// 'materialRefMesh'
|
||||
std::vector<App::Color> textureColor = materialRefMesh.diffuseColor;
|
||||
std::vector<Base::Color> textureColor = materialRefMesh.diffuseColor;
|
||||
material.diffuseColor.clear();
|
||||
material.binding = MeshCore::MeshIO::OVERALL;
|
||||
|
||||
if (kdTree) {
|
||||
// the points of the current mesh
|
||||
std::vector<App::Color> diffuseColor;
|
||||
std::vector<Base::Color> diffuseColor;
|
||||
const MeshCore::MeshPointArray& points = mesh.getKernel().GetPoints();
|
||||
const MeshCore::MeshFacetArray& facets = mesh.getKernel().GetFacets();
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
original material is used.
|
||||
*/
|
||||
void apply(const Mesh::MeshObject& mesh,
|
||||
const App::Color& defaultColor,
|
||||
const Base::Color& defaultColor,
|
||||
MeshCore::Material& material);
|
||||
/*!
|
||||
Find common points or facets of this to the original mesh. For points or facets
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
original material is used.
|
||||
*/
|
||||
void apply(const Mesh::MeshObject& mesh,
|
||||
const App::Color& defaultColor,
|
||||
const Base::Color& defaultColor,
|
||||
float max_dist,
|
||||
MeshCore::Material& material);
|
||||
/*!
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
private:
|
||||
void apply(const Mesh::MeshObject& mesh,
|
||||
bool addDefaultColor,
|
||||
const App::Color& defaultColor,
|
||||
const Base::Color& defaultColor,
|
||||
float max_dist,
|
||||
MeshCore::Material& material);
|
||||
PointIndex findIndex(const Base::Vector3f& p, float max_dist) const
|
||||
|
||||
@@ -117,7 +117,7 @@ void ViewProviderFace::attach(App::DocumentObject* obj)
|
||||
|
||||
SoBaseColor* basecol = new SoBaseColor;
|
||||
if (mesh) {
|
||||
App::Color col = mesh->ShapeAppearance.getDiffuseColor();
|
||||
Base::Color col = mesh->ShapeAppearance.getDiffuseColor();
|
||||
basecol->rgb.setValue(col.r, col.g, col.b);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -269,7 +269,7 @@ ViewProviderMesh::ViewProviderMesh()
|
||||
Gui::WindowParameter::getDefaultParameter()->GetGroup("Mod/Mesh");
|
||||
|
||||
// Mesh color
|
||||
App::Color color = ShapeAppearance.getDiffuseColor();
|
||||
Base::Color color = ShapeAppearance.getDiffuseColor();
|
||||
unsigned long current = color.getPackedValue();
|
||||
unsigned long setting = hGrp->GetUnsigned("MeshColor", current);
|
||||
if (current != setting) {
|
||||
@@ -353,7 +353,7 @@ void ViewProviderMesh::onChanged(const App::Property* prop)
|
||||
}
|
||||
}
|
||||
else if (prop == &LineColor) {
|
||||
const App::Color& c = LineColor.getValue();
|
||||
const Base::Color& c = LineColor.getValue();
|
||||
pLineColor->diffuseColor.setValue(c.r, c.g, c.b);
|
||||
}
|
||||
else if (prop == &Coloring) {
|
||||
@@ -373,7 +373,7 @@ void ViewProviderMesh::onChanged(const App::Property* prop)
|
||||
ViewProviderGeometryObject::onChanged(prop);
|
||||
}
|
||||
|
||||
void ViewProviderMesh::setOpenEdgeColorFrom(const App::Color& c)
|
||||
void ViewProviderMesh::setOpenEdgeColorFrom(const Base::Color& c)
|
||||
{
|
||||
float r = 1.0F - c.r;
|
||||
r = r < 0.5F ? 0.0F : 1.0F;
|
||||
@@ -588,7 +588,7 @@ void ViewProviderMesh::tryColorPerVertexOrFace(bool on)
|
||||
}
|
||||
else {
|
||||
pcMatBinding->value = SoMaterialBinding::OVERALL;
|
||||
const App::Color& c = ShapeAppearance.getDiffuseColor();
|
||||
const Base::Color& c = ShapeAppearance.getDiffuseColor();
|
||||
pcShapeMaterial->diffuseColor.setValue(c.r, c.g, c.b);
|
||||
pcShapeMaterial->transparency.setValue(Transparency.getValue() / 100.0F);
|
||||
}
|
||||
@@ -606,7 +606,7 @@ void ViewProviderMesh::setColorPerFace(const App::PropertyColorList* prop)
|
||||
setDiffuseColor(prop->getValues());
|
||||
}
|
||||
|
||||
void ViewProviderMesh::setColorField(const std::vector<App::Color>& val, SoMFColor& field)
|
||||
void ViewProviderMesh::setColorField(const std::vector<Base::Color>& val, SoMFColor& field)
|
||||
{
|
||||
field.setNum(val.size());
|
||||
SbColor* col = field.startEditing();
|
||||
@@ -619,22 +619,22 @@ void ViewProviderMesh::setColorField(const std::vector<App::Color>& val, SoMFCol
|
||||
field.finishEditing();
|
||||
}
|
||||
|
||||
void ViewProviderMesh::setAmbientColor(const std::vector<App::Color>& val)
|
||||
void ViewProviderMesh::setAmbientColor(const std::vector<Base::Color>& val)
|
||||
{
|
||||
setColorField(val, pcShapeMaterial->ambientColor);
|
||||
}
|
||||
|
||||
void ViewProviderMesh::setDiffuseColor(const std::vector<App::Color>& val)
|
||||
void ViewProviderMesh::setDiffuseColor(const std::vector<Base::Color>& val)
|
||||
{
|
||||
setColorField(val, pcShapeMaterial->diffuseColor);
|
||||
}
|
||||
|
||||
void ViewProviderMesh::setSpecularColor(const std::vector<App::Color>& val)
|
||||
void ViewProviderMesh::setSpecularColor(const std::vector<Base::Color>& val)
|
||||
{
|
||||
setColorField(val, pcShapeMaterial->specularColor);
|
||||
}
|
||||
|
||||
void ViewProviderMesh::setEmissiveColor(const std::vector<App::Color>& val)
|
||||
void ViewProviderMesh::setEmissiveColor(const std::vector<Base::Color>& val)
|
||||
{
|
||||
setColorField(val, pcShapeMaterial->emissiveColor);
|
||||
}
|
||||
@@ -1982,7 +1982,7 @@ void ViewProviderMesh::fillHole(Mesh::FacetIndex uFacet)
|
||||
void ViewProviderMesh::setFacetTransparency(const std::vector<float>& facetTransparency)
|
||||
{
|
||||
if (pcShapeMaterial->diffuseColor.getNum() != int(facetTransparency.size())) {
|
||||
App::Color c = ShapeAppearance.getDiffuseColor();
|
||||
Base::Color c = ShapeAppearance.getDiffuseColor();
|
||||
pcShapeMaterial->diffuseColor.setNum(facetTransparency.size());
|
||||
SbColor* cols = pcShapeMaterial->diffuseColor.startEditing();
|
||||
for (std::size_t index = 0; index < facetTransparency.size(); ++index) {
|
||||
@@ -2004,7 +2004,7 @@ void ViewProviderMesh::setFacetTransparency(const std::vector<float>& facetTrans
|
||||
void ViewProviderMesh::resetFacetTransparency()
|
||||
{
|
||||
pcMatBinding->value = SoMaterialBinding::OVERALL;
|
||||
App::Color c = ShapeAppearance.getDiffuseColor();
|
||||
Base::Color c = ShapeAppearance.getDiffuseColor();
|
||||
pcShapeMaterial->diffuseColor.setValue(c.r, c.g, c.b);
|
||||
pcShapeMaterial->transparency.setValue(0);
|
||||
}
|
||||
@@ -2032,8 +2032,8 @@ void ViewProviderMesh::removeFacets(const std::vector<Mesh::FacetIndex>& facets)
|
||||
// switch off coloring mode
|
||||
Coloring.setValue(false);
|
||||
|
||||
const std::vector<App::Color>& colors = prop->getValues();
|
||||
std::vector<App::Color> valid_colors;
|
||||
const std::vector<Base::Color>& colors = prop->getValues();
|
||||
std::vector<Base::Color> valid_colors;
|
||||
valid_colors.reserve(kernel->countPoints() - invalid);
|
||||
std::size_t numPoints = pointDegree.size();
|
||||
for (std::size_t index = 0; index < numPoints; index++) {
|
||||
@@ -2054,8 +2054,8 @@ void ViewProviderMesh::removeFacets(const std::vector<Mesh::FacetIndex>& facets)
|
||||
validFacets[it] = false;
|
||||
}
|
||||
|
||||
const std::vector<App::Color>& colors = prop->getValues();
|
||||
std::vector<App::Color> valid_colors;
|
||||
const std::vector<Base::Color>& colors = prop->getValues();
|
||||
std::vector<Base::Color> valid_colors;
|
||||
valid_colors.reserve(colors.size());
|
||||
std::size_t numColors = colors.size();
|
||||
for (std::size_t index = 0; index < numColors; index++) {
|
||||
@@ -2112,7 +2112,7 @@ void ViewProviderMesh::deselectFacet(Mesh::FacetIndex facet)
|
||||
highlightSelection();
|
||||
}
|
||||
else {
|
||||
App::Color c = ShapeAppearance.getDiffuseColor();
|
||||
Base::Color c = ShapeAppearance.getDiffuseColor();
|
||||
pcShapeMaterial->diffuseColor.set1Value(facet, c.r, c.g, c.b);
|
||||
}
|
||||
}
|
||||
@@ -2280,7 +2280,7 @@ void ViewProviderMesh::highlightSelection()
|
||||
|
||||
// Colorize the selection
|
||||
pcMatBinding->value = SoMaterialBinding::PER_FACE;
|
||||
App::Color c = ShapeAppearance.getDiffuseColor();
|
||||
Base::Color c = ShapeAppearance.getDiffuseColor();
|
||||
int uCtFacets = (int)rMesh.countFacets();
|
||||
pcShapeMaterial->diffuseColor.setNum(uCtFacets);
|
||||
|
||||
@@ -2296,7 +2296,7 @@ void ViewProviderMesh::highlightSelection()
|
||||
|
||||
void ViewProviderMesh::unhighlightSelection()
|
||||
{
|
||||
App::Color c = ShapeAppearance.getDiffuseColor();
|
||||
Base::Color c = ShapeAppearance.getDiffuseColor();
|
||||
pcMatBinding->value = SoMaterialBinding::OVERALL;
|
||||
pcShapeMaterial->diffuseColor.setNum(1);
|
||||
pcShapeMaterial->diffuseColor.setValue(c.r, c.g, c.b);
|
||||
@@ -2358,13 +2358,13 @@ void ViewProviderMesh::setHighlightedSegments(bool on)
|
||||
|
||||
void ViewProviderMesh::highlightSegments()
|
||||
{
|
||||
std::vector<App::Color> colors;
|
||||
std::vector<Base::Color> colors;
|
||||
const Mesh::MeshObject& rMesh = getMeshObject();
|
||||
unsigned long numSegm = rMesh.countSegments();
|
||||
colors.resize(numSegm, this->ShapeAppearance.getDiffuseColor());
|
||||
|
||||
for (unsigned long i = 0; i < numSegm; i++) {
|
||||
App::Color col;
|
||||
Base::Color col;
|
||||
if (col.fromHexString(rMesh.getSegment(i).getColor())) {
|
||||
colors[i] = col;
|
||||
}
|
||||
@@ -2373,7 +2373,7 @@ void ViewProviderMesh::highlightSegments()
|
||||
highlightSegments(colors);
|
||||
}
|
||||
|
||||
void ViewProviderMesh::highlightSegments(const std::vector<App::Color>& colors)
|
||||
void ViewProviderMesh::highlightSegments(const std::vector<Base::Color>& colors)
|
||||
{
|
||||
const Mesh::MeshObject& rMesh = getMeshObject();
|
||||
unsigned long numSegm = rMesh.countSegments();
|
||||
|
||||
@@ -199,7 +199,7 @@ public:
|
||||
/*! The size of the array must be equal to the number of facets. */
|
||||
void setFacetTransparency(const std::vector<float>&);
|
||||
void resetFacetTransparency();
|
||||
void highlightSegments(const std::vector<App::Color>&);
|
||||
void highlightSegments(const std::vector<Base::Color>&);
|
||||
//@}
|
||||
|
||||
/** @name Restoring view provider from document load */
|
||||
@@ -215,7 +215,7 @@ protected:
|
||||
/// get called by the container whenever a property has been changed
|
||||
void onChanged(const App::Property* prop) override;
|
||||
virtual void showOpenEdges(bool);
|
||||
void setOpenEdgeColorFrom(const App::Color& col);
|
||||
void setOpenEdgeColorFrom(const Base::Color& col);
|
||||
virtual void
|
||||
splitMesh(const MeshCore::MeshKernel& toolMesh, const Base::Vector3f& normal, SbBool inner);
|
||||
virtual void
|
||||
@@ -241,11 +241,11 @@ protected:
|
||||
const Mesh::PropertyMeshKernel& getMeshProperty() const;
|
||||
Mesh::PropertyMeshKernel& getMeshProperty();
|
||||
|
||||
void setColorField(const std::vector<App::Color>&, SoMFColor&);
|
||||
void setAmbientColor(const std::vector<App::Color>&);
|
||||
void setDiffuseColor(const std::vector<App::Color>&);
|
||||
void setSpecularColor(const std::vector<App::Color>&);
|
||||
void setEmissiveColor(const std::vector<App::Color>&);
|
||||
void setColorField(const std::vector<Base::Color>&, SoMFColor&);
|
||||
void setAmbientColor(const std::vector<Base::Color>&);
|
||||
void setDiffuseColor(const std::vector<Base::Color>&);
|
||||
void setSpecularColor(const std::vector<Base::Color>&);
|
||||
void setEmissiveColor(const std::vector<Base::Color>&);
|
||||
|
||||
virtual SoShape* getShapeNode() const;
|
||||
virtual SoNode* getCoordNode() const;
|
||||
|
||||
@@ -360,7 +360,7 @@ void ViewProviderMeshCurvature::setVertexCurvatureMode(int mode)
|
||||
float* transp = pcColorMat->transparency.startEditing();
|
||||
|
||||
for (auto const& value : fValues | boost::adaptors::indexed(0)) {
|
||||
App::Color c = pcColorBar->getColor(value.value());
|
||||
Base::Color c = pcColorBar->getColor(value.value());
|
||||
// NOLINTBEGIN
|
||||
diffcol[value.index()].setValue(c.r, c.g, c.b);
|
||||
transp[value.index()] = c.transparency();
|
||||
|
||||
Reference in New Issue
Block a user