-
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.
#10107 : Import of AICD from Eclipse text file
- Loading branch information
Showing
10 changed files
with
249 additions
and
0 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
77 changes: 77 additions & 0 deletions
77
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,77 @@ | ||
///////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// 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 "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, | ||
"Text Files (*.txt);;All Files (*.*)" ); | ||
|
||
RimValveTemplateCollection* templateColl = RimProject::current()->allValveTemplateCollections().front(); | ||
for ( const auto& fileName : fileNames ) | ||
{ | ||
auto values = RiaOpmParserTools::extractWsegaicd( fileName.toStdString() ); | ||
for ( const auto value : values ) | ||
{ | ||
auto newTemplate = RimValveTemplate::createAicdTemplate( value ); | ||
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
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
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