#3724 Split the line annotation classes into separate files. Cleaned up includes

This commit is contained in:
Jacob Støren 2018-11-28 12:07:39 +01:00
parent c3dd6a14a7
commit 0f384cf4f7
19 changed files with 507 additions and 363 deletions

View File

@ -22,7 +22,7 @@
#include "RimTextAnnotation.h"
#include "RimReachCircleAnnotation.h"
#include "RimPolylinesAnnotation.h"
#include "RimUserDefinedPolylinesAnnotation.h"
#include "RimAnnotationCollection.h"
#include "RimAnnotationInViewCollection.h"
#include "RimProject.h"

View File

@ -23,7 +23,7 @@
#include "RimOilField.h"
#include "RimProject.h"
#include "RimAnnotationCollection.h"
#include "RimPolylinesAnnotation.h"
#include "RimPolylinesFromFileAnnotation.h"
#include "Riu3DMainWindowTools.h"

View File

@ -21,10 +21,15 @@
#include "RimAnnotationCollection.h"
#include "RimPolylinesAnnotation.h"
#include "RimAnnotationInViewCollection.h"
#include "RimAnnotationLineAppearance.h"
#include "RigPolyLinesData.h"
#include "RivPolylineGenerator.h"
#include "RivPartPriority.h"
#include "RivPolylinesAnnotationSourceInfo.h"
#include "cafEffectGenerator.h"
#include "cvfDrawableGeo.h"

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, 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
@ -48,7 +48,6 @@ public:
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform * displayXf);
private:
void buildPolylineAnnotationParts(const caf::DisplayCoordTransform* displayXf);

View File

@ -3,6 +3,8 @@ set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationCollectionBase.h
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimPolylinesAnnotation.h
${CMAKE_CURRENT_LIST_DIR}/RimPolylinesFromFileAnnotation.h
${CMAKE_CURRENT_LIST_DIR}/RimUserDefinedPolylinesAnnotation.h
${CMAKE_CURRENT_LIST_DIR}/RimReachCircleAnnotation.h
${CMAKE_CURRENT_LIST_DIR}/RimTextAnnotation.h
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationInViewCollection.h
@ -14,6 +16,8 @@ set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationCollectionBase.cpp
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolylinesAnnotation.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolylinesFromFileAnnotation.cpp
${CMAKE_CURRENT_LIST_DIR}/RimUserDefinedPolylinesAnnotation.cpp
${CMAKE_CURRENT_LIST_DIR}/RimReachCircleAnnotation.cpp
${CMAKE_CURRENT_LIST_DIR}/RimTextAnnotation.cpp
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationInViewCollection.cpp

View File

@ -22,7 +22,7 @@
#include "RimTextAnnotation.h"
#include "RimReachCircleAnnotation.h"
#include "RimPolylinesAnnotation.h"
#include "RimPolylinesFromFileAnnotation.h"
#include "RimProject.h"
#include "RimGridView.h"

View File

@ -18,21 +18,12 @@
#pragma once
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafPdmField.h"
#include "cafAppEnum.h"
#include "cafPdmUiOrdering.h"
// Include to make Pdm work for cvf::Color
#include "cafPdmFieldCvfColor.h"
#include "cafPdmChildField.h"
#include "cvfObject.h"
class QString;
class RimGridView;
//==================================================================================================

View File

@ -18,6 +18,8 @@
#include "RimLineBasedAnnotation.h"
#include "RimAnnotationLineAppearance.h"
CAF_PDM_SOURCE_INIT(RimLineBasedAnnotation, "RimLineBasedAnnotation");

View File

@ -18,28 +18,12 @@
#pragma once
#include "RimAnnotationLineAppearance.h"
#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 RimAnnotationLineAppearance;
//==================================================================================================
///

View File

