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

Renaming HtmlFormat to ToolTipFormat, and creating a new HtmlFormat. #343

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/SIMPLib/Common/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ namespace SIMPL

enum InfoStringFormat
{
HtmlFormat = 0,
ToolTipFormat = 0,
// JsonFormat,
// TextFormat,
HtmlFormat,
// XmlFormat,
UnknownFormat
};
Expand Down
32 changes: 22 additions & 10 deletions Source/SIMPLib/DataArrays/DataArray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1380,19 +1380,28 @@ template <typename T> class DataArray : public IDataArray

QString info;
QTextStream ss(&info);
if(format == SIMPL::HtmlFormat)

QString bgColor = "";
QString nameBgColor = "";

switch(format)
{
case SIMPL::ToolTipFormat:
bgColor = "bgcolor=\"#FFFCEA\"";
nameBgColor = "bgcolor=\"#E9E7D6\"";
case SIMPL::HtmlFormat:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment here (before the case SIMPL::HtmlFormat:) stating that the fall-through is intentional. Better yet, use a commented out [[fallthrough]] attribute to document the intention. Without any kind of documentation of intent, this looks like a mistake and could be easily "fixed" while trying to reduce compiler warnings.

{
ss << "<html><head></head>\n";
ss << "<body>\n";
ss << "<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\">\n";
ss << "<tbody>\n";
ss << "<tr bgcolor=\"#FFFCEA\"><th colspan=2>Attribute Array Info</th></tr>";
ss << "<tr " << bgColor << "><th colspan=2>Attribute Array Info</th></tr>";

ss << R"(<tr bgcolor="#E9E7D6"><th align="right">Name:</th><td>)" << getName() << "</td></tr>";
ss << "<tr " << nameBgColor << "><th align=\"right\">Name:</th><td>" << getName() << "</td></tr>";

ss << R"(<tr bgcolor="#FFFCEA"><th align="right">Type:</th><td> DataArray&lt;)" << getTypeAsString() << "&gt;</td></tr>";
ss << "<tr " << bgColor << "><th align=\"right\">Type:</th><td> DataArray&lt;" << getTypeAsString() << "&gt;</td></tr>";
QString numStr = usa.toString(static_cast<qlonglong>(getNumberOfTuples()));
ss << R"(<tr bgcolor="#FFFCEA"><th align="right">Number of Tuples:</th><td>)" << numStr << "</td></tr>";
ss << "<tr " << bgColor << "><th align=\"right\">Number of Tuples:</th><td>" << numStr << "</td></tr>";

QString compDimStr = "(";
for(int i = 0; i < m_CompDims.size(); i++)
Expand All @@ -1404,17 +1413,20 @@ template <typename T> class DataArray : public IDataArray
}
}
compDimStr = compDimStr + ")";
ss << R"(<tr bgcolor="#FFFCEA"><th align="right">Component Dimensions:</th><td>)" << compDimStr << "</td></tr>";
ss << "<tr " << bgColor << "><th align=\"right\">Component Dimensions:</th><td>" << compDimStr << "</td></tr>";
numStr = usa.toString(static_cast<qlonglong>(m_Size));
ss << R"(<tr bgcolor="#FFFCEA"><th align="right">Total Elements:</th><td>)" << numStr << "</td></tr>";
ss << "<tr " << bgColor << "><th align=\"right\">Total Elements:</th><td>" << numStr << "</td></tr>";
numStr = usa.toString(static_cast<qlonglong>(m_Size * sizeof(T)));
ss << R"(<tr bgcolor="#FFFCEA"><th align="right">Total Memory Required:</th><td>)" << numStr << "</td></tr>";
ss << "<tr " << bgColor << "><th align=\"right\">Total Memory Required:</th><td>" << numStr << "</td></tr>";
ss << "</tbody></table>\n";
ss << "</body></html>";
break;
}
else
{
default:
ss << "Requested DataArray information string format is not supported. " << format;
break;
}

return info;
}

