-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import of AICD valve definition from text file
* Add readKeywordContentFromFile * Add import of AICD values from Completor and Eclipse
- Loading branch information
Showing
14 changed files
with
464 additions
and
89 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
100 changes: 100 additions & 0 deletions
100
ApplicationLibCode/Commands/CompletionCommands/RicImportValveTemplatesFeature.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,100 @@ | ||
///////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright (C) 2023- 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 "RicImportValveTemplatesFeature.h" | ||
|
||
#include "RiaApplication.h" | ||
#include "RiaLogging.h" | ||
#include "RiaOpmParserTools.h" | ||
|
||
#include "RimProject.h" | ||
#include "RimValveTemplate.h" | ||
#include "RimValveTemplateCollection.h" | ||
|
||
#include "Riu3DMainWindowTools.h" | ||
#include "RiuFileDialogTools.h" | ||
|
||
#include <QAction> | ||
|
||
CAF_CMD_SOURCE_INIT( RicImportValveTemplatesFeature, "RicImportValveTemplatesFeature" ); | ||
|
||
//-------------------------------------------------------------------------------------------------- | ||
/// | ||
//-------------------------------------------------------------------------------------------------- | ||
bool RicImportValveTemplatesFeature::isCommandEnabled() const | ||
{ | ||
return true; | ||
} | ||
|
||
//-------------------------------------------------------------------------------------------------- | ||
/// | ||
//-------------------------------------------------------------------------------------------------- | ||
void RicImportValveTemplatesFeature::onActionTriggered( bool isChecked ) | ||
{ | ||
RiaApplication* app = RiaApplication::instance(); | ||
QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" ); | ||
|
||
QStringList fileNames = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(), | ||
"Import Valve Templates", | ||
defaultDir, | ||
"Valve Files (*.sch *.case);;All Files (*.*)" ); | ||
|
||
if ( RimProject::current()->allValveTemplateCollections().empty() ) | ||
{ | ||
RiaLogging::error( "No valve template collection found, failed to import valves." ); | ||
return; | ||
} | ||
|
||
RimValveTemplateCollection* templateColl = RimProject::current()->allValveTemplateCollections().front(); | ||
for ( const auto& fileName : fileNames ) | ||
{ | ||
std::vector<RiaOpmParserTools::AicdTemplateValues> aicdTemplates; | ||
|
||
if ( fileName.contains( ".case" ) ) | ||
{ | ||
aicdTemplates = RiaOpmParserTools::extractWsegAicdCompletor( fileName.toStdString() ); | ||
} | ||
else | ||
{ | ||
aicdTemplates = RiaOpmParserTools::extractWsegAicd( fileName.toStdString() ); | ||
} | ||
|
||
// There can be multiple items of the same template, make sure we have unique templates | ||
std::sort( aicdTemplates.begin(), aicdTemplates.end() ); | ||
auto it = std::unique( aicdTemplates.begin(), aicdTemplates.end() ); | ||
aicdTemplates.resize( std::distance( aicdTemplates.begin(), it ) ); | ||
|
||
int number = 1; | ||
for ( const auto& aicdValue : aicdTemplates ) | ||
{ | ||
auto newTemplate = RimValveTemplate::createAicdTemplate( aicdValue, number++ ); | ||
templateColl->addValveTemplate( newTemplate ); | ||
} | ||
} | ||
|
||
templateColl->updateConnectedEditors(); | ||
} | ||
|
||
//-------------------------------------------------------------------------------------------------- | ||
/// | ||
//-------------------------------------------------------------------------------------------------- | ||
void RicImportValveTemplatesFeature::setupActionLook( QAction* actionToSetup ) | ||
{ | ||
actionToSetup->setIcon( QIcon( ":/ICDValve16x16.png" ) ); | ||
actionToSetup->setText( "Import Valve Templates" ); | ||
} |
34 changes: 34 additions & 0 deletions
34
ApplicationLibCode/Commands/CompletionCommands/RicImportValveTemplatesFeature.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,34 @@ | ||
///////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright (C) 2023- 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 RicImportValveTemplatesFeature : public caf::CmdFeature | ||
{ | ||
CAF_CMD_HEADER_INIT; | ||
|
||
protected: | ||
bool isCommandEnabled() const override; | ||
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
Oops, something went wrong.