@ -64,241 +64,5 @@ 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);
auto appearanceGroup = uiOrdering.addNewGroup("Line Appearance");
appearance()->uiOrdering(uiConfigName, *appearanceGroup);
uiOrdering.skipRemainingFields(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUserDefinedPolylinesAnnotation::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue)
{
RimAnnotationCollection* annColl = nullptr;
this->firstAncestorOrThisOfTypeAsserted(annColl);
annColl->scheduleRedrawOfRelevantViews();
}
#include "cafPdmUiFilePathEditor.h"
CAF_PDM_SOURCE_INIT(RimPolylinesFromFileAnnotation, "PolylinesFromFileAnnotation");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolylinesFromFileAnnotation::RimPolylinesFromFileAnnotation()
{
CAF_PDM_InitObject("PolyLines Annotation", ":/WellCollection.png", "", "");
CAF_PDM_InitFieldNoDefault(&m_polyLinesFileName, "PolyLineFilePath", "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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimPolylinesFromFileAnnotation::fileName() const
{
return m_polyLinesFileName().path();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolylinesFromFileAnnotation::readPolyLinesFile(QString * errorMessage)
{
QFile dataFile(m_polyLinesFileName().path());
if (!dataFile.open(QFile::ReadOnly))
{
if (errorMessage) (*errorMessage) += "Could not open the File: " + (m_polyLinesFileName().path()) + "\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()
{
if (m_polyLinesData.isNull()) return true;
for (const std::vector<cvf::Vec3d> & line :m_polyLinesData->polyLines())
{
if (!line.empty()) return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolylinesFromFileAnnotation::setDescriptionFromFileName()
{
QFileInfo fileInfo(m_polyLinesFileName().path());
m_userDescription = fileInfo.fileName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolylinesFromFileAnnotation::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_polyLinesFileName);
auto appearanceGroup = uiOrdering.addNewGroup("Line Appearance");
appearance()->uiOrdering(uiConfigName, *appearanceGroup);
uiOrdering.skipRemainingFields(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolylinesFromFileAnnotation::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue)
{
RimAnnotationCollection* annColl = nullptr;
this->firstAncestorOrThisOfTypeAsserted(annColl);
annColl->scheduleRedrawOfRelevantViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimPolylinesFromFileAnnotation::userDescriptionField()
{
return &m_userDescription;
}

View File

@ -19,25 +19,12 @@
#pragma once
#include "RimLineBasedAnnotation.h"
#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 "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include <vector>
class QString;
class RimGridView;
class RigPolyLinesData;
//==================================================================================================
@ -46,8 +33,6 @@ class RigPolyLinesData;
//==================================================================================================
class RimPolylinesAnnotation : public RimLineBasedAnnotation
{
using Vec3d = cvf::Vec3d;
CAF_PDM_HEADER_INIT;
public:
@ -65,79 +50,3 @@ protected:
private:
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);
QString fileName() const;
void readPolyLinesFile(QString * errorMessage);
cvf::ref<RigPolyLinesData> polyLinesData() override { return m_polyLinesData;}
virtual bool isEmpty() override;
void setDescriptionFromFileName();
protected:
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
private:
virtual caf::PdmFieldHandle* userDescriptionField() override;
caf::PdmField<QString> m_userDescription;
caf::PdmField<caf::FilePath> 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;
};

View File

@ -0,0 +1,208 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolylinesFromFileAnnotation.h"
#include "RimAnnotationCollection.h"
#include "RimAnnotationLineAppearance.h"
#include "RigPolyLinesData.h"
#include "cafPdmUiFilePathEditor.h"
#include <QFile>
#include <QFileInfo>
CAF_PDM_SOURCE_INIT(RimPolylinesFromFileAnnotation, "PolylinesFromFileAnnotation");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPolylinesFromFileAnnotation::RimPolylinesFromFileAnnotation()
{
CAF_PDM_InitObject("PolyLines Annotation", ":/WellCollection.png", "", "");
CAF_PDM_InitFieldNoDefault(&m_polyLinesFileName, "PolyLineFilePath", "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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimPolylinesFromFileAnnotation::fileName() const
{
return m_polyLinesFileName().path();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolylinesFromFileAnnotation::readPolyLinesFile(QString * errorMessage)
{
QFile dataFile(m_polyLinesFileName().path());
if (!dataFile.open(QFile::ReadOnly))
{
if (errorMessage) (*errorMessage) += "Could not open the File: " + (m_polyLinesFileName().path()) + "\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);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigPolyLinesData> RimPolylinesFromFileAnnotation::polyLinesData()
{
return m_polyLinesData;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPolylinesFromFileAnnotation::isEmpty()
{
if (m_polyLinesData.isNull()) return true;
for (const std::vector<cvf::Vec3d> & line :m_polyLinesData->polyLines())
{
if (!line.empty()) return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolylinesFromFileAnnotation::setDescriptionFromFileName()
{
QFileInfo fileInfo(m_polyLinesFileName().path());
m_userDescription = fileInfo.fileName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolylinesFromFileAnnotation::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_polyLinesFileName);
auto appearanceGroup = uiOrdering.addNewGroup("Line Appearance");
appearance()->uiOrdering(uiConfigName, *appearanceGroup);
uiOrdering.skipRemainingFields(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPolylinesFromFileAnnotation::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue)
{
RimAnnotationCollection* annColl = nullptr;
this->firstAncestorOrThisOfTypeAsserted(annColl);
annColl->scheduleRedrawOfRelevantViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimPolylinesFromFileAnnotation::userDescriptionField()
{
return &m_userDescription;
}

View File

@ -0,0 +1,53 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolylinesAnnotation.h"
class RimPolylinesFromFileAnnotation : public RimPolylinesAnnotation
{
CAF_PDM_HEADER_INIT;
public:
RimPolylinesFromFileAnnotation();
~RimPolylinesFromFileAnnotation();
void setFileName(const QString& fileName);
QString fileName() const;
void readPolyLinesFile(QString * errorMessage);
cvf::ref<RigPolyLinesData> polyLinesData() override;
virtual bool isEmpty() override;
void setDescriptionFromFileName();
protected:
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
private:
virtual caf::PdmFieldHandle* userDescriptionField() override;
caf::PdmField<QString> m_userDescription;
caf::PdmField<caf::FilePath> m_polyLinesFileName;
cvf::ref<RigPolyLinesData> m_polyLinesData;
};

View File

@ -0,0 +1,93 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimUserDefinedPolylinesAnnotation.h"
#include "RimAnnotationCollection.h"
#include "RimAnnotationLineAppearance.h"
#include "RigPolyLinesData.h"
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);
auto appearanceGroup = uiOrdering.addNewGroup("Line Appearance");
appearance()->uiOrdering(uiConfigName, *appearanceGroup);
uiOrdering.skipRemainingFields(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUserDefinedPolylinesAnnotation::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue)
{
RimAnnotationCollection* annColl = nullptr;
this->firstAncestorOrThisOfTypeAsserted(annColl);
annColl->scheduleRedrawOfRelevantViews();
}

View File

@ -0,0 +1,49 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimPolylinesAnnotation.h"
#include "cafPdmFieldCvfVec3d.h"
//==================================================================================================
///
///
//==================================================================================================
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;
};

View File

@ -32,7 +32,7 @@
#include "RimAnnotationCollection.h"
#include "RimAnnotationInViewCollection.h"
#include "RimPolylinesAnnotation.h"
#include "RimPolylinesFromFileAnnotation.h"
#include "RimCalcScript.h"
#include "RimCase.h"
#include "RimCaseCollection.h"

View File

@ -65,6 +65,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigWellResultPoint.h
${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryTools.h
${CMAKE_CURRENT_LIST_DIR}/RigCaseRealizationParameters.h
${CMAKE_CURRENT_LIST_DIR}/RigGeoMechBoreHoleStressCalculator.h
${CMAKE_CURRENT_LIST_DIR}/RigPolyLinesData.h
)
@ -129,6 +130,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RigWellResultPoint.cpp
${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RigCaseRealizationParameters.cpp
${CMAKE_CURRENT_LIST_DIR}/RigGeoMechBoreHoleStressCalculator.cpp
${CMAKE_CURRENT_LIST_DIR}/RigPolyLinesData.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,37 @@
#include "RigPolyLinesData.h"
#include "RigPolyLinesData.h"
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RigPolyLinesData.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigPolyLinesData::RigPolyLinesData()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigPolyLinesData::~RigPolyLinesData()
{
}

View File

@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include <vector>
//==================================================================================================
///
///
//==================================================================================================
class RigPolyLinesData : public cvf::Object
{
public:
RigPolyLinesData();
~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;
};