-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
311 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonCsvFeature.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright (C) 2024 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 "RicExportPolygonCsvFeature.h" | ||
|
||
#include "RiaGuiApplication.h" | ||
#include "RiaLogging.h" | ||
|
||
#include "Polygons/RimPolygon.h" | ||
#include "Polygons/RimPolygonInView.h" | ||
#include "Polygons/RimPolygonTools.h" | ||
|
||
#include "RiuFileDialogTools.h" | ||
|
||
#include "cafSelectionManager.h" | ||
|
||
#include <QAction> | ||
#include <QFileInfo> | ||
|
||
CAF_CMD_SOURCE_INIT( RicExportPolygonCsvFeature, "RicExportPolygonCsvFeature" ); | ||
|
||
//-------------------------------------------------------------------------------------------------- | ||
/// | ||
//-------------------------------------------------------------------------------------------------- | ||
void RicExportPolygonCsvFeature::onActionTriggered( bool isChecked ) | ||
{ | ||
auto sourcePolygon = caf::SelectionManager::instance()->selectedItemOfType<RimPolygon>(); | ||
if ( !sourcePolygon ) | ||
{ | ||
auto sourcePolygonInView = caf::SelectionManager::instance()->selectedItemOfType<RimPolygonInView>(); | ||
if ( sourcePolygonInView ) | ||
{ | ||
sourcePolygon = sourcePolygonInView->polygon(); | ||
} | ||
} | ||
|
||
if ( !sourcePolygon ) return; | ||
|
||
auto app = RiaGuiApplication::instance(); | ||
auto fallbackPath = app->lastUsedDialogDirectory( "BINARY_GRID" ); | ||
auto polygonPath = app->lastUsedDialogDirectoryWithFallback( RimPolygonTools::polygonCacheName(), fallbackPath ); | ||
auto polygonFileName = polygonPath + "/" + sourcePolygon->name() + ".csv"; | ||
|
||
auto fileName = RiuFileDialogTools::getSaveFileName( nullptr, | ||
"Select File for Polygon Export to CSV", | ||
polygonFileName, | ||
"CSV Files (*.csv);;All files(*.*)" ); | ||
|
||
if ( !RimPolygonTools::exportPolygonCsv( sourcePolygon, fileName ) ) | ||
{ | ||
RiaLogging::error( "Failed to export polygon to " + fileName ); | ||
} | ||
|
||
RiaLogging::info( "Completed polygon export to " + fileName ); | ||
RiaApplication::instance()->setLastUsedDialogDirectory( RimPolygonTools::polygonCacheName(), QFileInfo( fileName ).absolutePath() ); | ||
} | ||
|
||
//-------------------------------------------------------------------------------------------------- | ||
/// | ||
//-------------------------------------------------------------------------------------------------- | ||
void RicExportPolygonCsvFeature::setupActionLook( QAction* actionToSetup ) | ||
{ | ||
actionToSetup->setText( "Export Polygon CSV" ); | ||
actionToSetup->setIcon( QIcon( ":/Save.svg" ) ); | ||
} |
33 changes: 33 additions & 0 deletions
33
ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonCsvFeature.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright (C) 2024 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 "cafCmdFeature.h" | ||
|
||
//================================================================================================== | ||
/// | ||
//================================================================================================== | ||
class RicExportPolygonCsvFeature : public caf::CmdFeature | ||
{ | ||
CAF_CMD_HEADER_INIT; | ||
|
||
protected: | ||
void onActionTriggered( bool isChecked ) override; | ||
void setupActionLook( QAction* actionToSetup ) override; | ||
}; |
80 changes: 80 additions & 0 deletions
80
ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonPolFeature.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright (C) 2024 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 "RicExportPolygonPolFeature.h" | ||
|
||
#include "RiaGuiApplication.h" | ||
#include "RiaLogging.h" | ||
|
||
#include "Polygons/RimPolygon.h" | ||
#include "Polygons/RimPolygonInView.h" | ||
#include "Polygons/RimPolygonTools.h" | ||
|
||
#include "RiuFileDialogTools.h" | ||
|
||
#include "cafSelectionManager.h" | ||
|
||
#include <QAction> | ||
#include <QFileInfo> | ||
|
||
CAF_CMD_SOURCE_INIT( RicExportPolygonPolFeature, "RicExportPolygonPolFeature" ); | ||
|
||
//-------------------------------------------------------------------------------------------------- | ||
/// | ||
//-------------------------------------------------------------------------------------------------- | ||
void RicExportPolygonPolFeature::onActionTriggered( bool isChecked ) | ||
{ | ||
auto sourcePolygon = caf::SelectionManager::instance()->selectedItemOfType<RimPolygon>(); | ||
if ( !sourcePolygon ) | ||
{ | ||
auto sourcePolygonInView = caf::SelectionManager::instance()->selectedItemOfType<RimPolygonInView>(); | ||
if ( sourcePolygonInView ) | ||
{ | ||
sourcePolygon = sourcePolygonInView->polygon(); | ||
} | ||
} | ||
|
||
if ( !sourcePolygon ) return; | ||
|
||
auto app = RiaGuiApplication::instance(); | ||
auto fallbackPath = app->lastUsedDialogDirectory( "BINARY_GRID" ); | ||
auto polygonPath = app->lastUsedDialogDirectoryWithFallback( RimPolygonTools::polygonCacheName(), fallbackPath ); | ||
auto polygonFileName = polygonPath + "/" + sourcePolygon->name() + ".pol"; | ||
|
||
auto fileName = RiuFileDialogTools::getSaveFileName( nullptr, | ||
"Select File for Polygon Export to POL", | ||
polygonFileName, | ||
"POL Files (*.pol);;All files(*.*)" ); | ||
|
||
if ( !RimPolygonTools::exportPolygonPol( sourcePolygon, fileName ) ) | ||
{ | ||
RiaLogging::error( "Failed to export polygon to " + fileName ); | ||
} | ||
|
||
RiaLogging::info( "Completed polygon export to " + fileName ); | ||
RiaApplication::instance()->setLastUsedDialogDirectory( RimPolygonTools::polygonCacheName(), QFileInfo( fileName ).absolutePath() ); | ||
} | ||
|
||
//-------------------------------------------------------------------------------------------------- | ||
/// | ||
//-------------------------------------------------------------------------------------------------- | ||
void RicExportPolygonPolFeature::setupActionLook( QAction* actionToSetup ) | ||
{ | ||
actionToSetup->setText( "Export Polygon POL" ); | ||
actionToSetup->setIcon( QIcon( ":/Save.svg" ) ); | ||
} |
33 changes: 33 additions & 0 deletions
33
ApplicationLibCode/Commands/PolygonCommands/RicExportPolygonPolFeature.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright (C) 2024 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 "cafCmdFeature.h" | ||
|
||
//================================================================================================== | ||
/// | ||
//================================================================================================== | ||
class RicExportPolygonPolFeature : public caf::CmdFeature | ||
{ | ||
CAF_CMD_HEADER_INIT; | ||
|
||
protected: | ||
void onActionTriggered( bool isChecked ) override; | ||
void setupActionLook( QAction* actionToSetup ) override; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters