Skip to content

Commit

Permalink
Refs #11597 Remove the unused rebin logic
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonPiccardoSelg committed Apr 21, 2015
1 parent 677dfcc commit b35f148
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ namespace Mantid

void getStoredWorkspaceNames(pqPipelineSource* source, std::string& originalWorkspaceName, std::string& rebinnedWorkspaceName);

void registerRebinnedSource(pqPipelineSource* source);

bool isRebinnedSource(std::string name);

bool doesWorkspaceBelongToRebinnedSource(std::string workspaceName);
Expand All @@ -88,9 +86,6 @@ namespace Mantid

void afterReplaceHandle(const std::string &workspaceName, const boost::shared_ptr<Mantid::API::Workspace> workspace);

private slots:
void onRebinnedSourceDestroyed();

private:
std::map<std::string, std::string> m_originalWorkspaceToRebinnedWorkspace; ///< Holds the mapping from the original source to the rebinned source

Expand All @@ -110,14 +105,8 @@ namespace Mantid

void processWorkspaceNames(std::string& inputWorkspace, std::string& outputWorkspace, std::string workspaceName, std::string algorithmType);

void removeUnusedRebinnedWorkspaces();

void untrackWorkspaces(std::string rebinnedSource);

void removeRebinnedWorkspace(std::string rebinnedWorkspace);

void compareToSources(std::string workspaceName);

void copyProperties(pqPipelineFilter* filter1, pqPipelineFilter* filter2);

static void copySafe(vtkSMProxy* dest, vtkSMProxy* source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,6 @@ void MdViewerWidget::prepareRebinnedWorkspace(const std::string rebinnedWorkspac
// It seems that the new source gets set as active before it is fully constructed. We therefore reset it.
pqActiveObjects::instance().setActiveSource(NULL);
pqActiveObjects::instance().setActiveSource(newRebinnedSource);
//m_rebinnedSourcesManager.registerRebinnedSource(newRebinnedSource);

this->renderAndFinalSetup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,98 +430,6 @@ namespace Mantid
}
}

/**
* Register the rebinned source. Specifically, connect to the destroyed signal of the rebinned source.
* @param source The rebinned source.
*/
void RebinnedSourcesManager::registerRebinnedSource(pqPipelineSource* source)
{
if (!source)
{
return;
}

QObject::connect(source, SIGNAL(destroyed()),
this, SLOT(onRebinnedSourceDestroyed()));
}

/**
* React to the deletion of a rebinned source.
*/
void RebinnedSourcesManager::onRebinnedSourceDestroyed()
{
removeUnusedRebinnedWorkspaces();
}

/**
* Remove unused rebinned workspaces, by comparing the workspaces against the sources.
*/
void RebinnedSourcesManager::removeUnusedRebinnedWorkspaces()
{
// Iterate through all workspaces and check for ones ending with the tempIdentifier
std::set<std::string> workspaceNames = Mantid::API::AnalysisDataService::Instance().getObjectNamesInclHidden();

for (std::set<std::string>::iterator it = workspaceNames.begin(); it != workspaceNames.end(); ++it)
{
// Only look at the rebinned files
if (it->find(m_tempPostfix) != std::string::npos)
{
compareToSources(*it);
}
}
}

/**
* Compare if the workspace name exists among the sources. If it doesnt't exist, remove it.
* @param workspaceName The name of the workspace
*/
void RebinnedSourcesManager::compareToSources(std::string workspaceName)
{
pqServer *server = pqActiveObjects::instance().activeServer();
pqServerManagerModel *smModel = pqApplicationCore::instance()->getServerManagerModel();
QList<pqPipelineSource *> sources = smModel->findItems<pqPipelineSource *>(server);

for (QList<pqPipelineSource *>::Iterator source = sources.begin(); source != sources.end(); ++source)
{
const QString srcProxyName = (*source)->getProxy()->GetXMLGroup();

if (srcProxyName == QString("sources"))
{
std::string name(vtkSMPropertyHelper((*source)->getProxy(),
"WorkspaceName", true).GetAsString());

// If the rebinned workspace has a source equivalent, then exit
if (name==workspaceName)
{
return;
}
}
}

// There is no source which corresponds to the workspace, hence delete and unregister the workspace.
removeRebinnedWorkspace(workspaceName);
untrackWorkspaces(workspaceName);
}

/**
* Removes the rebinned workspace from memory.
* @param rebinnedWorkspace The name of the rebinned workspace.
*/
void RebinnedSourcesManager::removeRebinnedWorkspace(std::string rebinnedWorkspace)
{
Mantid::VATES::ADSWorkspaceProvider<Mantid::API::IMDHistoWorkspace> adsHistoWorkspaceProvider;
Mantid::VATES::ADSWorkspaceProvider<Mantid::API::IMDEventWorkspace> adsEventWorkspaceProvider;

if (adsHistoWorkspaceProvider.canProvideWorkspace(rebinnedWorkspace))
{
adsHistoWorkspaceProvider.disposeWorkspace(rebinnedWorkspace);
}
else if (adsEventWorkspaceProvider.canProvideWorkspace(rebinnedWorkspace))
{
adsEventWorkspaceProvider.disposeWorkspace(rebinnedWorkspace);
}
}

/**
* Rebuild the pipeline for the new source
* @param source1 The old source.
Expand Down

0 comments on commit b35f148

Please sign in to comment.