mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Renamed from polyline to polylines. Split into PolylinesFromFile and UserDefinedPolylines Add import of polylines from file
This commit is contained in:
@@ -123,7 +123,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimContourMapViewCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimContourMapNameConfig.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimScaleLegendConfig.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPolylineAnnotation.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPolylinesAnnotation.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimReachCircleAnnotation.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimTextAnnotation.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationInView.h
|
||||
@@ -255,7 +255,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimContourMapViewCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimContourMapNameConfig.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimScaleLegendConfig.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPolylineAnnotation.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPolylinesAnnotation.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimReachCircleAnnotation.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimTextAnnotation.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationInView.cpp
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 Ceetron AS
|
||||
// Copyright (C) 2018- equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
@@ -22,22 +20,16 @@
|
||||
|
||||
#include "RimTextAnnotation.h"
|
||||
#include "RimReachCircleAnnotation.h"
|
||||
#include "RimPolylineAnnotation.h"
|
||||
#include "RimPolylinesAnnotation.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
#include "RimGridView.h"
|
||||
#include "RimAnnotationInViewCollection.h"
|
||||
|
||||
#include "QMessageBox"
|
||||
#include <QString>
|
||||
|
||||
|
||||
namespace caf
|
||||
{
|
||||
// template<>
|
||||
// void RimWellPathCollection::WellVisibilityEnum::setUp()
|
||||
// {
|
||||
// addItem(RimWellPathCollection::FORCE_ALL_OFF, "FORCE_ALL_OFF", "Off");
|
||||
// addItem(RimWellPathCollection::ALL_ON, "ALL_ON", "Individual");
|
||||
// addItem(RimWellPathCollection::FORCE_ALL_ON, "FORCE_ALL_ON", "On");
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimAnnotationCollection, "RimAnnotationCollection");
|
||||
|
||||
@@ -49,11 +41,14 @@ RimAnnotationCollection::RimAnnotationCollection()
|
||||
CAF_PDM_InitObject("Annotations", ":/WellCollection.png", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_textAnnotations, "TextAnnotations", "Text Annotations", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_reachCircleAnnotations, "ReachCircleAnnotations", "Reach Circle Annotations", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_polylineAnnotations, "PolylineAnnotations", "Polyline Annotations", "", "", "");
|
||||
m_textAnnotations.uiCapability()->setUiHidden(true);
|
||||
CAF_PDM_InitFieldNoDefault(&m_reachCircleAnnotations, "ReachCircleAnnotations", "Reach Circle Annotations", "", "", "");
|
||||
m_reachCircleAnnotations.uiCapability()->setUiHidden(true);
|
||||
CAF_PDM_InitFieldNoDefault(&m_polylineAnnotations, "PolylineAnnotations", "Polyline Annotations", "", "", "");
|
||||
m_polylineAnnotations.uiCapability()->setUiHidden(true);
|
||||
CAF_PDM_InitFieldNoDefault(&m_polylineFromFileAnnotations, "PolylineFromFileAnnotations", "Polylines From File", "", "", "");
|
||||
m_polylineFromFileAnnotations.uiCapability()->setUiHidden(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +79,7 @@ void RimAnnotationCollection::addAnnotation(RimReachCircleAnnotation* annotation
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAnnotationCollection::addAnnotation(RimPolylineAnnotation* annotation)
|
||||
void RimAnnotationCollection::addAnnotation(RimPolylinesAnnotation* annotation)
|
||||
{
|
||||
m_polylineAnnotations.push_back(annotation);
|
||||
}
|
||||
@@ -108,7 +103,120 @@ std::vector<RimReachCircleAnnotation*> RimAnnotationCollection::reachCircleAnnot
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimPolylineAnnotation*> RimAnnotationCollection::polylineAnnotations() const
|
||||
std::vector<RimPolylinesAnnotation*> RimAnnotationCollection::polylineAnnotations() const
|
||||
{
|
||||
return m_polylineAnnotations.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimPolyLinesFromFileAnnotation*> RimAnnotationCollection::polylinesFromFileAnnotations() const
|
||||
{
|
||||
return m_polylineFromFileAnnotations.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPolyLinesFromFileAnnotation* RimAnnotationCollection::importOrUpdatePolylinesFromFile(const QStringList& fileNames)
|
||||
{
|
||||
QStringList newFileNames;
|
||||
std::vector<RimPolyLinesFromFileAnnotation*> polyLinesObjsToReload;
|
||||
size_t formationListBeforeImportCount = m_polylineFromFileAnnotations.size();
|
||||
|
||||
for(const QString& newFileName : fileNames)
|
||||
{
|
||||
bool isFound = false;
|
||||
for(RimPolyLinesFromFileAnnotation* polyLinesAnnot: m_polylineFromFileAnnotations)
|
||||
{
|
||||
if(polyLinesAnnot->fileName() == newFileName)
|
||||
{
|
||||
polyLinesObjsToReload.push_back(polyLinesAnnot);
|
||||
isFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isFound)
|
||||
{
|
||||
newFileNames.push_back(newFileName);
|
||||
}
|
||||
}
|
||||
|
||||
for(const QString& newFileName : newFileNames)
|
||||
{
|
||||
RimPolyLinesFromFileAnnotation* newPolyLinesAnnot = new RimPolyLinesFromFileAnnotation;
|
||||
newPolyLinesAnnot->setFileName(newFileName);
|
||||
m_polylineFromFileAnnotations.push_back(newPolyLinesAnnot);
|
||||
polyLinesObjsToReload.push_back(newPolyLinesAnnot);
|
||||
newPolyLinesAnnot->setDescriptionFromFileName();
|
||||
}
|
||||
|
||||
QString totalErrorMessage;
|
||||
|
||||
for (RimPolyLinesFromFileAnnotation* polyLinesAnnot: polyLinesObjsToReload)
|
||||
{
|
||||
QString errormessage;
|
||||
|
||||
polyLinesAnnot->readPolyLinesFile(&errormessage);
|
||||
if (!errormessage.isEmpty())
|
||||
{
|
||||
totalErrorMessage += "\nError in: " + polyLinesAnnot->fileName()
|
||||
+ "\n\t" + errormessage;
|
||||
}
|
||||
}
|
||||
|
||||
if (!totalErrorMessage.isEmpty())
|
||||
{
|
||||
QMessageBox::warning(nullptr, "Import Formation Names", totalErrorMessage);
|
||||
}
|
||||
|
||||
if (m_polylineFromFileAnnotations.size() > formationListBeforeImportCount)
|
||||
{
|
||||
return m_polylineFromFileAnnotations[m_polylineFromFileAnnotations.size() - 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAnnotationCollection::scheduleRedrawOfRelevantViews()
|
||||
{
|
||||
// Todo: Do a Bounding Box check to see if this annotation actually is relevant for the view
|
||||
|
||||
auto views = gridViewsContainingAnnotations();
|
||||
if ( !views.empty() )
|
||||
{
|
||||
for ( auto& view : views )
|
||||
{
|
||||
view->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimGridView*> RimAnnotationCollection::gridViewsContainingAnnotations() const
|
||||
{
|
||||
std::vector<RimGridView*> views;
|
||||
RimProject* project = nullptr;
|
||||
this->firstAncestorOrThisOfType(project);
|
||||
|
||||
if (!project) return views;
|
||||
|
||||
std::vector<RimGridView*> visibleGridViews;
|
||||
project->allVisibleGridViews(visibleGridViews);
|
||||
|
||||
for (auto& gridView : visibleGridViews)
|
||||
{
|
||||
if (gridView->annotationCollection()->isActive()) views.push_back(gridView);
|
||||
}
|
||||
return views;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 Ceetron AS
|
||||
// Copyright (C) 2018- equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
@@ -26,19 +24,13 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPointer.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
// Include to make Pdm work for cvf::Color
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmChildField.h"
|
||||
|
||||
#include "cvfObject.h"
|
||||
|
||||
class QString;
|
||||
class RimTextAnnotation;
|
||||
class RimReachCircleAnnotation;
|
||||
class RimPolylineAnnotation;
|
||||
|
||||
class RimPolylinesAnnotation;
|
||||
class RimPolyLinesFromFileAnnotation;
|
||||
class RimGridView;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -53,14 +45,20 @@ public:
|
||||
|
||||
void addAnnotation(RimTextAnnotation* annotation);
|
||||
void addAnnotation(RimReachCircleAnnotation* annotation);
|
||||
void addAnnotation(RimPolylineAnnotation* annotation);
|
||||
void addAnnotation(RimPolylinesAnnotation* annotation);
|
||||
|
||||
std::vector<RimTextAnnotation*> textAnnotations() const;
|
||||
std::vector<RimReachCircleAnnotation*> reachCircleAnnotations() const;
|
||||
std::vector<RimPolylineAnnotation*> polylineAnnotations() const;
|
||||
std::vector<RimTextAnnotation*> textAnnotations() const;
|
||||
std::vector<RimReachCircleAnnotation*> reachCircleAnnotations() const;
|
||||
std::vector<RimPolylinesAnnotation*> polylineAnnotations() const;
|
||||
std::vector<RimPolyLinesFromFileAnnotation*> polylinesFromFileAnnotations() const;
|
||||
|
||||
RimPolyLinesFromFileAnnotation* importOrUpdatePolylinesFromFile(const QStringList& fileNames );
|
||||
void scheduleRedrawOfRelevantViews();
|
||||
std::vector<RimGridView*> gridViewsContainingAnnotations() const;
|
||||
|
||||
private:
|
||||
caf::PdmChildArrayField<RimTextAnnotation*> m_textAnnotations;
|
||||
caf::PdmChildArrayField<RimReachCircleAnnotation*> m_reachCircleAnnotations;
|
||||
caf::PdmChildArrayField<RimPolylineAnnotation*> m_polylineAnnotations;
|
||||
caf::PdmChildArrayField<RimTextAnnotation*> m_textAnnotations;
|
||||
caf::PdmChildArrayField<RimReachCircleAnnotation*> m_reachCircleAnnotations;
|
||||
caf::PdmChildArrayField<RimPolylinesAnnotation*> m_polylineAnnotations;
|
||||
caf::PdmChildArrayField<RimPolyLinesFromFileAnnotation*> m_polylineFromFileAnnotations;
|
||||
};
|
||||
|
||||
@@ -682,6 +682,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
}
|
||||
else if (dynamic_cast<RimAnnotationCollection*>(uiItem))
|
||||
{
|
||||
menuBuilder << "RicImportPolylinesAnnotationFeature";
|
||||
menuBuilder << "RicNewTextAnnotationFeature";
|
||||
menuBuilder << "RicNewReachCircleAnnotationFeature";
|
||||
menuBuilder << "RicNewPolygonAnnotationFeature";
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 Ceetron 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPointer.h"
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmUiOrdering.h"
|
||||
|
||||
// Include to make Pdm work for cvf::Color
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmFieldCvfVec3d.h"
|
||||
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class QString;
|
||||
class RimGridView;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimPolylineAnnotation : public caf::PdmObject
|
||||
{
|
||||
using Vec3d = cvf::Vec3d;
|
||||
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimPolylineAnnotation();
|
||||
~RimPolylineAnnotation();
|
||||
|
||||
void setPoints(const std::vector<Vec3d>& points);
|
||||
const std::vector<Vec3d>& points() const;
|
||||
|
||||
protected:
|
||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
private:
|
||||
std::vector<RimGridView*> gridViewsContainingAnnotations() const;
|
||||
|
||||
private:
|
||||
caf::PdmField<std::vector<Vec3d>> m_points;
|
||||
};
|
||||
278
ApplicationCode/ProjectDataModel/RimPolylinesAnnotation.cpp
Normal file
278
ApplicationCode/ProjectDataModel/RimPolylinesAnnotation.cpp
Normal file
@@ -0,0 +1,278 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- equinor ASA
|
||||
//
|
||||
// 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 "RimPolylinesAnnotation.h"
|
||||
|
||||
#include "RimAnnotationInViewCollection.h"
|
||||
#include "RimGridView.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimTools.h"
|
||||
#include "QFile"
|
||||
#include "RimAnnotationCollection.h"
|
||||
#include "QFileInfo"
|
||||
|
||||
CAF_PDM_ABSTRACT_SOURCE_INIT(RimPolylinesAnnotation, "RimPolylinesAnnotation");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPolylinesAnnotation::RimPolylinesAnnotation()
|
||||
{
|
||||
CAF_PDM_InitObject("PolylineAnnotation", ":/WellCollection.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_isActive, "IsActive", true, "Is Active", "", "", "");
|
||||
m_isActive.uiCapability()->setUiHidden(true);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPolylinesAnnotation::~RimPolylinesAnnotation()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimPolylinesAnnotation::objectToggleField()
|
||||
{
|
||||
return &m_isActive;
|
||||
}
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimUserDefinedPolyLinesAnnotation, "UserDefinedPolyLinesAnnotation");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimUserDefinedPolyLinesAnnotation::RimUserDefinedPolyLinesAnnotation()
|
||||
{
|
||||
CAF_PDM_InitObject("PolyLines Annotation", ":/WellCollection.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_points, "Points", {}, "", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimUserDefinedPolyLinesAnnotation::~RimUserDefinedPolyLinesAnnotation()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RigPolyLinesData> RimUserDefinedPolyLinesAnnotation::polyLinesData()
|
||||
{
|
||||
cvf::ref<RigPolyLinesData> pld = new RigPolyLinesData;
|
||||
std::vector<std::vector<cvf::Vec3d> > lines;
|
||||
lines.push_back(m_points());
|
||||
pld->setPolyLines(lines);
|
||||
|
||||
return pld;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimUserDefinedPolyLinesAnnotation::isEmpty()
|
||||
{
|
||||
return m_points().empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUserDefinedPolyLinesAnnotation::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
uiOrdering.add(&m_points);
|
||||
|
||||
uiOrdering.skipRemainingFields(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUserDefinedPolyLinesAnnotation::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
RimAnnotationCollection* annColl = nullptr;
|
||||
this->firstAncestorOrThisOfType(annColl);
|
||||
if (annColl)
|
||||
{
|
||||
annColl->scheduleRedrawOfRelevantViews();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimPolyLinesFromFileAnnotation, "PolyLinesFromFileAnnotation");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPolyLinesFromFileAnnotation::RimPolyLinesFromFileAnnotation()
|
||||
{
|
||||
CAF_PDM_InitObject("PolyLines Annotation", ":/WellCollection.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_polyLinesFileName, "PolyLineFilePath", QString(""), "File Path", "", "", "");
|
||||
m_polyLinesFileName.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
CAF_PDM_InitField(&m_userDescription, "PolyLineDescription", QString(""), "Name", "", "", "");
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPolyLinesFromFileAnnotation::~RimPolyLinesFromFileAnnotation()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPolyLinesFromFileAnnotation::setFileName(const QString& fileName)
|
||||
{
|
||||
m_polyLinesFileName = fileName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const QString& RimPolyLinesFromFileAnnotation::fileName()
|
||||
{
|
||||
return m_polyLinesFileName();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPolyLinesFromFileAnnotation::readPolyLinesFile(QString * errorMessage)
|
||||
{
|
||||
QFile dataFile(m_polyLinesFileName());
|
||||
|
||||
if (!dataFile.open(QFile::ReadOnly))
|
||||
{
|
||||
if (errorMessage) (*errorMessage) += "Could not open the File: " + (m_polyLinesFileName()) + "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
m_polyLinesData = new RigPolyLinesData;
|
||||
|
||||
std::vector< std::vector< cvf::Vec3d > > polylines(1);
|
||||
|
||||
QTextStream stream(&dataFile);
|
||||
int lineNumber = 1;
|
||||
while (!stream.atEnd())
|
||||
{
|
||||
QString line = stream.readLine();
|
||||
QStringList commentLineSegs = line.split("#", QString::KeepEmptyParts);
|
||||
if(commentLineSegs.size() == 0) continue; // Empty line
|
||||
|
||||
|
||||
QStringList lineSegs = commentLineSegs[0].split(QRegExp("\\s+"), QString::SkipEmptyParts);
|
||||
|
||||
if(lineSegs.size() == 0) continue; // No data
|
||||
if(lineSegs.size() != 3)
|
||||
{
|
||||
if (errorMessage) (*errorMessage) += "Unexpected number of words on line: " + QString::number(lineNumber) + "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lineSegs.size() == 3) // Normal case
|
||||
{
|
||||
bool isNumberParsingOk = true;
|
||||
bool isOk = true;
|
||||
double x = lineSegs[0].toDouble(&isOk); isNumberParsingOk &= isOk;
|
||||
double y = lineSegs[1].toDouble(&isOk); isNumberParsingOk &= isOk;
|
||||
double z = lineSegs[2].toDouble(&isOk); isNumberParsingOk &= isOk;
|
||||
|
||||
if (!isNumberParsingOk)
|
||||
{
|
||||
if (errorMessage) (*errorMessage) += "Could not read the point at line: " + QString::number(lineNumber) + "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (x == 999.0 && y == 999.0 && z == 999.0) // New PolyLine
|
||||
{
|
||||
polylines.push_back(std::vector<cvf::Vec3d>());
|
||||
continue;
|
||||
}
|
||||
|
||||
cvf::Vec3d point(x, y, -z);
|
||||
polylines.back().push_back(point);
|
||||
|
||||
}
|
||||
|
||||
++lineNumber;
|
||||
}
|
||||
|
||||
if ( polylines.back().empty() )
|
||||
{
|
||||
polylines.pop_back();
|
||||
}
|
||||
|
||||
m_polyLinesData->setPolyLines(polylines);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimPolyLinesFromFileAnnotation::isEmpty()
|
||||
{
|
||||
bool isThisEmpty = true;
|
||||
for (const std::vector<cvf::Vec3d> & line :m_polyLinesData->polyLines())
|
||||
{
|
||||
if (!line.empty()) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPolyLinesFromFileAnnotation::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath)
|
||||
{
|
||||
m_polyLinesFileName = RimTools::relocateFile(m_polyLinesFileName(), newProjectPath, oldProjectPath, nullptr, nullptr);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPolyLinesFromFileAnnotation::setDescriptionFromFileName()
|
||||
{
|
||||
QFileInfo fileInfo(m_polyLinesFileName());
|
||||
m_userDescription = fileInfo.fileName();
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimPolyLinesFromFileAnnotation::userDescriptionField()
|
||||
{
|
||||
return &m_userDescription;
|
||||
}
|
||||
139
ApplicationCode/ProjectDataModel/RimPolylinesAnnotation.h
Normal file
139
ApplicationCode/ProjectDataModel/RimPolylinesAnnotation.h
Normal file
@@ -0,0 +1,139 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- equinor ASA
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPointer.h"
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmUiOrdering.h"
|
||||
|
||||
// Include to make Pdm work for cvf::Color
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmFieldCvfVec3d.h"
|
||||
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class QString;
|
||||
class RimGridView;
|
||||
class RigPolyLinesData;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimPolylinesAnnotation : public caf::PdmObject
|
||||
{
|
||||
using Vec3d = cvf::Vec3d;
|
||||
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimPolylinesAnnotation();
|
||||
~RimPolylinesAnnotation();
|
||||
|
||||
virtual cvf::ref<RigPolyLinesData> polyLinesData() = 0;
|
||||
virtual bool isEmpty() = 0;
|
||||
|
||||
protected:
|
||||
virtual caf::PdmFieldHandle* objectToggleField() override;
|
||||
|
||||
private:
|
||||
caf::PdmField<std::vector<Vec3d>> m_points;
|
||||
caf::PdmField<bool> m_isActive;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
class RimUserDefinedPolyLinesAnnotation : public RimPolylinesAnnotation
|
||||
{
|
||||
using Vec3d = cvf::Vec3d;
|
||||
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
RimUserDefinedPolyLinesAnnotation();
|
||||
~RimUserDefinedPolyLinesAnnotation();
|
||||
|
||||
cvf::ref<RigPolyLinesData> polyLinesData() override;
|
||||
virtual bool isEmpty() override;
|
||||
|
||||
protected:
|
||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<std::vector<Vec3d>> m_points;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
|
||||
class RimPolyLinesFromFileAnnotation : public RimPolylinesAnnotation
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
RimPolyLinesFromFileAnnotation();
|
||||
~RimPolyLinesFromFileAnnotation();
|
||||
|
||||
void setFileName(const QString& fileName);
|
||||
const QString& fileName();
|
||||
void readPolyLinesFile(QString * errorMessage);
|
||||
|
||||
|
||||
cvf::ref<RigPolyLinesData> polyLinesData() override { return m_polyLinesData;}
|
||||
virtual bool isEmpty() override;
|
||||
|
||||
void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath);
|
||||
void setDescriptionFromFileName();
|
||||
|
||||
private:
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
caf::PdmField<QString> m_userDescription;
|
||||
caf::PdmField<QString> m_polyLinesFileName;
|
||||
cvf::ref<RigPolyLinesData> m_polyLinesData;
|
||||
};
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RigPolyLinesData : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RigPolyLinesData() {}
|
||||
|
||||
const std::vector<std::vector<cvf::Vec3d> >& polyLines() const { return m_polylines;}
|
||||
void setPolyLines(const std::vector<std::vector<cvf::Vec3d> >& polyLines) { m_polylines = polyLines;}
|
||||
|
||||
private:
|
||||
std::vector<std::vector<cvf::Vec3d> > m_polylines;
|
||||
};
|
||||
@@ -31,6 +31,8 @@
|
||||
#include "RigGridBase.h"
|
||||
|
||||
#include "RimAnnotationCollection.h"
|
||||
#include "RimPolylinesAnnotation.h"
|
||||
|
||||
#include "RimCalcScript.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimCaseCollection.h"
|
||||
@@ -995,9 +997,9 @@ std::vector<RimReachCircleAnnotation*> RimProject::reachCircleAnnotations() cons
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimPolylineAnnotation*> RimProject::polylineAnnotations() const
|
||||
std::vector<RimPolylinesAnnotation*> RimProject::polylineAnnotations() const
|
||||
{
|
||||
std::vector<RimPolylineAnnotation*> annotations;
|
||||
std::vector<RimPolylinesAnnotation*> annotations;
|
||||
for (const auto& oilField : oilFields())
|
||||
{
|
||||
auto annotationColl = oilField->annotationCollection();
|
||||
@@ -1005,6 +1007,12 @@ std::vector<RimPolylineAnnotation*> RimProject::polylineAnnotations() const
|
||||
{
|
||||
annotations.push_back(annotation);
|
||||
}
|
||||
|
||||
for (const auto& annotation : annotationColl->polylinesFromFileAnnotations())
|
||||
{
|
||||
annotations.push_back(annotation);
|
||||
}
|
||||
|
||||
}
|
||||
return annotations;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class RigWellPath;
|
||||
|
||||
class RimTextAnnotation;
|
||||
class RimReachCircleAnnotation;
|
||||
class RimPolylineAnnotation;
|
||||
class RimPolylinesAnnotation;
|
||||
class RimSummaryCalculationCollection;
|
||||
class RimCase;
|
||||
class RimCommandObject;
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
std::vector<RimWellPath*> allWellPaths() const;
|
||||
std::vector<RimTextAnnotation*> textAnnotations() const;
|
||||
std::vector<RimReachCircleAnnotation*> reachCircleAnnotations() const;
|
||||
std::vector<RimPolylineAnnotation*> polylineAnnotations() const;
|
||||
std::vector<RimPolylinesAnnotation*> polylineAnnotations() const;
|
||||
|
||||
std::vector<RimGeoMechCase*> geoMechCases() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user