ResInsight/ApplicationCode/Commands/RicNewWellLogPlotFeature.cpp
Pål Hagen 15d34498e3 (#411) Added description/name field to well log plot
Setting default name when adding through command feature.
2015-09-04 16:45:09 +02:00

84 lines
3.2 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicNewWellLogPlotFeature.h"
#include "RimProject.h"
#include "RimMainPlotCollection.h"
#include "RimWellLogPlotCollection.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotTrace.h"
#include "RiaApplication.h"
#include "RiuMainWindow.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicNewWellLogPlotFeature, "RicNewWellLogPlotFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewWellLogPlotFeature::isCommandEnabled()
{
return wellLogPlotCollection() != NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewWellLogPlotFeature::onActionTriggered(bool isChecked)
{
RimWellLogPlotCollection* wellLogPlotColl = wellLogPlotCollection();
if (wellLogPlotColl)
{
RimWellLogPlot* plot = new RimWellLogPlot();
wellLogPlotColl->wellLogPlots().push_back(plot);
RimWellLogPlotTrace* plotrace = new RimWellLogPlotTrace();
plot->addTrace(plotrace);
plot->setDescription(QString("Well Log Plot %1").arg(wellLogPlotCollection()->wellLogPlots.size()));
plot->loadDataAndUpdate();
RiaApplication::instance()->project()->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(plot);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewWellLogPlotFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("New Well Log Plot");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlotCollection* RicNewWellLogPlotFeature::wellLogPlotCollection()
{
RimProject* project = RiaApplication::instance()->project();
RimMainPlotCollection* mainPlotCollection = project ? project->mainPlotCollection() : NULL;
return mainPlotCollection ? mainPlotCollection->wellLogPlotCollection() : NULL;
}