Skip to content
Permalink
Browse files

Tweaks to Sandbox Tool

  • Loading branch information...
imikejackson committed May 24, 2019
1 parent b0b781a commit 4d6020f52158bf9fb22592dacf724e66f2b365b0
Showing with 75 additions and 61 deletions.
  1. +26 −25 Tools/SandboxTool.cpp
  2. +16 −8 Tools/SandboxTool/Sandbox.h
  3. +33 −28 Tools/SandboxTool/UpdateMDHeader.hpp
@@ -168,42 +168,43 @@ int main(int argc, char* argv[])
std::list<QDir> dirs;
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjParentDir()));

dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/ExternalProjects/SIMPL/Source"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/ExternalProjects/SIMPLView/Source"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/ExternalProjects/Plugins"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/ExternalProjects/SIMPL/Source/SIMPLib/CoreFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../SIMPLView/Source"));

dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/Source"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/Test"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/Tools"));

// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/Source/Plugins"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/Source/Plugins"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/Source/EbsdLib"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/Source/OrientationLib"));

dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/AskNDEToolbox/AskNDEToolboxFilters"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/BrukerIntegration/BrukerIntegrationFilters"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/CAxisByPolarizedLight/CAxisByPolarizedLightFilters"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/DictionaryIndexing/DictionaryIndexingFilters"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/DREAM3DReview/DREAM3DReviewFilters"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/ImageProcessing/ImageProcessingFilters"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/ITKImageProcessing/ITKImageProcessingFilters"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/Leroy2/Leroy2Filters"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/NETLIntegration/NETLIntegrationFilters"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/ProgWorkshop/ProgWorkshopFilters"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/SMTKPlugin/SMTKPluginFilters"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/SimulationIO/SimulationIOFilters"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/TomvizToolbox/TomvizToolboxFilters"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/UCSBUtilities/UCSBUtilitiesFilters"));
dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/VolumeMeshing/VolumeMeshingFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/Anisotropy/AnisotropyFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/AskNDEToolbox/AskNDEToolboxFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/BrukerIntegration/BrukerIntegrationFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/CAxisByPolarizedLight/CAxisByPolarizedLightFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/DataFusion/DataFusionFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/DatasetMerging/DatasetMergingFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/DictionaryIndexing/DictionaryIndexingFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/DREAM3DReview/DREAM3DReviewFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/Fusion/FusionFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/ImageProcessing/ImageProcessingFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/ITKImageProcessing/ITKImageProcessingFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/Leroy2/Leroy2Filters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/MDIToolbox/MDIToolboxFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/NETLIntegration/NETLIntegrationFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/ProgWorkshop/ProgWorkshopFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/SMTKPlugin/SMTKPluginFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/SimulationIO/SimulationIOFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/TomvizToolbox/TomvizToolboxFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/UCSBUtilities/UCSBUtilitiesFilters"));
// dirs.emplace_back(QDir(D3DTools::GetDREAM3DProjDir() + "/../DREAM3D_Plugins/VolumeMeshing/VolumeMeshingFilters"));

QStringList filters;
filters.append("*.cpp");
// filters.append("*.cpp");
filters.append("*.h");
// filters.append("*.md");

for(auto const& dir : dirs)
{
RecursiveFileSearch<RemoveSIMPLMacros>(dir, filters);
qDebug() << "====> Search Directory " << dir.absolutePath();
RecursiveFileSearch<UpdateMDHeader>(dir, filters);
}

return 0;
@@ -1,6 +1,7 @@
#pragma once

#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QString>
@@ -28,15 +29,19 @@ class Sandbox
*/
void writeOutput(bool didReplace, const QStringList& outLines, const QString& filename)
{
QString finalOutPath = filename;
QFileInfo fi(filename);
if(didReplace)
{
QFileInfo fi2(filename);
#if OVERWRITE_SOURCE_FILE
QFile hOut(filename);

#else
QString tmpPath = "/tmp/" + fi2.fileName();
QFile hOut(tmpPath);
finalOutPath = QDir::homePath() + "/tmp/" + fi.fileName();
#endif
QFile hOut(finalOutPath);

QFileInfo fi2(finalOutPath);

hOut.open(QFile::WriteOnly);
QTextStream stream(&hOut);
stream << outLines.join("\n");
@@ -54,15 +59,18 @@ class Sandbox
*/
void writeOutput(bool didReplace, QVector<QString>& outLines, const QString& filename)
{
QString finalOutPath = filename;
QFileInfo fi(filename);
if(didReplace)
{
QFileInfo fi2(filename);
#if OVERWRITE_SOURCE_FILE
QFile hOut(filename);

#else
QString tmpPath = "/tmp/" + fi2.fileName();
QFile hOut(tmpPath);
finalOutPath = QDir::homePath() + "/tmp/" + fi.fileName();
#endif
QFile hOut(finalOutPath);

QFileInfo fi2(finalOutPath);
hOut.open(QFile::WriteOnly);
QTextStream stream(&hOut);
for(qint32 i = 0; i < outLines.size() - 1; i++)
@@ -20,7 +20,8 @@ class UpdateMDHeader : public Sandbox
QString msg;
QTextStream out(&msg);

out << hFile << '\n';
out << hFile;
qDebug() << msg;

QString contents;
QFileInfo fi(hFile);
@@ -38,49 +39,53 @@ class UpdateMDHeader : public Sandbox
source.close();
}

bool didReplace = false;
bool isIOFilter = false;
QString searchString = "=============";
bool hasInclude = false;
bool hasSearchString = false;

QString searchString = "DEFINE_IDATAARRAY_VARIABLE";
QString includString = "#include \"SIMPLib";

int includeIndex = 0;

QVector<QString> outLines;
QStringList list = contents.split(QRegExp("\\n"));
QStringListIterator sourceLines(list);

int32_t lineIndex = 0;

// Get the first line
QString zeroLine = sourceLines.next();
if(zeroLine.startsWith("#"))
{
// The file is correctly formatted. Skip it and go on.
return;
}

// Get the second line
QString oneLine = sourceLines.next();
if(oneLine.startsWith("===="))
{
// This doc needs updating
zeroLine = "# " + zeroLine + " #";
oneLine = "";
outLines.push_back(zeroLine);
outLines.push_back(oneLine);
didReplace = true;
}

// First Pass is to analyze the header file
while(sourceLines.hasNext())
{
QString line = sourceLines.next();

outLines.push_back(line);
if(line.startsWith(includString))
{
includeIndex = lineIndex;
}
if(line.contains(searchString))
{
hasSearchString = true;
}
if(line.contains("#include \"SIMPLib/DataArrays/IDataArray.h\""))
{
hasInclude = true;
}
lineIndex++;
outLines.push_back(line);
}

if(didReplace && !isIOFilter)
if(!hasInclude && hasSearchString)
{
std::cout << msg.toStdString() << std::endl;
writeOutput(didReplace, outLines, hFile);
QString line = outLines[includeIndex];
line = line + "\n#include \"SIMPLib/DataArrays/IDataArray.h\"";
outLines[includeIndex] = line;
}
qDebug() << "Last SIMPLib Include Directive is line " << includeIndex;

if(!hasInclude && hasSearchString)
{

writeOutput(hasSearchString, outLines, hFile);
}
}
};

0 comments on commit 4d6020f

Please sign in to comment.
You can’t perform that action at this time.