Rename ApplicationCode to ApplicationLibCode

This commit is contained in:
Gaute Lindkvist
2021-01-06 14:55:29 +01:00
parent 751df1a421
commit 81699db187
3242 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicImportColorCategoriesFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCopyStandardLegendFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicInsertColorLegendFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicInsertColorLegendItemFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicImportColorCategoriesFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCopyStandardLegendFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicInsertColorLegendFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicInsertColorLegendItemFeature.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND COMMAND_CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "CommandFeature\\ColorLegend" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )

View File

@@ -0,0 +1,92 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 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 "RicCopyStandardLegendFeature.h"
#include "RimColorLegend.h"
#include "RimColorLegendCollection.h"
#include "RimProject.h"
#include "cafSelectionManager.h"
#include "Riu3DMainWindowTools.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicCopyStandardLegendFeature, "RicCopyStandardLegendFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCopyStandardLegendFeature::isCommandEnabled()
{
if ( selectedColorLegend() ) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCopyStandardLegendFeature::onActionTriggered( bool isChecked )
{
RimColorLegend* standardLegend = selectedColorLegend();
if ( standardLegend )
{
// perform deep copy of standard legend object via XML
RimColorLegend* customLegend = dynamic_cast<RimColorLegend*>(
standardLegend->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
customLegend->setColorLegendName( "Copy of " + standardLegend->colorLegendName() );
RimColorLegendCollection* colorLegendCollection = RimProject::current()->colorLegendCollection;
colorLegendCollection->appendCustomColorLegend( customLegend );
colorLegendCollection->updateConnectedEditors();
Riu3DMainWindowTools::setExpanded( customLegend );
Riu3DMainWindowTools::selectAsCurrentItem( customLegend );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCopyStandardLegendFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/Legend.png" ) );
actionToSetup->setText( "Copy to Custom Color Legends" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimColorLegend* RicCopyStandardLegendFeature::selectedColorLegend()
{
caf::PdmObject* selectedObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( !selectedObject ) return nullptr;
RimColorLegend* colorLegend = nullptr;
selectedObject->firstAncestorOrThisOfType( colorLegend );
if ( colorLegend ) return colorLegend;
return nullptr;
}

View File

@@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 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 RimColorLegend;
//==================================================================================================
///
//==================================================================================================
class RicCopyStandardLegendFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
RimColorLegend* selectedColorLegend();
};

View File

@@ -0,0 +1,116 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 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 "RicImportColorCategoriesFeature.h"
#include "RiaApplication.h"
#include "RigFormationNames.h"
#include "RimColorLegend.h"
#include "RimColorLegendCollection.h"
#include "RimColorLegendItem.h"
#include "RimProject.h"
#include "RifColorLegendData.h"
#include "Riu3DMainWindowTools.h"
#include "RiuFileDialogTools.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QFileInfo>
CAF_CMD_SOURCE_INIT( RicImportColorCategoriesFeature, "RicImportColorCategoriesFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicImportColorCategoriesFeature::isCommandEnabled()
{
RimColorLegendCollection* legendCollection = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( legendCollection );
}
if ( legendCollection ) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicImportColorCategoriesFeature::onActionTriggered( bool isChecked )
{
RiaApplication* app = RiaApplication::instance();
QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" );
QString filterText = QString( "Formation Names description File (*.lyr);;All Files (*.*)" );
QString fileName = RiuFileDialogTools::getOpenFileName( Riu3DMainWindowTools::mainWindowWidget(),
"Import Formation File",
defaultDir,
filterText );
if ( fileName.isEmpty() ) return;
// Remember the path to next time
app->setLastUsedDialogDirectory( "BINARY_GRID", QFileInfo( fileName ).absolutePath() );
QString errormessage;
cvf::ref<RigFormationNames> formations = RifColorLegendData::readFormationNamesFile( fileName, &errormessage );
const std::vector<QString>& formationNames = formations->formationNames();
const std::vector<cvf::Color3f>& formationColors = formations->formationColors();
RimColorLegend* colorLegend = new RimColorLegend;
colorLegend->setColorLegendName( QFileInfo( fileName ).baseName() );
for ( size_t i = 0; i < formationColors.size(); i++ )
{
RimColorLegendItem* colorLegendItem = new RimColorLegendItem;
colorLegendItem->setValues( formationNames[i], (int)i, formationColors[i] );
colorLegend->appendColorLegendItem( colorLegendItem );
}
RimProject* proj = RimProject::current();
RimColorLegendCollection* colorLegendCollection = proj->colorLegendCollection;
colorLegendCollection->appendCustomColorLegend( colorLegend );
colorLegendCollection->updateConnectedEditors();
Riu3DMainWindowTools::setExpanded( colorLegend );
Riu3DMainWindowTools::selectAsCurrentItem( colorLegend );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicImportColorCategoriesFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/Formations16x16.png" ) );
actionToSetup->setText( "Import Color Legend from LYR Formation File" );
}

View File

@@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 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 RicImportColorCategoriesFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -0,0 +1,102 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 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 "RicInsertColorLegendFeature.h"
#include "RimColorLegend.h"
#include "RimColorLegendCollection.h"
#include "RimProject.h"
#include "cafSelectionManager.h"
#include "Riu3DMainWindowTools.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicInsertColorLegendFeature, "RicInsertColorLegendFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicInsertColorLegendFeature::isCommandEnabled()
{
if ( selectedColorLegendCollection() ) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
/// TODO: insert new color legend prior to entry of selected color legend ?
/// C.f. RicNewAnalysisPlotFeature.cpp(70-71)
//--------------------------------------------------------------------------------------------------
void RicInsertColorLegendFeature::onActionTriggered( bool isChecked )
{
RimColorLegendCollection* colorLegendCollection = selectedColorLegendCollection();
if ( colorLegendCollection )
{
RimColorLegend* customLegend = new RimColorLegend();
customLegend->setColorLegendName( "New Color Legend" );
RimColorLegendCollection* colorLegendCollection = RimProject::current()->colorLegendCollection;
colorLegendCollection->appendCustomColorLegend( customLegend );
caf::SelectionManager::instance()->setSelectedItem( customLegend );
colorLegendCollection->updateConnectedEditors();
Riu3DMainWindowTools::setExpanded( customLegend );
Riu3DMainWindowTools::selectAsCurrentItem( customLegend );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicInsertColorLegendFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/Legend.png" ) );
actionToSetup->setText( "New Color Legend" );
}
//--------------------------------------------------------------------------------------------------
/// C.f. RicNewAnalysisPlotFeature.cpp(42)
//--------------------------------------------------------------------------------------------------
RimColorLegendCollection* RicInsertColorLegendFeature::selectedColorLegendCollection()
{
caf::PdmObject* selectedObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( !selectedObject ) return nullptr;
RimColorLegendCollection* colorLegendCollection = nullptr;
selectedObject->firstAncestorOrThisOfType( colorLegendCollection );
if ( colorLegendCollection )
{
// Disable the menu for standard color legends
RimColorLegend* colorLegend = dynamic_cast<RimColorLegend*>( selectedObject );
if ( colorLegend && colorLegendCollection->isStandardColorLegend( colorLegend ) )
{
return nullptr;
}
return colorLegendCollection;
}
return nullptr;
}

View File

@@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 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 RimColorLegendCollection;
//==================================================================================================
///
//==================================================================================================
class RicInsertColorLegendFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
RimColorLegendCollection* selectedColorLegendCollection();
};

View File

@@ -0,0 +1,102 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 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 "RicInsertColorLegendItemFeature.h"
#include "RimColorLegend.h"
#include "RimColorLegendCollection.h"
#include "RimColorLegendItem.h"
#include "RimProject.h"
#include "Riu3DMainWindowTools.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicInsertColorLegendItemFeature, "RicInsertColorLegendItemFeature" );
//--------------------------------------------------------------------------------------------------
/// Disallows insert of color legend item in standard color legends
//--------------------------------------------------------------------------------------------------
bool RicInsertColorLegendItemFeature::isCommandEnabled()
{
RimColorLegend* legend = selectedColorLegend();
if ( legend )
{
RimColorLegendCollection* colorLegendCollection = nullptr;
legend->firstAncestorOrThisOfType( colorLegendCollection );
if ( colorLegendCollection && !colorLegendCollection->isStandardColorLegend( legend ) ) return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
/// TODO: insert new color legend item prior to selected color legend item?
/// C.f. RicNewAnalysisPlotFeature.cpp(70-71)
//--------------------------------------------------------------------------------------------------
void RicInsertColorLegendItemFeature::onActionTriggered( bool isChecked )
{
RimColorLegend* legend = selectedColorLegend();
if ( legend )
{
RimColorLegendItem* newLegendItem = new RimColorLegendItem();
legend->appendColorLegendItem( newLegendItem );
legend->updateConnectedEditors();
caf::SelectionManager::instance()->setSelectedItem( newLegendItem );
legend->updateConnectedEditors();
Riu3DMainWindowTools::setExpanded( newLegendItem );
Riu3DMainWindowTools::selectAsCurrentItem( newLegendItem );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicInsertColorLegendItemFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/Legend.png" ) );
actionToSetup->setText( "Append Color" );
}
//--------------------------------------------------------------------------------------------------
/// C.f. RicNewAnalysisPlotFeature.cpp(42)
//--------------------------------------------------------------------------------------------------
RimColorLegend* RicInsertColorLegendItemFeature::selectedColorLegend()
{
caf::PdmObject* selectedObject = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( !selectedObject ) return nullptr;
RimColorLegend* colorLegend = nullptr;
selectedObject->firstAncestorOrThisOfType( colorLegend );
if ( colorLegend ) return colorLegend;
return nullptr;
}

View File

@@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020 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 RimColorLegend;
//==================================================================================================
///
//==================================================================================================
class RicInsertColorLegendItemFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
RimColorLegend* selectedColorLegend();
};