Expand Down
29 changes: 20 additions & 9 deletions Source/SIMPLib/DataArrays/NeighborList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,30 +792,41 @@ class NeighborList : public IDataArray
{
QString info;
QTextStream ss (&info);
if(format == SIMPL::HtmlFormat)

QString bgColor = "";
QString nameBgColor = "";

switch(format)
{
case SIMPL::ToolTipFormat:
bgColor = "bgcolor=\"#FFFCEA\"";
nameBgColor = "bgcolor=\"#E9E7D6\"";
case SIMPL::HtmlFormat:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If fall-through is intentional, make sure to document it ever time. // [[falthrough]] should be good enough while remaining short and easy to read. We can't use the fallthrough attribute as it's C++17, but it's everything we would want to use while remaining far more easily readable than a longer comment stating that we want to use [[fallthrough]]

{
ss << "<html><head></head>\n";
ss << "<body>\n";
ss << "<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\">\n";
ss << "<tbody>\n";
ss << "<tr bgcolor=\"#FFFCEA\"><th colspan=2>Attribute Array Info</th></tr>";
ss << "<tr " << bgColor << "><th colspan=2>Attribute Array Info</th></tr>";

ss << "<tr bgcolor=\"#E9E7D6\"><th align=\"right\">Name:</th><td>" << getName() << "</td></tr>";
ss << "<tr " << nameBgColor << "><th align=\"right\">Name:</th><td>" << getName() << "</td></tr>";

ss << "<tr bgcolor=\"#FFFCEA\"><th align=\"right\">Type:</th><td>" << getTypeAsString() << "</td></tr>";
ss << "<tr " << bgColor << "><th align=\"right\">Type:</th><td>" << getTypeAsString() << "</td></tr>";
QLocale usa(QLocale::English, QLocale::UnitedStates);
QString numStr = usa.toString(static_cast<qlonglong>(getNumberOfTuples()));
ss << "<tr bgcolor=\"#FFFCEA\"><th align=\"right\">Number of Tuples:</th><td>" << numStr << "</td></tr>";
ss << "<tr bgcolor=\"#FFFCEA\"><th align=\"right\">Number of Lists:</th><td>" << getNumberOfLists() << "</td></tr>";
ss << "<tr " << bgColor << "><th align=\"right\">Number of Tuples:</th><td>" << numStr << "</td></tr>";
ss << "<tr " << bgColor << "><th align=\"right\">Number of Lists:</th><td>" << getNumberOfLists() << "</td></tr>";

ss << "</tbody></table>\n";
ss << "<br/>";
ss << "</body></html>";
break;
}
else
{

default:
ss << "Requested NeighborList information string format is not supported. " << format;
break;
}

return info;
}
/**
Expand Down
26 changes: 19 additions & 7 deletions Source/SIMPLib/DataArrays/StatsDataArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,28 +674,40 @@ QString StatsDataArray::getInfoString(SIMPL::InfoStringFormat format)
{
QString info;
QTextStream ss(&info);
if(format == SIMPL::HtmlFormat)

QString bgColor = "";
QString nameBgColor = "";

switch(format)
{
case SIMPL::ToolTipFormat:
bgColor = "bgcolor=\"#FFFCEA\"";
nameBgColor = "bgcolor=\"#E9E7D6\"";
case SIMPL::HtmlFormat:
{
ss << "<html><head></head>\n";
ss << "<body>\n";
ss << "<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\">\n";
ss << "<tbody>\n";
ss << "<tr bgcolor=\"#FFFCEA\"><th colspan=2>Attribute Array Info</th></tr>";
ss << "<tr " << bgColor << "><th colspan=2>Attribute Array Info</th></tr>";

ss << "<tr bgcolor=\"#E9E7D6\"><th align=\"right\">Name:</th><td>" << getName() << "</td></tr>";
ss << "<tr " << nameBgColor << "><th align=\"right\">Name:</th><td>" << getName() << "</td></tr>";

ss << "<tr bgcolor=\"#FFFCEA\"><th align=\"right\">Type:</th><td>" << getTypeAsString() << "</td></tr>";
ss << "<tr " << bgColor << "><th align=\"right\">Type:</th><td>" << getTypeAsString() << "</td></tr>";
QLocale usa(QLocale::English, QLocale::UnitedStates);
QString numStr = usa.toString(static_cast<qlonglong>(getNumberOfTuples()));
ss << "<tr bgcolor=\"#FFFCEA\"><th align=\"right\">Number of Tuples:</th><td>" << numStr << "</td></tr>";
ss << "<tr " << bgColor << "><th align=\"right\">Number of Tuples:</th><td>" << numStr << "</td></tr>";

ss << "</tbody></table>\n";
ss << "<br/>";
ss << "</body></html>";
break;
}
else
{
default:
ss << "Requested StatsDataArray information string format is not supported. " << format;
break;
}

return info;
}

Expand Down
24 changes: 17 additions & 7 deletions Source/SIMPLib/DataArrays/StringDataArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,25 +464,35 @@ QString StringDataArray::getInfoString(SIMPL::InfoStringFormat format)
{
QString info;
QTextStream ss(&info);
if(format == SIMPL::HtmlFormat)

QString bgColor = "";

switch(format)
{
case SIMPL::ToolTipFormat:
bgColor = "bgcolor=\"#FFFCEA\"";
case SIMPL::HtmlFormat:
{
ss << "<html><head></head>\n";
ss << "<body>\n";
ss << "<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\">\n";
ss << "<tbody>\n";
ss << "<tr bgcolor=\"#FFFCEA\"><th colspan=2>Attribute Array Info</th></tr>";
ss << R"(<tr bgcolor="#FFFCEA"><th align="right">Name:</th><td>)" << getName() << R"(</td></tr>)";
ss << "<tr bgcolor=\"#FFFCEA\"><th align=\"right\">Type:</th><td>" << getTypeAsString() << R"(</td></tr>)";
ss << "<tr " << bgColor << "><th colspan=2>Attribute Array Info</th></tr>";
ss << "<tr " << bgColor << "><th align=\"right\">Name:</th><td>" << getName() << R"(</td></tr>)";
ss << "<tr " << bgColor << "><th align=\"right\">Type:</th><td>" << getTypeAsString() << R"(</td></tr>)";
QLocale usa(QLocale::English, QLocale::UnitedStates);
QString numStr = usa.toString(static_cast<qlonglong>(getNumberOfTuples()));
ss << R"(<tr bgcolor=\"#FFFCEA\"><th align=\"right\">Number of Tuples:</th><td>)" << numStr << R"(</td></tr>)";
ss << "<tr " << bgColor << "><th align=\"right\">Number of Tuples:</th><td>" << numStr << R"(</td></tr>)";
ss << "</tbody></table>\n";
ss << "<br/>";
ss << "</body></html>";
break;
}
else
{
default:
ss << "Requested StringDataArray information string format is not supported. " << format;
break;
}

return info;
}

Expand Down
27 changes: 19 additions & 8 deletions Source/SIMPLib/DataArrays/StructArray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,26 +669,37 @@ class StructArray : public IDataArray
{
QString info;
QTextStream ss (&info);
if(format == SIMPL::HtmlFormat)

QString bgColor = "";
QString nameBgColor = "";

switch(format)
{
case SIMPL::ToolTipFormat:
bgColor = "bgcolor=\"#FFFCEA\"";
nameBgColor = "bgcolor=\"#E9E7D6\"";
case SIMPL::HtmlFormat:
{
ss << "<html><head></head>\n";
ss << "<body>\n";
ss << "<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\">\n";
ss << "<tbody>\n";
ss << "<tr bgcolor=\"#FFFCEA\"><th colspan=2>Attribute Array Info</th></tr>";
ss << "<tr bgcolor=\"#E9E7D6\"><th align=\"right\">Name:</th><td>" << getName() << "</td></tr>";
ss << "<tr bgcolor=\"#FFFCEA\"><th align=\"right\">Type:</th><td>" << getTypeAsString() << "</td></tr>";
ss << "<tr " << bgColor << "><th colspan=2>Attribute Array Info</th></tr>";
ss << "<tr " << nameBgColor << "><th align=\"right\">Name:</th><td>" << getName() << "</td></tr>";
ss << "<tr " << bgColor << "><th align=\"right\">Type:</th><td>" << getTypeAsString() << "</td></tr>";
QLocale usa(QLocale::English, QLocale::UnitedStates);
QString numStr = usa.toString(static_cast<qlonglong>(getNumberOfTuples()));
ss << "<tr bgcolor=\"#FFFCEA\"><th align=\"right\">Number of Tuples:</th><td>" << numStr << "</td></tr>";
ss << "<tr " << bgColor << "><th align=\"right\">Number of Tuples:</th><td>" << numStr << "</td></tr>";
ss << "</tbody></table>\n";
ss << "<br/>";
ss << "</body></html>";
break;
}
else
{

default:
ss << "Requested StructArray information string format is not supported. " << format;
break;
}

return info;
}

Expand Down