mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-24 14:58:13 -06:00
Review follow-up for #15127: onProjectBeingSaved() returns false when the surface has data that could not be written, and saveProjectAs() then fails with a message naming the surface before the project file is written, so a write error no longer reports a successful save with the surface data lost.
66 lines
2.2 KiB
C++
66 lines
2.2 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2026- 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 "RimSurface.h"
|
|
|
|
#include "cafFilePath.h"
|
|
|
|
#include <memory>
|
|
|
|
class RigTriangleMeshData;
|
|
|
|
//==================================================================================================
|
|
/// Surface with geometry and properties set from scripting, saved as a GOCAD TSurf file next to the project file
|
|
//==================================================================================================
|
|
class RimTriangulatedSurface : public RimSurface
|
|
{
|
|
CAF_PDM_HEADER_INIT;
|
|
|
|
public:
|
|
RimTriangulatedSurface();
|
|
~RimTriangulatedSurface() override;
|
|
|
|
bool onLoadData() override;
|
|
RimSurface* createCopy() override;
|
|
|
|
void setGeometry( const std::vector<cvf::Vec3d>& vertices, const std::vector<unsigned>& triangleIndices );
|
|
void setProperty( const QString& key, const std::vector<float>& values );
|
|
|
|
size_t vertexCount() const;
|
|
std::vector<float> getProperty( const QString& key ) const;
|
|
std::vector<QString> propertyNames() const;
|
|
|
|
bool onProjectBeingSaved();
|
|
|
|
private:
|
|
bool updateSurfaceData() override;
|
|
void clearCachedNativeData() override;
|
|
|
|
bool loadDataFromFile();
|
|
QString fileNameInProjectFolder();
|
|
|
|
private:
|
|
caf::PdmField<caf::FilePath> m_surfaceFilePath;
|
|
caf::PdmField<QString> m_fileId;
|
|
|
|
std::unique_ptr<RigTriangleMeshData> m_triangleMeshData;
|
|
bool m_hasUnsavedChanges;
|
|
};
|