Added riGetSelectedCases based on currently selected cases in the main tree view

p4#: 21604
This commit is contained in:
Magne Sjaastad
2013-05-13 22:32:01 +02:00
parent 10b49efae9
commit 22d45bc28f
5 changed files with 244 additions and 1 deletions
@@ -250,8 +250,9 @@ void RiaSocketServer::readCommandFromOctave()
bool isGetGridDim = args[0] == "GetMainGridDimensions"; // GetMainGridDimensions [casename/index]
bool isGetCurrentCase = args[0] == "GetCurrentCase";
bool isGetCaseGroups = args[0] == "GetCaseGroups";
bool isGetSelectedCases = args[0] == "GetSelectedCases";
if (!(isGetProperty || isSetProperty || isGetCellInfo || isGetGridDim || isGetCurrentCase || isGetCaseGroups))
if (!(isGetProperty || isSetProperty || isGetCellInfo || isGetGridDim || isGetCurrentCase || isGetCaseGroups || isGetSelectedCases))
{
m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + tr("Unknown command: %1").arg(args[0].data()));
terminateCurrentConnection();
@@ -357,6 +358,42 @@ void RiaSocketServer::readCommandFromOctave()
return;
}
if (isGetSelectedCases)
{
RiuMainWindow* ruiMainWindow = RiuMainWindow::instance();
if (ruiMainWindow)
{
std::vector<qint64> caseIds;
std::vector<QString> caseNames;
std::vector<qint64> caseTypes;
std::vector<qint64> caseGroupIds;
ruiMainWindow->selectionInfo(caseIds, caseNames, caseTypes, caseGroupIds);
quint64 byteCount = sizeof(quint64);
quint64 selectionCount = caseIds.size();
for (size_t i = 0; i < selectionCount; i++)
{
byteCount += caseNames[i].size() * sizeof(QChar);
byteCount += 3*sizeof(qint64);
}
socketStream << byteCount;
socketStream << selectionCount;
for (size_t i = 0; i < selectionCount; i++)
{
socketStream << caseIds[i];
socketStream << caseNames[i];
socketStream << caseTypes[i];
socketStream << caseGroupIds[i];
}
}
return;
}
if (reservoir == NULL)
{
@@ -1520,3 +1520,36 @@ void RiuMainWindow::updateScaleValue()
m_scaleFactor->setEnabled(false);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::selectionInfo(std::vector<qint64>& caseIds, std::vector<QString>& caseNames, std::vector<qint64>& caseTypes, std::vector<qint64>& caseGroupIds)
{
if (m_treeView && m_treeView->selectionModel())
{
QModelIndexList selectedModelIndexes = m_treeView->selectionModel()->selectedIndexes();
for (int i = 0; i < selectedModelIndexes.size(); i++)
{
caf::PdmUiTreeItem* uiTreeItem = m_treeModelPdm->getTreeItemFromIndex(selectedModelIndexes[i]);
if (uiTreeItem && uiTreeItem->dataObject())
{
RimCase* rimCase = dynamic_cast<RimCase*>(uiTreeItem->dataObject().p());
if (rimCase)
{
caseIds.push_back(rimCase->caseId());
caseNames.push_back(rimCase->caseUserDescription());
caseTypes.push_back(-1);
qint64 caseGroupId = -1;
if (rimCase->parentGridCaseGroup())
{
caseGroupId = rimCase->parentGridCaseGroup()->groupId();
}
caseGroupIds.push_back(caseGroupId);
}
}
}
}
}
@@ -84,6 +84,8 @@ public:
void setCurrentObjectInTreeView(caf::PdmObject* object);
void selectionInfo(std::vector<qint64>& caseIds, std::vector<QString>& caseNames, std::vector<qint64>& caseTypes, std::vector<qint64>& caseGroupIds);
protected:
virtual void closeEvent(QCloseEvent* event);