#4683 clang-format on all files in ApplicationCode

This commit is contained in:
Magne Sjaastad
2019-09-06 10:40:57 +02:00
parent 3a317504bb
commit fe9e567825
2092 changed files with 117952 additions and 111846 deletions

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -19,9 +19,8 @@
#include "Riu3DMainWindowTools.h"
#include "RiuMainWindow.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QWidget* Riu3DMainWindowTools::mainWindowWidget()
{
@@ -29,37 +28,34 @@ QWidget* Riu3DMainWindowTools::mainWindowWidget()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void Riu3DMainWindowTools::setActiveViewer(QWidget* subWindow)
void Riu3DMainWindowTools::setActiveViewer( QWidget* subWindow )
{
if (RiuMainWindow::instance())
if ( RiuMainWindow::instance() )
{
RiuMainWindow::instance()->setActiveViewer(subWindow);
RiuMainWindow::instance()->setActiveViewer( subWindow );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void Riu3DMainWindowTools::setExpanded(const caf::PdmUiItem* uiItem, bool expanded /*= true*/)
void Riu3DMainWindowTools::setExpanded( const caf::PdmUiItem* uiItem, bool expanded /*= true*/ )
{
if (RiuMainWindow::instance())
if ( RiuMainWindow::instance() )
{
RiuMainWindow::instance()->setExpanded(uiItem, expanded);
RiuMainWindow::instance()->setExpanded( uiItem, expanded );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void Riu3DMainWindowTools::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange /*= true*/)
void Riu3DMainWindowTools::selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange /*= true*/ )
{
if (RiuMainWindow::instance())
if ( RiuMainWindow::instance() )
{
RiuMainWindow::instance()->selectAsCurrentItem(object, allowActiveViewChange);
RiuMainWindow::instance()->selectAsCurrentItem( object, allowActiveViewChange );
}
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -20,17 +20,17 @@
class QWidget;
namespace caf
namespace caf
{
class PdmUiItem;
class PdmObject;
}
class PdmUiItem;
class PdmObject;
} // namespace caf
class Riu3DMainWindowTools
{
public:
static QWidget* mainWindowWidget();
static void setActiveViewer(QWidget* subWindow) ;
static void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true);
static void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true);
static QWidget* mainWindowWidget();
static void setActiveViewer( QWidget* subWindow );
static void setExpanded( const caf::PdmUiItem* uiItem, bool expanded = true );
static void selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange = true );
};

View File

@@ -2,28 +2,28 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "Riu3dSelectionManager.h"
#include "RimGridView.h"
#include "Rim2dIntersectionView.h"
#include "RimEclipseView.h"
#include "RimGeoMechView.h"
#include "RimGridView.h"
#include "RimSimWellInView.h"
#include "Rim2dIntersectionView.h"
#include "RimWellPath.h"
#include "RivSimWellPipeSourceInfo.h"
@@ -31,29 +31,28 @@
#include "RiuSelectionChangedHandler.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
Riu3dSelectionManager::Riu3dSelectionManager()
: m_notificationCenter(new RiuSelectionChangedHandler)
: m_notificationCenter( new RiuSelectionChangedHandler )
{
m_selection.resize(2);
m_selection.resize( 2 );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
Riu3dSelectionManager::~Riu3dSelectionManager()
{
deleteAllItemsFromSelection(RUI_APPLICATION_GLOBAL);
deleteAllItemsFromSelection(RUI_TEMPORARY);
deleteAllItemsFromSelection( RUI_APPLICATION_GLOBAL );
deleteAllItemsFromSelection( RUI_TEMPORARY );
delete m_notificationCenter;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
Riu3dSelectionManager* Riu3dSelectionManager::instance()
{
@@ -62,26 +61,25 @@ Riu3dSelectionManager* Riu3dSelectionManager::instance()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void Riu3dSelectionManager::selectedItems(std::vector<RiuSelectionItem*>& items, int role) const
void Riu3dSelectionManager::selectedItems( std::vector<RiuSelectionItem*>& items, int role ) const
{
const std::vector<RiuSelectionItem*>& s = m_selection[role];
items = s;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuSelectionItem* Riu3dSelectionManager::selectedItem(int role /*= RUI_APPLICATION_GLOBAL*/) const
RiuSelectionItem* Riu3dSelectionManager::selectedItem( int role /*= RUI_APPLICATION_GLOBAL*/ ) const
{
const std::vector<RiuSelectionItem*>& s = m_selection[role];
if (s.size() == 1)
if ( s.size() == 1 )
{
if (s[0])
if ( s[0] )
{
return s[0];
}
@@ -91,48 +89,48 @@ RiuSelectionItem* Riu3dSelectionManager::selectedItem(int role /*= RUI_APPLICATI
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void Riu3dSelectionManager::appendItemToSelection(RiuSelectionItem* item, int role)
void Riu3dSelectionManager::appendItemToSelection( RiuSelectionItem* item, int role )
{
std::vector<RiuSelectionItem*>& s = m_selection[role];
s.push_back(item);
s.push_back( item );
if (role == RUI_APPLICATION_GLOBAL) m_notificationCenter->handleItemAppended(item);
if ( role == RUI_APPLICATION_GLOBAL ) m_notificationCenter->handleItemAppended( item );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void Riu3dSelectionManager::setSelectedItem(RiuSelectionItem* item, int role)
void Riu3dSelectionManager::setSelectedItem( RiuSelectionItem* item, int role )
{
deleteAllItemsFromSelection(role);
deleteAllItemsFromSelection( role );
std::vector<RiuSelectionItem*>& s = m_selection[role];
s.push_back(item);
s.push_back( item );
if (role == RUI_APPLICATION_GLOBAL) m_notificationCenter->handleSetSelectedItem(item);
if ( role == RUI_APPLICATION_GLOBAL ) m_notificationCenter->handleSetSelectedItem( item );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void Riu3dSelectionManager::deleteAllItems(int role)
void Riu3dSelectionManager::deleteAllItems( int role )
{
if (!isEmpty(role))
if ( !isEmpty( role ) )
{
deleteAllItemsFromSelection(role);
deleteAllItemsFromSelection( role );
if (role == RUI_APPLICATION_GLOBAL) m_notificationCenter->handleSelectionDeleted();
if ( role == RUI_APPLICATION_GLOBAL ) m_notificationCenter->handleSelectionDeleted();
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool Riu3dSelectionManager::isEmpty(int role) const
bool Riu3dSelectionManager::isEmpty( int role ) const
{
const std::vector<RiuSelectionItem*>& s = m_selection[role];
@@ -140,13 +138,13 @@ bool Riu3dSelectionManager::isEmpty(int role) const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void Riu3dSelectionManager::deleteAllItemsFromSelection(int role)
void Riu3dSelectionManager::deleteAllItemsFromSelection( int role )
{
std::vector<RiuSelectionItem*>& s = m_selection[role];
for (RiuSelectionItem* item : s)
for ( RiuSelectionItem* item : s )
{
delete item;
}
@@ -155,86 +153,86 @@ void Riu3dSelectionManager::deleteAllItemsFromSelection(int role)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuEclipseSelectionItem::RiuEclipseSelectionItem(RimEclipseView* view,
size_t gridIndex,
size_t cellIndex,
size_t nncIndex,
cvf::Color3f color,
cvf::StructGridInterface::FaceType face,
const cvf::Vec3d& localIntersectionPointInDisplay)
: m_view(view),
m_gridIndex(gridIndex),
m_gridLocalCellIndex(cellIndex),
m_nncIndex(nncIndex),
m_color(color),
m_face(face),
m_localIntersectionPointInDisplay(localIntersectionPointInDisplay)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuGeoMechSelectionItem::RiuGeoMechSelectionItem(RimGeoMechView* view,
size_t gridIndex,
size_t cellIndex,
cvf::Color3f color,
int elementFace,
const cvf::Vec3d& localIntersectionPointInDisplay)
: m_view(view)
, m_gridIndex(gridIndex)
, m_cellIndex(cellIndex)
, m_color(color)
, m_elementFace(elementFace)
, m_hasIntersectionTriangle(false)
, m_localIntersectionPointInDisplay(localIntersectionPointInDisplay)
RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimEclipseView* view,
size_t gridIndex,
size_t cellIndex,
size_t nncIndex,
cvf::Color3f color,
cvf::StructGridInterface::FaceType face,
const cvf::Vec3d& localIntersectionPointInDisplay )
: m_view( view )
, m_gridIndex( gridIndex )
, m_gridLocalCellIndex( cellIndex )
, m_nncIndex( nncIndex )
, m_color( color )
, m_face( face )
, m_localIntersectionPointInDisplay( localIntersectionPointInDisplay )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuGeoMechSelectionItem::RiuGeoMechSelectionItem(RimGeoMechView* view,
size_t gridIndex,
size_t cellIndex,
cvf::Color3f color,
int elementFace,
const cvf::Vec3d& localIntersectionPointInDisplay,
const std::array<cvf::Vec3f, 3>& intersectionTriangle)
: m_view(view)
, m_gridIndex(gridIndex)
, m_cellIndex(cellIndex)
, m_color(color)
, m_elementFace(elementFace)
, m_hasIntersectionTriangle(true)
, m_intersectionTriangle(intersectionTriangle)
, m_localIntersectionPointInDisplay(localIntersectionPointInDisplay)
RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView* view,
size_t gridIndex,
size_t cellIndex,
cvf::Color3f color,
int elementFace,
const cvf::Vec3d& localIntersectionPointInDisplay )
: m_view( view )
, m_gridIndex( gridIndex )
, m_cellIndex( cellIndex )
, m_color( color )
, m_elementFace( elementFace )
, m_hasIntersectionTriangle( false )
, m_localIntersectionPointInDisplay( localIntersectionPointInDisplay )
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
Riu2dIntersectionSelectionItem::Riu2dIntersectionSelectionItem(Rim2dIntersectionView* view, RiuSelectionItem *selItem)
RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView* view,
size_t gridIndex,
size_t cellIndex,
cvf::Color3f color,
int elementFace,
const cvf::Vec3d& localIntersectionPointInDisplay,
const std::array<cvf::Vec3f, 3>& intersectionTriangle )
: m_view( view )
, m_gridIndex( gridIndex )
, m_cellIndex( cellIndex )
, m_color( color )
, m_elementFace( elementFace )
, m_hasIntersectionTriangle( true )
, m_intersectionTriangle( intersectionTriangle )
, m_localIntersectionPointInDisplay( localIntersectionPointInDisplay )
{
m_view = view;
m_eclipseSelItem = dynamic_cast<RiuEclipseSelectionItem*>(selItem);
m_geoMechSelItem = dynamic_cast<RiuGeoMechSelectionItem*>(selItem);
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
Riu2dIntersectionSelectionItem::Riu2dIntersectionSelectionItem( Rim2dIntersectionView* view, RiuSelectionItem* selItem )
{
m_view = view;
m_eclipseSelItem = dynamic_cast<RiuEclipseSelectionItem*>( selItem );
m_geoMechSelItem = dynamic_cast<RiuGeoMechSelectionItem*>( selItem );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Riu2dIntersectionSelectionItem::~Riu2dIntersectionSelectionItem()
{
if (m_eclipseSelItem) delete m_eclipseSelItem;
if (m_geoMechSelItem) delete m_geoMechSelItem;
if ( m_eclipseSelItem ) delete m_eclipseSelItem;
if ( m_geoMechSelItem ) delete m_geoMechSelItem;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
caf::PdmPointer<Rim2dIntersectionView> Riu2dIntersectionSelectionItem::view() const
{
@@ -242,7 +240,7 @@ caf::PdmPointer<Rim2dIntersectionView> Riu2dIntersectionSelectionItem::view() co
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuEclipseSelectionItem* Riu2dIntersectionSelectionItem::eclipseSelectionItem() const
{
@@ -250,7 +248,7 @@ RiuEclipseSelectionItem* Riu2dIntersectionSelectionItem::eclipseSelectionItem()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuGeoMechSelectionItem* Riu2dIntersectionSelectionItem::geoMechSelectionItem() const
{
@@ -258,35 +256,33 @@ RiuGeoMechSelectionItem* Riu2dIntersectionSelectionItem::geoMechSelectionItem()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuWellPathSelectionItem::RiuWellPathSelectionItem(const RivWellPathSourceInfo* wellPathSourceInfo,
const cvf::Vec3d& pipeCenterLineIntersectionInDomainCoords,
double measuredDepth,
RimWellPathComponentInterface* component /*=nullptr*/)
: m_pipeCenterlineIntersectionInDomainCoords(pipeCenterLineIntersectionInDomainCoords)
, m_measuredDepth(measuredDepth)
, m_wellPathComponent(component)
RiuWellPathSelectionItem::RiuWellPathSelectionItem( const RivWellPathSourceInfo* wellPathSourceInfo,
const cvf::Vec3d& pipeCenterLineIntersectionInDomainCoords,
double measuredDepth,
RimWellPathComponentInterface* component /*=nullptr*/ )
: m_pipeCenterlineIntersectionInDomainCoords( pipeCenterLineIntersectionInDomainCoords )
, m_measuredDepth( measuredDepth )
, m_wellPathComponent( component )
{
m_wellpath = wellPathSourceInfo->wellPath();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuSimWellSelectionItem::RiuSimWellSelectionItem(RimSimWellInView* simwell,
cvf::Vec3d m_domainCoord,
size_t m_branchIndex)
: m_simWell(simwell),
m_domainCoord(m_domainCoord),
m_branchIndex(m_branchIndex)
RiuSimWellSelectionItem::RiuSimWellSelectionItem( RimSimWellInView* simwell, cvf::Vec3d m_domainCoord, size_t m_branchIndex )
: m_simWell( simwell )
, m_domainCoord( m_domainCoord )
, m_branchIndex( m_branchIndex )
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuGeneralSelectionItem::RiuGeneralSelectionItem(caf::PdmObject* object)
: m_object(object)
RiuGeneralSelectionItem::RiuGeneralSelectionItem( caf::PdmObject* object )
: m_object( object )
{
}

View File

@@ -2,33 +2,32 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmPointer.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cvfColor3.h"
#include "cvfStructGrid.h"
#include <vector>
#include <cassert>
#include <array>
#include <cassert>
#include <vector>
// #include "RivWellPathSourceInfo.h"
// #include "RivWellPipeSourceInfo.h"
@@ -46,7 +45,7 @@ class RivWellPathSourceInfo;
//==================================================================================================
//
//
//
//
//==================================================================================================
class Riu3dSelectionManager
@@ -54,8 +53,8 @@ class Riu3dSelectionManager
public:
enum SelectionRole
{
RUI_APPLICATION_GLOBAL, // Selection role intended to manage the cells selected by left mouse click in the 3D view
RUI_TEMPORARY // Selection role intended to manage the items selected by a right mouse click in the 3D view
RUI_APPLICATION_GLOBAL, // Selection role intended to manage the cells selected by left mouse click in the 3D view
RUI_TEMPORARY // Selection role intended to manage the items selected by a right mouse click in the 3D view
};
public:
@@ -63,44 +62,42 @@ public:
// Returns selected items
// Selection manager owns the selection items
void selectedItems(std::vector<RiuSelectionItem*>& items, int role = RUI_APPLICATION_GLOBAL) const;
void selectedItems( std::vector<RiuSelectionItem*>& items, int role = RUI_APPLICATION_GLOBAL ) const;
// Returns selected items
// Selection manager owns the selection items
RiuSelectionItem* selectedItem(int role = RUI_APPLICATION_GLOBAL) const;
RiuSelectionItem* selectedItem( int role = RUI_APPLICATION_GLOBAL ) const;
// PdmUiItem* selectedItem(int role = SelectionManager::APPLICATION_GLOBAL);
// Append item to selected items
// SelectionManager takes ownership of the item
void appendItemToSelection(RiuSelectionItem* item, int role = RUI_APPLICATION_GLOBAL);
void appendItemToSelection( RiuSelectionItem* item, int role = RUI_APPLICATION_GLOBAL );
// Set one selected item
// SelectionManager takes ownership of the item
void setSelectedItem(RiuSelectionItem* item, int role = RUI_APPLICATION_GLOBAL);
void setSelectedItem( RiuSelectionItem* item, int role = RUI_APPLICATION_GLOBAL );
// Deletes all items in the SelectionManager
void deleteAllItems(int role = RUI_APPLICATION_GLOBAL);
void deleteAllItems( int role = RUI_APPLICATION_GLOBAL );
bool isEmpty(int role = RUI_APPLICATION_GLOBAL) const;
bool isEmpty( int role = RUI_APPLICATION_GLOBAL ) const;
private:
Riu3dSelectionManager();
~Riu3dSelectionManager();
Riu3dSelectionManager(const Riu3dSelectionManager&) = delete;
Riu3dSelectionManager( const Riu3dSelectionManager& ) = delete;
void deleteAllItemsFromSelection(int role);
void deleteAllItemsFromSelection( int role );
private:
std::vector< std::vector<RiuSelectionItem*> > m_selection;
std::vector<std::vector<RiuSelectionItem*>> m_selection;
RiuSelectionChangedHandler* m_notificationCenter;
};
//==================================================================================================
//
//
//
//
//==================================================================================================
class RiuSelectionItem
@@ -118,29 +115,28 @@ public:
public:
RiuSelectionItem() {}
virtual ~RiuSelectionItem() {};
virtual ~RiuSelectionItem(){};
virtual RiuSelectionType type() const = 0;
};
//==================================================================================================
//
//
//
//
//==================================================================================================
class RiuEclipseSelectionItem : public RiuSelectionItem
{
public:
explicit RiuEclipseSelectionItem(RimEclipseView* view,
size_t gridIndex,
size_t cellIndex,
size_t nncIndex,
cvf::Color3f color,
cvf::StructGridInterface::FaceType face,
const cvf::Vec3d& localIntersectionPointInDisplay);
~RiuEclipseSelectionItem() override {};
explicit RiuEclipseSelectionItem( RimEclipseView* view,
size_t gridIndex,
size_t cellIndex,
size_t nncIndex,
cvf::Color3f color,
cvf::StructGridInterface::FaceType face,
const cvf::Vec3d& localIntersectionPointInDisplay );
~RiuEclipseSelectionItem() override{};
RiuSelectionType type() const override
{
@@ -148,39 +144,38 @@ public:
}
public:
caf::PdmPointer<RimEclipseView> m_view;
size_t m_gridIndex;
size_t m_gridLocalCellIndex;
size_t m_nncIndex;
cvf::Color3f m_color;
caf::PdmPointer<RimEclipseView> m_view;
size_t m_gridIndex;
size_t m_gridLocalCellIndex;
size_t m_nncIndex;
cvf::Color3f m_color;
cvf::StructGridInterface::FaceType m_face;
cvf::Vec3d m_localIntersectionPointInDisplay;
cvf::Vec3d m_localIntersectionPointInDisplay;
};
//==================================================================================================
//
//
//
//
//==================================================================================================
class RiuGeoMechSelectionItem : public RiuSelectionItem
{
public:
explicit RiuGeoMechSelectionItem(RimGeoMechView* view,
size_t gridIndex,
size_t cellIndex,
cvf::Color3f color,
int elementFace,
const cvf::Vec3d& localIntersectionPointInDisplay);
explicit RiuGeoMechSelectionItem( RimGeoMechView* view,
size_t gridIndex,
size_t cellIndex,
cvf::Color3f color,
int elementFace,
const cvf::Vec3d& localIntersectionPointInDisplay );
explicit RiuGeoMechSelectionItem(RimGeoMechView* view,
size_t gridIndex,
size_t cellIndex,
cvf::Color3f color,
int elementFace,
const cvf::Vec3d& localIntersectionPointInDisplay,
const std::array<cvf::Vec3f, 3>& intersectionTriangle );
~RiuGeoMechSelectionItem() override {};
explicit RiuGeoMechSelectionItem( RimGeoMechView* view,
size_t gridIndex,
size_t cellIndex,
cvf::Color3f color,
int elementFace,
const cvf::Vec3d& localIntersectionPointInDisplay,
const std::array<cvf::Vec3f, 3>& intersectionTriangle );
~RiuGeoMechSelectionItem() override{};
RiuSelectionType type() const override
{
@@ -189,25 +184,24 @@ public:
public:
caf::PdmPointer<RimGeoMechView> m_view;
size_t m_gridIndex;
size_t m_cellIndex;
cvf::Color3f m_color;
int m_elementFace;
bool m_hasIntersectionTriangle;
std::array<cvf::Vec3f, 3> m_intersectionTriangle;
cvf::Vec3d m_localIntersectionPointInDisplay;
size_t m_gridIndex;
size_t m_cellIndex;
cvf::Color3f m_color;
int m_elementFace;
bool m_hasIntersectionTriangle;
std::array<cvf::Vec3f, 3> m_intersectionTriangle;
cvf::Vec3d m_localIntersectionPointInDisplay;
};
//==================================================================================================
//
//
//
//
//==================================================================================================
class Riu2dIntersectionSelectionItem : public RiuSelectionItem
{
public:
explicit Riu2dIntersectionSelectionItem(Rim2dIntersectionView* view, RiuSelectionItem *selItem);
explicit Riu2dIntersectionSelectionItem( Rim2dIntersectionView* view, RiuSelectionItem* selItem );
~Riu2dIntersectionSelectionItem() override;
@@ -218,30 +212,29 @@ public:
public:
caf::PdmPointer<Rim2dIntersectionView> view() const;
RiuEclipseSelectionItem* eclipseSelectionItem() const;
RiuGeoMechSelectionItem* geoMechSelectionItem() const;
RiuEclipseSelectionItem* eclipseSelectionItem() const;
RiuGeoMechSelectionItem* geoMechSelectionItem() const;
private:
caf::PdmPointer<Rim2dIntersectionView> m_view;
RiuEclipseSelectionItem* m_eclipseSelItem;
RiuGeoMechSelectionItem* m_geoMechSelItem;
RiuEclipseSelectionItem* m_eclipseSelItem;
RiuGeoMechSelectionItem* m_geoMechSelItem;
};
//==================================================================================================
//
//
//
//
//==================================================================================================
class RiuWellPathSelectionItem : public RiuSelectionItem
{
public:
explicit RiuWellPathSelectionItem(const RivWellPathSourceInfo* wellPathSourceInfo,
const cvf::Vec3d& pipeCenterLineIntersectionInDomainCoords,
double measuredDepth,
RimWellPathComponentInterface* wellPathComponent = nullptr);
explicit RiuWellPathSelectionItem( const RivWellPathSourceInfo* wellPathSourceInfo,
const cvf::Vec3d& pipeCenterLineIntersectionInDomainCoords,
double measuredDepth,
RimWellPathComponentInterface* wellPathComponent = nullptr );
~RiuWellPathSelectionItem() override {};
~RiuWellPathSelectionItem() override{};
RiuSelectionType type() const override
{
@@ -255,20 +248,17 @@ public:
RimWellPathComponentInterface* m_wellPathComponent;
};
//==================================================================================================
//
//
//
//
//==================================================================================================
class RiuSimWellSelectionItem : public RiuSelectionItem
{
public:
explicit RiuSimWellSelectionItem(RimSimWellInView* simwell, cvf::Vec3d domainCoord, size_t branchIndex);
explicit RiuSimWellSelectionItem( RimSimWellInView* simwell, cvf::Vec3d domainCoord, size_t branchIndex );
~RiuSimWellSelectionItem() override {};
~RiuSimWellSelectionItem() override{};
RiuSelectionType type() const override
{
@@ -281,18 +271,17 @@ public:
size_t m_branchIndex;
};
//==================================================================================================
//
//
//
//
//==================================================================================================
class RiuGeneralSelectionItem : public RiuSelectionItem
{
public:
RiuGeneralSelectionItem(caf::PdmObject* object);
RiuGeneralSelectionItem( caf::PdmObject* object );
~RiuGeneralSelectionItem() override {};
~RiuGeneralSelectionItem() override{};
RiuSelectionType type() const override
{

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -22,12 +22,12 @@
#include "ExportCommands/RicAdvancedSnapshotExportFeature.h"
#include "Rim3dView.h"
#include "RimAdvancedSnapshotExportDefinition.h"
#include "RimCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimAdvancedSnapshotExportDefinition.h"
#include "RimProject.h"
#include "Rim3dView.h"
#include "RiuTools.h"
@@ -35,10 +35,11 @@
#include "cafPdmUiTableView.h"
#include "cafSelectionManager.h"
#include <QFileDialog>
#include <QAbstractItemView>
#include <QBoxLayout>
#include <QDialogButtonBox>
#include <QFileDialog>
#include <QHeaderView>
#include <QLabel>
#include <QLineEdit>
#include <QMenu>
@@ -46,139 +47,137 @@
#include <QTableView>
#include <QToolButton>
#include <QWidget>
#include <QHeaderView>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuAdvancedSnapshotExportWidget::RiuAdvancedSnapshotExportWidget(QWidget* parent, RimProject* project)
: QDialog(parent, RiuTools::defaultDialogFlags()),
m_rimProject(project)
RiuAdvancedSnapshotExportWidget::RiuAdvancedSnapshotExportWidget( QWidget* parent, RimProject* project )
: QDialog( parent, RiuTools::defaultDialogFlags() )
, m_rimProject( project )
{
setWindowTitle("Advanced Snapshot Export");
setWindowTitle( "Advanced Snapshot Export" );
int nWidth = 1000;
int nWidth = 1000;
int nHeight = 300;
resize(nWidth, nHeight);
resize( nWidth, nHeight );
QVBoxLayout* dialogLayout = new QVBoxLayout;
setLayout(dialogLayout);
setLayout( dialogLayout );
m_pdmTableView = new caf::PdmUiTableView(this);
m_pdmTableView->tableView()->setSelectionMode(QAbstractItemView::ExtendedSelection);
m_pdmTableView->tableView()->setContextMenuPolicy(Qt::CustomContextMenu);
m_pdmTableView->enableHeaderText(false);
m_pdmTableView = new caf::PdmUiTableView( this );
m_pdmTableView->tableView()->setSelectionMode( QAbstractItemView::ExtendedSelection );
m_pdmTableView->tableView()->setContextMenuPolicy( Qt::CustomContextMenu );
m_pdmTableView->enableHeaderText( false );
connect(m_pdmTableView->tableView(), SIGNAL(customContextMenuRequested(QPoint)), SLOT(customMenuRequested(QPoint)));
connect( m_pdmTableView->tableView(),
SIGNAL( customContextMenuRequested( QPoint ) ),
SLOT( customMenuRequested( QPoint ) ) );
m_pdmTableView->setChildArrayField(&(project->multiSnapshotDefinitions()));
m_pdmTableView->setChildArrayField( &( project->multiSnapshotDefinitions() ) );
QHeaderView* verticalHeader = m_pdmTableView->tableView()->verticalHeader();
#if QT_VERSION >= 0x050000
verticalHeader->setSectionResizeMode(QHeaderView::Interactive);
verticalHeader->setSectionResizeMode( QHeaderView::Interactive );
#else
verticalHeader->setResizeMode(QHeaderView::Interactive);
verticalHeader->setResizeMode( QHeaderView::Interactive );
#endif
m_pdmTableView->tableView()->resizeColumnsToContents();
// Set active child array to be able to use generic delete
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle(&(project->multiSnapshotDefinitions()));
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle( &( project->multiSnapshotDefinitions() ) );
dialogLayout->addWidget(m_pdmTableView);
dialogLayout->addWidget( m_pdmTableView );
// Export folder
{
QHBoxLayout* layout = new QHBoxLayout;
layout->addWidget(new QLabel("Export folder"));
layout->addWidget( new QLabel( "Export folder" ) );
m_exportFolderLineEdit = new QLineEdit;
QToolButton* button = new QToolButton;
button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
button->setText(QLatin1String("..."));
button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ) );
button->setText( QLatin1String( "..." ) );
layout->addWidget(m_exportFolderLineEdit);
layout->addWidget(button);
layout->addWidget( m_exportFolderLineEdit );
layout->addWidget( button );
connect(button, SIGNAL(clicked()), this, SLOT(folderSelectionClicked()));
connect( button, SIGNAL( clicked() ), this, SLOT( folderSelectionClicked() ) );
dialogLayout->addLayout(layout);
dialogLayout->addLayout( layout );
}
// Buttons
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Close );
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
QPushButton* exportButton = new QPushButton(tr("Export"));
exportButton->setDefault(true);
buttonBox->addButton(exportButton, QDialogButtonBox::ActionRole);
connect(exportButton, SIGNAL(clicked()), this, SLOT(exportSnapshots()));
QPushButton* exportButton = new QPushButton( tr( "Export" ) );
exportButton->setDefault( true );
buttonBox->addButton( exportButton, QDialogButtonBox::ActionRole );
connect( exportButton, SIGNAL( clicked() ), this, SLOT( exportSnapshots() ) );
dialogLayout->addWidget(buttonBox);
dialogLayout->addWidget( buttonBox );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuAdvancedSnapshotExportWidget::~RiuAdvancedSnapshotExportWidget()
{
m_pdmTableView->setChildArrayField(nullptr);
m_pdmTableView->setChildArrayField( nullptr );
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle(nullptr);
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle( nullptr );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuAdvancedSnapshotExportWidget::addSnapshotItemFromActiveView()
{
if (!m_rimProject) return;
if ( !m_rimProject ) return;
Rim3dView* activeView = RiaApplication::instance()->activeReservoirView();
if (activeView)
if ( activeView )
{
RimAdvancedSnapshotExportDefinition* multiSnapshot = new RimAdvancedSnapshotExportDefinition();
multiSnapshot->view = activeView;
multiSnapshot->view = activeView;
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(activeView);
if (eclipseView)
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( activeView );
if ( eclipseView )
{
multiSnapshot->eclipseResultType = eclipseView->cellResult()->resultType();
multiSnapshot->selectedEclipseResults.v().push_back(eclipseView->cellResult()->resultVariable());
multiSnapshot->selectedEclipseResults.v().push_back( eclipseView->cellResult()->resultVariable() );
}
multiSnapshot->timeStepStart = activeView->currentTimeStep();
multiSnapshot->timeStepEnd = activeView->currentTimeStep();
multiSnapshot->timeStepEnd = activeView->currentTimeStep();
RimCase* sourceCase = nullptr;
activeView->firstAncestorOrThisOfType(sourceCase);
if (sourceCase)
activeView->firstAncestorOrThisOfType( sourceCase );
if ( sourceCase )
{
multiSnapshot->additionalCases().push_back(sourceCase);
multiSnapshot->additionalCases().push_back( sourceCase );
}
m_rimProject->multiSnapshotDefinitions.push_back(multiSnapshot);
m_rimProject->multiSnapshotDefinitions.push_back( multiSnapshot );
m_rimProject->multiSnapshotDefinitions.uiCapability()->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuAdvancedSnapshotExportWidget::addEmptySnapshotItems(size_t itemCount)
void RiuAdvancedSnapshotExportWidget::addEmptySnapshotItems( size_t itemCount )
{
if (!m_rimProject) return;
if ( !m_rimProject ) return;
for (size_t i = 0; i < itemCount; i++)
for ( size_t i = 0; i < itemCount; i++ )
{
RimAdvancedSnapshotExportDefinition* multiSnapshot = new RimAdvancedSnapshotExportDefinition();
multiSnapshot->isActive = false;
multiSnapshot->isActive = false;
m_rimProject->multiSnapshotDefinitions.push_back(multiSnapshot);
m_rimProject->multiSnapshotDefinitions.push_back( multiSnapshot );
}
m_rimProject->multiSnapshotDefinitions.uiCapability()->updateConnectedEditors();
@@ -187,50 +186,49 @@ void RiuAdvancedSnapshotExportWidget::addEmptySnapshotItems(size_t itemCount)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuAdvancedSnapshotExportWidget::setExportFolder(const QString& folder)
void RiuAdvancedSnapshotExportWidget::setExportFolder( const QString& folder )
{
m_exportFolderLineEdit->setText(folder);
m_exportFolderLineEdit->setText( folder );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiuAdvancedSnapshotExportWidget::exportFolder() const
QString RiuAdvancedSnapshotExportWidget::exportFolder() const
{
return m_exportFolderLineEdit->text();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuAdvancedSnapshotExportWidget::customMenuRequested(QPoint pos)
void RiuAdvancedSnapshotExportWidget::customMenuRequested( QPoint pos )
{
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
QMenu menu;
menu.addAction(commandManager->action("PdmListField_DeleteItem","Delete row"));
menu.addAction( commandManager->action( "PdmListField_DeleteItem", "Delete row" ) );
QAction* newRowAction = new QAction("New row", this);
connect(newRowAction, SIGNAL(triggered()), SLOT(addSnapshotItem()));
menu.addAction(newRowAction);
QAction* newRowAction = new QAction( "New row", this );
connect( newRowAction, SIGNAL( triggered() ), SLOT( addSnapshotItem() ) );
menu.addAction( newRowAction );
QAction* clearAllRows = new QAction( "Clear", this );
connect( clearAllRows, SIGNAL( triggered() ), SLOT( deleteAllSnapshotItems() ) );
menu.addAction( clearAllRows );
QAction* clearAllRows = new QAction("Clear", this);
connect(clearAllRows, SIGNAL(triggered()), SLOT(deleteAllSnapshotItems()));
menu.addAction(clearAllRows);
// Qt doc: QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the viewport().
QPoint globalPos = m_pdmTableView->tableView()->viewport()->mapToGlobal(pos);
QPoint globalPos = m_pdmTableView->tableView()->viewport()->mapToGlobal( pos );
menu.exec(globalPos);
menu.exec( globalPos );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuAdvancedSnapshotExportWidget::deleteAllSnapshotItems()
{
if (!m_rimProject) return;
if ( !m_rimProject ) return;
m_rimProject->multiSnapshotDefinitions.deleteAllChildObjects();
@@ -238,33 +236,34 @@ void RiuAdvancedSnapshotExportWidget::deleteAllSnapshotItems()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuAdvancedSnapshotExportWidget::exportSnapshots()
{
RicAdvancedSnapshotExportFeature::exportMultipleSnapshots(m_exportFolderLineEdit->text(), m_rimProject);
RicAdvancedSnapshotExportFeature::exportMultipleSnapshots( m_exportFolderLineEdit->text(), m_rimProject );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuAdvancedSnapshotExportWidget::folderSelectionClicked()
{
QString defaultPath = m_exportFolderLineEdit->text();
QString directoryPath = QFileDialog::getExistingDirectory(m_exportFolderLineEdit,
tr("Get existing directory"),
defaultPath,
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
QString directoryPath = QFileDialog::getExistingDirectory( m_exportFolderLineEdit,
tr( "Get existing directory" ),
defaultPath,
QFileDialog::ShowDirsOnly |
QFileDialog::DontResolveSymlinks );
if (!directoryPath.isEmpty())
if ( !directoryPath.isEmpty() )
{
m_exportFolderLineEdit->setText(directoryPath);
m_exportFolderLineEdit->setText( directoryPath );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuAdvancedSnapshotExportWidget::addSnapshotItem()
{

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -22,8 +22,9 @@
class RimProject;
namespace caf {
class PdmUiTableView;
namespace caf
{
class PdmUiTableView;
}
class QWidget;
@@ -33,16 +34,16 @@ class RiuAdvancedSnapshotExportWidget : public QDialog
{
Q_OBJECT
public:
RiuAdvancedSnapshotExportWidget(QWidget* parent, RimProject* project);
RiuAdvancedSnapshotExportWidget( QWidget* parent, RimProject* project );
~RiuAdvancedSnapshotExportWidget() override;
void addSnapshotItemFromActiveView();
void addEmptySnapshotItems(size_t itemCount);
void setExportFolder(const QString& folder);
void addSnapshotItemFromActiveView();
void addEmptySnapshotItems( size_t itemCount );
void setExportFolder( const QString& folder );
QString exportFolder() const;
private slots:
void customMenuRequested(QPoint pos);
void customMenuRequested( QPoint pos );
void addSnapshotItem();
void deleteAllSnapshotItems();
void exportSnapshots();

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -20,143 +20,136 @@
#include "RiuCadNavigation.h"
#include "cafViewer.h"
#include "cvfCamera.h"
#include "cvfViewport.h"
#include "cvfHitItemCollection.h"
#include "cvfRay.h"
#include "cvfManipulatorTrackball.h"
#include "cvfRay.h"
#include "cvfViewport.h"
#include <QInputEvent>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuCadNavigation::RiuCadNavigation()
RiuCadNavigation::RiuCadNavigation() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuCadNavigation::~RiuCadNavigation() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuCadNavigation::handleInputEvent( QInputEvent* inputEvent )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuCadNavigation::~RiuCadNavigation()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuCadNavigation::handleInputEvent(QInputEvent* inputEvent)
{
if (! inputEvent) return false;
if ( !inputEvent ) return false;
bool isEventHandled = false;
switch (inputEvent->type())
switch ( inputEvent->type() )
{
case QEvent::MouseButtonPress:
case QEvent::MouseButtonPress:
{
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
QMouseEvent* me = static_cast<QMouseEvent*>( inputEvent );
int translatedMousePosX, translatedMousePosY;
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
cvfEventPos( me->x(), me->y(), &translatedMousePosX, &translatedMousePosY );
if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier && isRotationEnabled())
{
if ( me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier && isRotationEnabled() )
{
cvf::HitItemCollection hic;
bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic);
bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic );
if (hitSomething)
if ( hitSomething )
{
cvf::Vec3d pointOfInterest = hic.firstItem()->intersectionPoint();
this->setPointOfInterest(pointOfInterest);
this->setPointOfInterest( pointOfInterest );
}
else
{
initializeRotationCenter();
}
m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY);
m_isNavigating = true;
m_trackball->startNavigation( cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY );
m_isNavigating = true;
m_hasMovedMouseDuringNavigation = false;
isEventHandled = true;
isEventHandled = true;
}
else if (me->button() == Qt::LeftButton || (me->button() == Qt::MidButton && (me->modifiers() & Qt::ShiftModifier)))
else if ( me->button() == Qt::LeftButton ||
( me->button() == Qt::MidButton && ( me->modifiers() & Qt::ShiftModifier ) ) )
{
m_trackball->startNavigation(cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY);
m_isNavigating = true;
m_trackball->startNavigation( cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY );
m_isNavigating = true;
m_hasMovedMouseDuringNavigation = false;
isEventHandled = true;
isEventHandled = true;
}
forcePointOfInterestUpdateDuringNextWheelZoom();
forcePointOfInterestUpdateDuringNextWheelZoom();
}
break;
case QEvent::MouseButtonRelease:
case QEvent::MouseButtonRelease:
{
if (m_isNavigating)
if ( m_isNavigating )
{
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
if (me->button() == Qt::MidButton || me->button() == Qt::LeftButton)
QMouseEvent* me = static_cast<QMouseEvent*>( inputEvent );
if ( me->button() == Qt::MidButton || me->button() == Qt::LeftButton )
{
m_trackball->endNavigation();
m_isNavigating = false;
if (m_hasMovedMouseDuringNavigation) isEventHandled = true;
if ( m_hasMovedMouseDuringNavigation ) isEventHandled = true;
m_hasMovedMouseDuringNavigation = false;
}
}
forcePointOfInterestUpdateDuringNextWheelZoom();
}
break;
case QEvent::MouseMove:
case QEvent::MouseMove:
{
initializeRotationCenter();
if (m_isRotCenterInitialized)
if ( m_isRotCenterInitialized )
{
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
QMouseEvent* me = static_cast<QMouseEvent*>( inputEvent );
int translatedMousePosX, translatedMousePosY;
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
cvfEventPos( me->x(), me->y(), &translatedMousePosX, &translatedMousePosY );
if (m_isNavigating)
if ( m_isNavigating )
{
bool needRedraw = m_trackball->updateNavigation(translatedMousePosX, translatedMousePosY);
if (needRedraw)
bool needRedraw = m_trackball->updateNavigation( translatedMousePosX, translatedMousePosY );
if ( needRedraw )
{
m_viewer->navigationPolicyUpdate();
}
isEventHandled = true;
isEventHandled = true;
m_hasMovedMouseDuringNavigation = true;
}
}
}
break;
case QEvent::Wheel:
case QEvent::Wheel:
{
if (inputEvent->modifiers() == Qt::NoModifier)
if ( inputEvent->modifiers() == Qt::NoModifier )
{
QWheelEvent* we = static_cast<QWheelEvent*>(inputEvent);
QWheelEvent* we = static_cast<QWheelEvent*>( inputEvent );
updatePointOfInterestDuringZoomIfNecessary(we->x(), we->y());
updatePointOfInterestDuringZoomIfNecessary( we->x(), we->y() );
if (m_isRotCenterInitialized)
if ( m_isRotCenterInitialized )
{
int translatedMousePosX, translatedMousePosY;
cvfEventPos(we->x(), we->y(), &translatedMousePosX, &translatedMousePosY);
cvfEventPos( we->x(), we->y(), &translatedMousePosX, &translatedMousePosY );
cvf::ref<cvf::Ray> ray = createZoomRay(translatedMousePosX, translatedMousePosY);
cvf::ref<cvf::Ray> ray = createZoomRay( translatedMousePosX, translatedMousePosY );
zoomAlongRay(ray.p(), -we->delta());
zoomAlongRay( ray.p(), -we->delta() );
}
isEventHandled = true;
}
}
break;
default:
break;
default:
break;
}
if (isSupposedToConsumeEvents())
if ( isSupposedToConsumeEvents() )
return isEventHandled;
else
return false;

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -26,6 +26,7 @@ class RiuCadNavigation : public caf::TrackBallBasedNavigation
public:
RiuCadNavigation();
~RiuCadNavigation() override;
protected:
bool handleInputEvent(QInputEvent* inputEvent) override;
bool handleInputEvent( QInputEvent* inputEvent ) override;
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -22,54 +22,54 @@
#include <QMenu>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuCalculationsContextMenuManager::attachWidget(QWidget* widget, RicSummaryCurveCalculator* curveCalc)
void RiuCalculationsContextMenuManager::attachWidget( QWidget* widget, RicSummaryCurveCalculator* curveCalc )
{
if (m_widget != widget)
if ( m_widget != widget )
{
widget->setContextMenuPolicy(Qt::CustomContextMenu);
QObject::connect(widget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotMenuItems(QPoint)));
widget->setContextMenuPolicy( Qt::CustomContextMenu );
QObject::connect( widget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( slotMenuItems( QPoint ) ) );
m_widget = widget;
m_widget = widget;
m_curveCalc = curveCalc;
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuCalculationsContextMenuManager::slotMenuItems(QPoint point)
void RiuCalculationsContextMenuManager::slotMenuItems( QPoint point )
{
QMenu menu;
QAction action("Create copy", this);
connect(&action, SIGNAL(triggered()), SLOT(slotCreateCalculationCopy()));
action.setEnabled(m_curveCalc->currentCalculation() != nullptr);
QAction action( "Create copy", this );
connect( &action, SIGNAL( triggered() ), SLOT( slotCreateCalculationCopy() ) );
action.setEnabled( m_curveCalc->currentCalculation() != nullptr );
menu.addAction(&action);
menu.addAction( &action );
QPoint globalPoint = point;
if (m_widget)
if ( m_widget )
{
globalPoint = m_widget->mapToGlobal(point);
globalPoint = m_widget->mapToGlobal( point );
}
menu.exec(globalPoint);
menu.exec( globalPoint );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuCalculationsContextMenuManager::slotCreateCalculationCopy()
{
RimSummaryCalculation* currCalculation = m_curveCalc != nullptr ? m_curveCalc->currentCalculation() : nullptr;
if (m_widget != nullptr && currCalculation != nullptr)
if ( m_widget != nullptr && currCalculation != nullptr )
{
RimSummaryCalculationCollection* coll = RicSummaryCurveCalculator::calculationCollection();
RimSummaryCalculation* calcCopy = coll->addCalculationCopy(currCalculation);
m_curveCalc->setCurrentCalculation(calcCopy);
RimSummaryCalculationCollection* coll = RicSummaryCurveCalculator::calculationCollection();
RimSummaryCalculation* calcCopy = coll->addCalculationCopy( currCalculation );
m_curveCalc->setCurrentCalculation( calcCopy );
m_curveCalc->updateConnectedEditors();
}
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -19,38 +19,38 @@
#pragma once
#include "cafPdmChildArrayField.h"
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include <QPointer>
#include "cafPdmObject.h"
#include <QAction>
#include <QPointer>
#include <QWidget>
#include <memory>
#include <map>
#include <memory>
class RimSummaryCalculationVariable;
class RicSummaryCurveCalculator;
//==================================================================================================
///
///
///
///
//==================================================================================================
class RiuCalculationsContextMenuManager : public QObject
{
Q_OBJECT
static const std::map<QString, std::set<QString>> MENU_MAP;
static const std::map<QString, std::set<QString>> MENU_MAP;
public:
RiuCalculationsContextMenuManager()
: m_curveCalc(nullptr)
, m_textPosition(0)
: m_curveCalc( nullptr )
, m_textPosition( 0 )
{
}
void attachWidget(QWidget* widget, RicSummaryCurveCalculator* curveCalc);
void attachWidget( QWidget* widget, RicSummaryCurveCalculator* curveCalc );
public slots:
void slotMenuItems(QPoint point);
void slotMenuItems( QPoint point );
private slots:
void slotCreateCalculationCopy();

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -27,39 +27,37 @@
#include <QMenu>
#include <QWidget>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuContextMenuLauncher::RiuContextMenuLauncher(QWidget* widget, const caf::CmdFeatureMenuBuilder& commandIds) :
QObject(widget),
m_menuBuilder(commandIds)
RiuContextMenuLauncher::RiuContextMenuLauncher( QWidget* widget, const caf::CmdFeatureMenuBuilder& commandIds )
: QObject( widget )
, m_menuBuilder( commandIds )
{
widget->installEventFilter(this);
widget->installEventFilter( this );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuContextMenuLauncher::eventFilter(QObject* watchedObject, QEvent* event)
bool RiuContextMenuLauncher::eventFilter( QObject* watchedObject, QEvent* event )
{
if (event->type() == QEvent::ContextMenu)
if ( event->type() == QEvent::ContextMenu )
{
QMenu menu;
m_menuBuilder.appendToMenu(&menu);
m_menuBuilder.appendToMenu( &menu );
if (menu.actions().size() > 0)
if ( menu.actions().size() > 0 )
{
QContextMenuEvent* cme = static_cast<QContextMenuEvent*>(event);
CVF_ASSERT(cme);
QContextMenuEvent* cme = static_cast<QContextMenuEvent*>( event );
CVF_ASSERT( cme );
menu.exec(cme->globalPos());
menu.exec( cme->globalPos() );
}
return true;
}
// standard event processing
return QObject::eventFilter(watchedObject, event);
return QObject::eventFilter( watchedObject, event );
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -26,19 +26,17 @@
class QEvent;
class QWidget;
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
class RiuContextMenuLauncher : public QObject
{
public:
explicit RiuContextMenuLauncher(QWidget* widget, const caf::CmdFeatureMenuBuilder& commandIds);
explicit RiuContextMenuLauncher( QWidget* widget, const caf::CmdFeatureMenuBuilder& commandIds );
protected:
bool eventFilter(QObject* watched, QEvent* event) override;
bool eventFilter( QObject* watched, QEvent* event ) override;
private:
caf::CmdFeatureMenuBuilder m_menuBuilder;
};

View File

@@ -1,88 +1,79 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiuCursors.h"
#include <QtCore/QString>
#include <QBitmap>
#include <QtCore/QString>
//==================================================================================================
///
///
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuCursors::RiuCursors()
{
m_cursors[FILTER_BOX] = cursorFromFile(":/Cursors/curFilterBox.bmp", 10, 10);
m_cursors[NORMAL] = cursorFromFile(":/Cursors/curNormal.bmp", 10, 10);
m_cursors[PAN] = cursorFromFile(":/Cursors/curPan.bmp");
m_cursors[WALK] = cursorFromFile(":/Cursors/curWalk.bmp");
m_cursors[ZOOM] = cursorFromFile(":/Cursors/curZoom.bmp");
m_cursors[ROTATE] = cursorFromFile(":/Cursors/curRotate.bmp");
m_cursors[FILTER_BOX] = cursorFromFile( ":/Cursors/curFilterBox.bmp", 10, 10 );
m_cursors[NORMAL] = cursorFromFile( ":/Cursors/curNormal.bmp", 10, 10 );
m_cursors[PAN] = cursorFromFile( ":/Cursors/curPan.bmp" );
m_cursors[WALK] = cursorFromFile( ":/Cursors/curWalk.bmp" );
m_cursors[ZOOM] = cursorFromFile( ":/Cursors/curZoom.bmp" );
m_cursors[ROTATE] = cursorFromFile( ":/Cursors/curRotate.bmp" );
m_cursors[PICK] = cursorFromFile(":/Cursors/curPick.bmp", 10, 10);
m_cursors[PICK_ROTPOINT]= cursorFromFile(":/Cursors/curPickRotPoint.bmp", 10, 10);
m_cursors[PICK_GOTO] = cursorFromFile(":/Cursors/curPickGoto.bmp", 10, 10);
m_cursors[PICK] = cursorFromFile( ":/Cursors/curPick.bmp", 10, 10 );
m_cursors[PICK_ROTPOINT] = cursorFromFile( ":/Cursors/curPickRotPoint.bmp", 10, 10 );
m_cursors[PICK_GOTO] = cursorFromFile( ":/Cursors/curPickGoto.bmp", 10, 10 );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QCursor RiuCursors::get(CursorIndex cursorIdx)
QCursor RiuCursors::get( CursorIndex cursorIdx )
{
// Create our single instance in a local static variable
static RiuCursors myStaticInstance;
return myStaticInstance.m_cursors[cursorIdx];
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QCursor RiuCursors::cursorFromFile(const QString& fileName, int hotspotX, int hotspotY)
QCursor RiuCursors::cursorFromFile( const QString& fileName, int hotspotX, int hotspotY )
{
QImage image(fileName);
if (image.width() == 0 || image.height() == 0)
QImage image( fileName );
if ( image.width() == 0 || image.height() == 0 )
{
return QCursor();
}
//QRgb maskClr = image.pixel(0, 0);
//QImage imgMask = image.createMaskFromColor(maskClr, Qt::MaskInColor);
QImage imgMask = image.createHeuristicMask(true);
// QRgb maskClr = image.pixel(0, 0);
// QImage imgMask = image.createMaskFromColor(maskClr, Qt::MaskInColor);
QImage imgMask = image.createHeuristicMask( true );
QBitmap bmMask = QBitmap::fromImage(imgMask, Qt::ThresholdDither | Qt::AvoidDither);
QBitmap bmMask = QBitmap::fromImage( imgMask, Qt::ThresholdDither | Qt::AvoidDither );
QBitmap bitmap = QBitmap::fromImage(image, Qt::ThresholdDither | Qt::AvoidDither);
QBitmap bitmap = QBitmap::fromImage( image, Qt::ThresholdDither | Qt::AvoidDither );
return QCursor(bitmap, bmMask, hotspotX, hotspotY);
return QCursor( bitmap, bmMask, hotspotX, hotspotY );
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -20,8 +20,6 @@
#include <QCursor>
//==================================================================================================
//
// Singleton for getting the cursors
@@ -41,16 +39,16 @@ public:
PICK,
PICK_GOTO,
PICK_ROTPOINT,
NUM_CURSORS
NUM_CURSORS
};
public:
static QCursor get(CursorIndex cursorIdx);
static QCursor get( CursorIndex cursorIdx );
private:
RiuCursors();
static QCursor cursorFromFile(const QString& fileName, int hotspotX = -1, int hotspotY = -1);
static QCursor cursorFromFile( const QString& fileName, int hotspotX = -1, int hotspotY = -1 );
private:
QCursor m_cursors[NUM_CURSORS];
QCursor m_cursors[NUM_CURSORS];
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -23,109 +23,108 @@
#include "cafTitledOverlayFrame.h"
#include "cafViewer.h"
#include "cvfqtUtils.h"
#include "cvfRenderSequence.h"
#include "cvfCamera.h"
#include "cvfFramebufferObject.h"
#include "cvfRenderSequence.h"
#include "cvfRenderbufferObject.h"
#include "cvfRendering.h"
#include "cvfCamera.h"
#include "cvfqtUtils.h"
#include <QApplication>
#include <QBoxLayout>
#include <QFrame>
#include <QLabel>
#include <QPixmap>
#include <QPushButton>
#include <QResizeEvent>
#include <QBoxLayout>
#include "glew/GL/glew.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuCvfOverlayItemWidget::RiuCvfOverlayItemWidget(QWidget* parent/*=0*/, QWidget* widgetToSnapTo)
: RiuDraggableOverlayFrame(parent, widgetToSnapTo)
RiuCvfOverlayItemWidget::RiuCvfOverlayItemWidget( QWidget* parent /*=0*/, QWidget* widgetToSnapTo )
: RiuDraggableOverlayFrame( parent, widgetToSnapTo )
{
this->layout()->setMargin(0);
this->layout()->setSpacing(0);
this->layout()->setMargin( 0 );
this->layout()->setSpacing( 0 );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuCvfOverlayItemWidget::~RiuCvfOverlayItemWidget()
{
}
RiuCvfOverlayItemWidget::~RiuCvfOverlayItemWidget() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuCvfOverlayItemWidget::updateFromOverlayItem( caf::TitledOverlayFrame * item)
void RiuCvfOverlayItemWidget::updateFromOverlayItem( caf::TitledOverlayFrame* item )
{
unsigned int width = item->renderSize().x();
unsigned int height = item->renderSize().y();
QGLFormat glFormat;
glFormat.setDirectRendering(RiaGuiApplication::instance()->useShaders());
glFormat.setDirectRendering( RiaGuiApplication::instance()->useShaders() );
// Enforce no border to avoid
item->setBackgroundFrameColor(cvf::Color4f(0, 0, 0, 0));
item->setBackgroundFrameColor( cvf::Color4f( 0, 0, 0, 0 ) );
caf::Viewer* viewer = new caf::Viewer(glFormat, nullptr);
caf::Viewer* viewer = new caf::Viewer( glFormat, nullptr );
cvf::OpenGLContext* cvfOglContext = viewer->cvfOpenGLContext();
viewer->resize(width, height);
viewer->resize( width, height );
// Create a rendering
cvf::ref<cvf::Rendering> rendering = new cvf::Rendering;
item->setLayoutFixedPosition({0,0});
rendering->addOverlayItem(item);
item->setLayoutFixedPosition( {0, 0} );
rendering->addOverlayItem( item );
rendering->camera()->setViewport(0,0,width, height);
rendering->camera()->viewport()->setClearColor({1,1,1,0});
rendering->camera()->setViewport( 0, 0, width, height );
rendering->camera()->viewport()->setClearColor( {1, 1, 1, 0} );
cvf::ref<cvf::RenderSequence> renderingSequence = new cvf::RenderSequence;
renderingSequence->addRendering(rendering.p());
renderingSequence->addRendering( rendering.p() );
if (RiaGuiApplication::instance()->useShaders())
if ( RiaGuiApplication::instance()->useShaders() )
{
// Set up frame and render buffers
// Set up frame and render buffers
cvf::ref<cvf::FramebufferObject> fbo = new cvf::FramebufferObject;
cvf::ref<cvf::RenderbufferObject> rboColor = new cvf::RenderbufferObject(cvf::RenderbufferObject::RGBA, width, height);
cvf::ref<cvf::RenderbufferObject> rboDepth = new cvf::RenderbufferObject(cvf::RenderbufferObject::DEPTH_COMPONENT24, width, height);
cvf::ref<cvf::RenderbufferObject> rboColor = new cvf::RenderbufferObject( cvf::RenderbufferObject::RGBA,
width,
height );
cvf::ref<cvf::RenderbufferObject> rboDepth = new cvf::RenderbufferObject( cvf::RenderbufferObject::DEPTH_COMPONENT24,
width,
height );
fbo->attachDepthRenderbuffer(rboDepth.p());
fbo->attachColorRenderbuffer(0, rboColor.p());
fbo->attachDepthRenderbuffer( rboDepth.p() );
fbo->attachColorRenderbuffer( 0, rboColor.p() );
fbo->applyOpenGL(cvfOglContext);
rendering->setTargetFramebuffer(fbo.p());
fbo->bind(cvfOglContext);
fbo->applyOpenGL( cvfOglContext );
rendering->setTargetFramebuffer( fbo.p() );
fbo->bind( cvfOglContext );
}
renderingSequence->render(cvfOglContext);
renderingSequence->render( cvfOglContext );
// Read data from framebuffer
cvf::UByteArray arr(4*width*height);
glReadPixels(0, 0, static_cast<GLsizei>(width), static_cast<GLsizei>(height), GL_RGBA, GL_UNSIGNED_BYTE, arr.ptr());
cvf::UByteArray arr( 4 * width * height );
glReadPixels( 0, 0, static_cast<GLsizei>( width ), static_cast<GLsizei>( height ), GL_RGBA, GL_UNSIGNED_BYTE, arr.ptr() );
// Create a cvf texture image
cvf::ref<cvf::TextureImage> img = new cvf::TextureImage;
img->setData(arr.ptr(), width, height);
img->setData( arr.ptr(), width, height );
QImage image = cvfqt::Utils::toQImage(*img.p());
//image.save("jjsLegendImageTest.png");
QImage image = cvfqt::Utils::toQImage( *img.p() );
// image.save("jjsLegendImageTest.png");
QPixmap pixmap = QPixmap::fromImage(image);
QPixmap pixmap = QPixmap::fromImage( image );
delete viewer;
m_overlayItemLabel->setPixmap(pixmap);
this->setMinimumSize(QSize(width, height));
this->resize(QSize(width, height));
m_overlayItemLabel->setPixmap( pixmap );
this->setMinimumSize( QSize( width, height ) );
this->resize( QSize( width, height ) );
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -37,11 +37,11 @@ class RiuCvfOverlayItemWidget : public RiuDraggableOverlayFrame
{
Q_OBJECT
public:
explicit RiuCvfOverlayItemWidget(QWidget* parent = nullptr, QWidget* widgetToSnapTo = nullptr);
explicit RiuCvfOverlayItemWidget( QWidget* parent = nullptr, QWidget* widgetToSnapTo = nullptr );
~RiuCvfOverlayItemWidget() override;
void updateFromOverlayItem( caf::TitledOverlayFrame* item);
void updateFromOverlayItem( caf::TitledOverlayFrame* item );
// virtual QSize sizeHint() const override;
// virtual QSize minimumSizeHint() const override;
// virtual QSize sizeHint() const override;
// virtual QSize minimumSizeHint() const override;
};

View File

@@ -161,13 +161,13 @@ QMap<QString, QVariant> RiuDockWidgetTools::widgetVisibilitiesForGeoMech()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QDockWidget* RiuDockWidgetTools::findDockWidget(const QObject* parent, const QString& dockWidgetName)
QDockWidget* RiuDockWidgetTools::findDockWidget( const QObject* parent, const QString& dockWidgetName )
{
QList<QDockWidget*> dockWidgets = parent->findChildren<QDockWidget*>();
for (QDockWidget* dock : dockWidgets)
for ( QDockWidget* dock : dockWidgets )
{
if (dock->objectName() == dockWidgetName)
if ( dock->objectName() == dockWidgetName )
{
return dock;
}
@@ -179,10 +179,10 @@ QDockWidget* RiuDockWidgetTools::findDockWidget(const QObject* parent, const QSt
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QAction* RiuDockWidgetTools::toggleActionForWidget(const QObject* parent, const QString& dockWidgetName)
QAction* RiuDockWidgetTools::toggleActionForWidget( const QObject* parent, const QString& dockWidgetName )
{
auto w = RiuDockWidgetTools::findDockWidget(parent, dockWidgetName);
if (w)
auto w = RiuDockWidgetTools::findDockWidget( parent, dockWidgetName );
if ( w )
{
return w->toggleViewAction();
}
@@ -198,7 +198,7 @@ void RiuDockWidgetTools::setVisibleDockingWindowsForEclipse()
RiuMainWindow* mainWindow = RiuMainWindow::instance();
auto widgetVisibilities = widgetVisibilitiesForEclipse();
applyDockWidgetVisibilities(mainWindow, widgetVisibilities);
applyDockWidgetVisibilities( mainWindow, widgetVisibilities );
}
//--------------------------------------------------------------------------------------------------
@@ -209,33 +209,33 @@ void RiuDockWidgetTools::setVisibleDockingWindowsForGeoMech()
RiuMainWindow* mainWindow = RiuMainWindow::instance();
auto widgetVisibilities = widgetVisibilitiesForGeoMech();
applyDockWidgetVisibilities(mainWindow, widgetVisibilities);
applyDockWidgetVisibilities( mainWindow, widgetVisibilities );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuDockWidgetTools::setDockWidgetVisibility(const QObject* parent, const QString& dockWidgetName, bool isVisible)
void RiuDockWidgetTools::setDockWidgetVisibility( const QObject* parent, const QString& dockWidgetName, bool isVisible )
{
QDockWidget* dockWidget = findDockWidget(parent, dockWidgetName);
if (dockWidget)
QDockWidget* dockWidget = findDockWidget( parent, dockWidgetName );
if ( dockWidget )
{
dockWidget->setVisible(isVisible);
dockWidget->setVisible( isVisible );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QVariant RiuDockWidgetTools::dockWidgetsVisibility(const QObject* parent)
QVariant RiuDockWidgetTools::dockWidgetsVisibility( const QObject* parent )
{
QMap<QString, QVariant> widgetVisibility;
QList<QDockWidget*> dockWidgets = parent->findChildren<QDockWidget*>();
for (QDockWidget* dock : dockWidgets)
for ( QDockWidget* dock : dockWidgets )
{
if (dock)
if ( dock )
{
bool isVisible = dock->isVisible();
widgetVisibility[dock->objectName()] = isVisible;
@@ -244,7 +244,7 @@ QVariant RiuDockWidgetTools::dockWidgetsVisibility(const QObject* parent)
}
}
return QVariant(widgetVisibility);
return QVariant( widgetVisibility );
}
//--------------------------------------------------------------------------------------------------
@@ -252,29 +252,30 @@ QVariant RiuDockWidgetTools::dockWidgetsVisibility(const QObject* parent)
//--------------------------------------------------------------------------------------------------
QVariant RiuDockWidgetTools::defaultDockWidgetVisibilities()
{
return QVariant(widgetVisibilitiesForEclipse());
return QVariant( widgetVisibilitiesForEclipse() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuDockWidgetTools::applyDockWidgetVisibilities(const QObject* parent, const QMap<QString, QVariant>& widgetVisibilities)
void RiuDockWidgetTools::applyDockWidgetVisibilities( const QObject* parent,
const QMap<QString, QVariant>& widgetVisibilities )
{
QList<QDockWidget*> dockWidgets = parent->findChildren<QDockWidget*>();
for (QDockWidget* dock : dockWidgets)
for ( QDockWidget* dock : dockWidgets )
{
if (dock)
if ( dock )
{
bool isVisible = true;
auto widgetVisibility = widgetVisibilities.find(dock->objectName());
if (widgetVisibility != widgetVisibilities.end())
auto widgetVisibility = widgetVisibilities.find( dock->objectName() );
if ( widgetVisibility != widgetVisibilities.end() )
{
isVisible = widgetVisibility.value().toBool();
}
dock->setVisible(isVisible);
dock->setVisible( isVisible );
// qDebug() << "Restore " << dock->objectName() << " : " << (isVisible ? "visible" : "not visible");
}

View File

@@ -49,21 +49,20 @@ public:
static QString plotMainWindowProjectTreeName();
static QString plotMainWindowPropertyEditorName();
static QAction* toggleActionForWidget(const QObject* parent, const QString& dockWidgetName);
static QAction* toggleActionForWidget( const QObject* parent, const QString& dockWidgetName );
static QVariant dockWidgetsVisibility(const QObject* parent);
static QVariant dockWidgetsVisibility( const QObject* parent );
static QVariant defaultDockWidgetVisibilities();
static void setVisibleDockingWindowsForEclipse();
static void setVisibleDockingWindowsForGeoMech();
static void setDockWidgetVisibility(const QObject* parent, const QString& dockWidgetName, bool isVisible);
static void applyDockWidgetVisibilities(const QObject* parent, const QMap<QString, QVariant>& visibilityMap);
static void setDockWidgetVisibility( const QObject* parent, const QString& dockWidgetName, bool isVisible );
static void applyDockWidgetVisibilities( const QObject* parent, const QMap<QString, QVariant>& visibilityMap );
private:
static QMap<QString, QVariant> widgetVisibilitiesForEclipse();
static QMap<QString, QVariant> widgetVisibilitiesForGeoMech();
static QDockWidget* findDockWidget(const QObject* parent, const QString& dockWidgetName);
static QDockWidget* findDockWidget( const QObject* parent, const QString& dockWidgetName );
};

View File

@@ -29,49 +29,49 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuDockedQwtPlot::RiuDockedQwtPlot(QWidget* parent /*= nullptr*/)
: QwtPlot(parent)
RiuDockedQwtPlot::RiuDockedQwtPlot( QWidget* parent /*= nullptr*/ )
: QwtPlot( parent )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuDockedQwtPlot::applyFontSizes(bool replot /*= false*/)
void RiuDockedQwtPlot::applyFontSizes( bool replot /*= false*/ )
{
std::set<QwtPlot::Axis> allAxes = {QwtPlot::xBottom, QwtPlot::yLeft, QwtPlot::xTop, QwtPlot::yRight};
RiaFontCache::FontSize fontSizeEnum = RiaApplication::instance()->preferences()->defaultPlotFontSize();
int fontPointSize = RiaFontCache::pointSizeFromFontSizeEnum(fontSizeEnum) - 1;
int fontPointSize = RiaFontCache::pointSizeFromFontSizeEnum( fontSizeEnum ) - 1;
for (QwtPlot::Axis axis : allAxes)
for ( QwtPlot::Axis axis : allAxes )
{
QwtText text = this->axisTitle(axis);
QwtText text = this->axisTitle( axis );
QFont font = text.font();
font.setPointSize(fontPointSize);
text.setFont(font);
this->setAxisTitle(axis, text);
font.setPointSize( fontPointSize );
text.setFont( font );
this->setAxisTitle( axis, text );
QFont valuesFont = this->axisFont(axis);
valuesFont.setPointSize(fontPointSize);
this->setAxisFont(axis, valuesFont);
QFont valuesFont = this->axisFont( axis );
valuesFont.setPointSize( fontPointSize );
this->setAxisFont( axis, valuesFont );
}
if (legend())
if ( legend() )
{
auto font = legend()->font();
font.setPointSize(fontPointSize);
legend()->setFont(font);
font.setPointSize( fontPointSize );
legend()->setFont( font );
}
QwtText titleText = this->title();
QFont font = titleText.font();
font.setPointSize(fontPointSize + 3);
titleText.setFont(font);
this->setTitle(titleText);
font.setPointSize( fontPointSize + 3 );
titleText.setFont( font );
this->setTitle( titleText );
if (replot)
if ( replot )
{
this->replot();
}

View File

@@ -23,8 +23,7 @@ class RiuDockedQwtPlot : public QwtPlot
{
Q_OBJECT
public:
explicit RiuDockedQwtPlot(QWidget* parent = nullptr);
explicit RiuDockedQwtPlot( QWidget* parent = nullptr );
void applyFontSizes(bool replot);
void applyFontSizes( bool replot );
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -37,54 +37,53 @@
#include "RimWellLogFileChannel.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "RimWellLogTrack.h"
#include "RiuMainWindow.h"
#include "RicWellLogTools.h"
#include "cafPdmUiItem.h"
#include "cafPdmUiTreeView.h"
#include "cafSelectionManager.h"
#include "cafPdmUiItem.h"
#include <QAbstractItemModel>
#include <QModelIndex>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
template <typename T>
class RiuTypedPdmObjects
{
public:
explicit RiuTypedPdmObjects(const caf::PdmObjectGroup& objectGroup)
explicit RiuTypedPdmObjects( const caf::PdmObjectGroup& objectGroup )
{
objectGroup.objectsByType(&m_typedObjects);
objectGroup.objectsByType( &m_typedObjects );
}
explicit RiuTypedPdmObjects(const std::vector<caf::PdmPointer<caf::PdmObjectHandle> >& objectHandles)
explicit RiuTypedPdmObjects( const std::vector<caf::PdmPointer<caf::PdmObjectHandle>>& objectHandles )
{
for (size_t i = 0; i < objectHandles.size(); i++)
for ( size_t i = 0; i < objectHandles.size(); i++ )
{
T* obj = dynamic_cast<T*>(objectHandles[i].p());
if (obj) m_typedObjects.push_back(obj);
T* obj = dynamic_cast<T*>( objectHandles[i].p() );
if ( obj ) m_typedObjects.push_back( obj );
}
}
static std::vector<T*> typedObjectsFromGroup(const caf::PdmObjectGroup& objectGroup)
static std::vector<T*> typedObjectsFromGroup( const caf::PdmObjectGroup& objectGroup )
{
RiuTypedPdmObjects<T> typedObjectsGetter(objectGroup);
RiuTypedPdmObjects<T> typedObjectsGetter( objectGroup );
return typedObjectsGetter.typedObjects();
}
static bool containsTypedObjects(const caf::PdmObjectGroup& objectGroup)
static bool containsTypedObjects( const caf::PdmObjectGroup& objectGroup )
{
RiuTypedPdmObjects<T> typedObjectsGetter(objectGroup);
RiuTypedPdmObjects<T> typedObjectsGetter( objectGroup );
return typedObjectsGetter.typedObjects().size() > 0;
}
static bool containsTypedObjects(const std::vector<caf::PdmPointer<caf::PdmObjectHandle> >& objectHandles)
static bool containsTypedObjects( const std::vector<caf::PdmPointer<caf::PdmObjectHandle>>& objectHandles )
{
RiuTypedPdmObjects<T> typedObjectsGetter(objectHandles);
RiuTypedPdmObjects<T> typedObjectsGetter( objectHandles );
return typedObjectsGetter.typedObjects().size() > 0;
}
@@ -92,21 +91,20 @@ private:
std::vector<T*> typedObjects()
{
std::vector<T*> typedObjectsVec;
for (size_t i = 0; i < m_typedObjects.size(); i++)
for ( size_t i = 0; i < m_typedObjects.size(); i++ )
{
typedObjectsVec.push_back(m_typedObjects[i].p());
typedObjectsVec.push_back( m_typedObjects[i].p() );
}
return typedObjectsVec;
}
private:
std::vector<caf::PdmPointer<T> > m_typedObjects;
std::vector<caf::PdmPointer<T>> m_typedObjects;
};
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuDragDrop::RiuDragDrop()
{
@@ -114,25 +112,23 @@ RiuDragDrop::RiuDragDrop()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuDragDrop::~RiuDragDrop()
{
}
RiuDragDrop::~RiuDragDrop() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
Qt::DropActions RiuDragDrop::supportedDropActions() const
{
// Keep drag items so that we can determine allowed actions while dragging
// Keep drag items so that we can determine allowed actions while dragging
m_dragItems = objectHandlesFromSelection();
if (RiuTypedPdmObjects<RimEclipseCase>::containsTypedObjects(m_dragItems))
if ( RiuTypedPdmObjects<RimEclipseCase>::containsTypedObjects( m_dragItems ) )
{
return Qt::CopyAction | Qt::MoveAction;
}
else if (RiuTypedPdmObjects<RimWellLogFileChannel>::containsTypedObjects(m_dragItems))
else if ( RiuTypedPdmObjects<RimWellLogFileChannel>::containsTypedObjects( m_dragItems ) )
{
return Qt::CopyAction;
}
@@ -141,103 +137,101 @@ Qt::DropActions RiuDragDrop::supportedDropActions() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const
Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const
{
Qt::ItemFlags itemflags = nullptr;
if (index.isValid())
if ( index.isValid() )
{
caf::PdmUiTreeView* uiTreeView = RiuMainWindow::instance()->projectTreeView();
caf::PdmUiItem* uiItem = uiTreeView->uiItemFromModelIndex(index);
caf::PdmUiItem* uiItem = uiTreeView->uiItemFromModelIndex( index );
caf::PdmObject* pdmObj = dynamic_cast<caf::PdmObject*>(uiItem);
if (pdmObj)
caf::PdmObject* pdmObj = dynamic_cast<caf::PdmObject*>( uiItem );
if ( pdmObj )
{
RimWellAllocationPlot* wellAllocationPlot = nullptr;
pdmObj->firstAncestorOrThisOfType(wellAllocationPlot);
if (wellAllocationPlot) return itemflags;
pdmObj->firstAncestorOrThisOfType( wellAllocationPlot );
if ( wellAllocationPlot ) return itemflags;
}
if (dynamic_cast<RimEclipseCase*>(uiItem) ||
dynamic_cast<RimWellLogCurve*>(uiItem) ||
dynamic_cast<RimWellLogFileChannel*>(uiItem) ||
dynamic_cast<RimWellLogTrack*>(uiItem) ||
dynamic_cast<RimSummaryCase*>(uiItem))
if ( dynamic_cast<RimEclipseCase*>( uiItem ) || dynamic_cast<RimWellLogCurve*>( uiItem ) ||
dynamic_cast<RimWellLogFileChannel*>( uiItem ) || dynamic_cast<RimWellLogTrack*>( uiItem ) ||
dynamic_cast<RimSummaryCase*>( uiItem ) )
{
// TODO: Remember to handle reservoir holding the main grid
itemflags |= Qt::ItemIsDragEnabled;
}
if (dynamic_cast<RimEclipseCase*>(uiItem) || dynamic_cast<RimCaseCollection*>(uiItem))
if ( dynamic_cast<RimEclipseCase*>( uiItem ) || dynamic_cast<RimCaseCollection*>( uiItem ) )
{
if (RiuTypedPdmObjects<RimEclipseCase>::containsTypedObjects(m_dragItems))
if ( RiuTypedPdmObjects<RimEclipseCase>::containsTypedObjects( m_dragItems ) )
{
itemflags |= Qt::ItemIsDropEnabled;
}
}
else if (m_proposedDropAction == Qt::MoveAction)
else if ( m_proposedDropAction == Qt::MoveAction )
{
if (dynamic_cast<RimWellLogPlot*>(uiItem))
if ( dynamic_cast<RimWellLogPlot*>( uiItem ) )
{
if (RiuTypedPdmObjects<RimWellLogTrack>::containsTypedObjects(m_dragItems))
if ( RiuTypedPdmObjects<RimWellLogTrack>::containsTypedObjects( m_dragItems ) )
{
itemflags |= Qt::ItemIsDropEnabled;
}
}
else if (dynamic_cast<RimWellLogTrack*>(uiItem))
else if ( dynamic_cast<RimWellLogTrack*>( uiItem ) )
{
if (RiuTypedPdmObjects<RimWellLogCurve>::containsTypedObjects(m_dragItems))
if ( RiuTypedPdmObjects<RimWellLogCurve>::containsTypedObjects( m_dragItems ) )
{
itemflags |= Qt::ItemIsDropEnabled;
}
else if (RiuTypedPdmObjects<RimWellLogTrack>::containsTypedObjects(m_dragItems))
else if ( RiuTypedPdmObjects<RimWellLogTrack>::containsTypedObjects( m_dragItems ) )
{
itemflags |= Qt::ItemIsDropEnabled;
}
}
else if (dynamic_cast<RimWellLogCurve*>(uiItem))
else if ( dynamic_cast<RimWellLogCurve*>( uiItem ) )
{
if (RiuTypedPdmObjects<RimWellLogCurve>::containsTypedObjects(m_dragItems))
if ( RiuTypedPdmObjects<RimWellLogCurve>::containsTypedObjects( m_dragItems ) )
{
itemflags |= Qt::ItemIsDropEnabled;
}
}
else if (dynamic_cast<RimSummaryCase*>(uiItem))
else if ( dynamic_cast<RimSummaryCase*>( uiItem ) )
{
if (RiuTypedPdmObjects<RimSummaryCase>::containsTypedObjects(m_dragItems))
if ( RiuTypedPdmObjects<RimSummaryCase>::containsTypedObjects( m_dragItems ) )
{
itemflags |= Qt::ItemIsDropEnabled;
}
}
else if (dynamic_cast<RimSummaryCaseCollection*>(uiItem))
else if ( dynamic_cast<RimSummaryCaseCollection*>( uiItem ) )
{
if (RiuTypedPdmObjects<RimSummaryCase>::containsTypedObjects(m_dragItems))
if ( RiuTypedPdmObjects<RimSummaryCase>::containsTypedObjects( m_dragItems ) )
{
itemflags |= Qt::ItemIsDropEnabled;
}
}
else if (dynamic_cast<RimSummaryCaseMainCollection*>(uiItem))
else if ( dynamic_cast<RimSummaryCaseMainCollection*>( uiItem ) )
{
if (RiuTypedPdmObjects<RimSummaryCase>::containsTypedObjects(m_dragItems))
if ( RiuTypedPdmObjects<RimSummaryCase>::containsTypedObjects( m_dragItems ) )
{
itemflags |= Qt::ItemIsDropEnabled;
}
}
}
else if (m_proposedDropAction == Qt::CopyAction)
else if ( m_proposedDropAction == Qt::CopyAction )
{
if (dynamic_cast<RimWellLogTrack*>(uiItem))
if ( dynamic_cast<RimWellLogTrack*>( uiItem ) )
{
if (RiuTypedPdmObjects<RimWellLogFileChannel>::containsTypedObjects(m_dragItems))
if ( RiuTypedPdmObjects<RimWellLogFileChannel>::containsTypedObjects( m_dragItems ) )
{
itemflags |= Qt::ItemIsDropEnabled;
}
}
else if (dynamic_cast<RimWellLogCurve*>(uiItem))
else if ( dynamic_cast<RimWellLogCurve*>( uiItem ) )
{
if (RiuTypedPdmObjects<RimWellLogFileChannel>::containsTypedObjects(m_dragItems))
if ( RiuTypedPdmObjects<RimWellLogFileChannel>::containsTypedObjects( m_dragItems ) )
{
itemflags |= Qt::ItemIsDropEnabled;
}
@@ -249,20 +243,20 @@ Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuDragDrop::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
bool RiuDragDrop::dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent )
{
caf::PdmUiTreeView* uiTreeView = RiuMainWindow::instance()->projectTreeView();
caf::PdmUiItem* dropTargetUiItem = uiTreeView->uiItemFromModelIndex(parent);
caf::PdmObjectHandle* dropTarget = dynamic_cast<caf::PdmObjectHandle*>(dropTargetUiItem);
if (dropTarget)
caf::PdmUiTreeView* uiTreeView = RiuMainWindow::instance()->projectTreeView();
caf::PdmUiItem* dropTargetUiItem = uiTreeView->uiItemFromModelIndex( parent );
caf::PdmObjectHandle* dropTarget = dynamic_cast<caf::PdmObjectHandle*>( dropTargetUiItem );
if ( dropTarget )
{
caf::PdmObjectGroup draggedObjects;
const MimeDataWithIndexes* myMimeData = qobject_cast<const MimeDataWithIndexes*>(data);
if (myMimeData && parent.isValid())
caf::PdmObjectGroup draggedObjects;
const MimeDataWithIndexes* myMimeData = qobject_cast<const MimeDataWithIndexes*>( data );
if ( myMimeData && parent.isValid() )
{
objectGroupFromModelIndexes(&draggedObjects, myMimeData->indexes());
objectGroupFromModelIndexes( &draggedObjects, myMimeData->indexes() );
}
else
{
@@ -270,45 +264,45 @@ bool RiuDragDrop::dropMimeData(const QMimeData *data, Qt::DropAction action, int
}
RimIdenticalGridCaseGroup* gridCaseGroup;
dropTarget->firstAncestorOrThisOfType(gridCaseGroup);
if (gridCaseGroup)
dropTarget->firstAncestorOrThisOfType( gridCaseGroup );
if ( gridCaseGroup )
{
return handleGridCaseGroupDrop(action, draggedObjects, gridCaseGroup);
return handleGridCaseGroupDrop( action, draggedObjects, gridCaseGroup );
}
RimWellLogCurve* wellLogPlotCurve;
dropTarget->firstAncestorOrThisOfType(wellLogPlotCurve);
if (wellLogPlotCurve)
dropTarget->firstAncestorOrThisOfType( wellLogPlotCurve );
if ( wellLogPlotCurve )
{
return handleWellLogPlotCurveDrop(action, draggedObjects, wellLogPlotCurve);
return handleWellLogPlotCurveDrop( action, draggedObjects, wellLogPlotCurve );
}
RimWellLogTrack* wellLogPlotTrack;
dropTarget->firstAncestorOrThisOfType(wellLogPlotTrack);
if (wellLogPlotTrack)
dropTarget->firstAncestorOrThisOfType( wellLogPlotTrack );
if ( wellLogPlotTrack )
{
return handleWellLogPlotTrackDrop(action, draggedObjects, wellLogPlotTrack);
return handleWellLogPlotTrackDrop( action, draggedObjects, wellLogPlotTrack );
}
RimWellLogPlot* wellLogPlot;
dropTarget->firstAncestorOrThisOfType(wellLogPlot);
if (wellLogPlot)
dropTarget->firstAncestorOrThisOfType( wellLogPlot );
if ( wellLogPlot )
{
return handleWellLogPlotDrop(action, draggedObjects, wellLogPlot);
return handleWellLogPlotDrop( action, draggedObjects, wellLogPlot );
}
RimSummaryCaseCollection* summaryCaseCollection;
dropTarget->firstAncestorOrThisOfType(summaryCaseCollection);
if (summaryCaseCollection)
dropTarget->firstAncestorOrThisOfType( summaryCaseCollection );
if ( summaryCaseCollection )
{
return handleSummaryCaseCollectionDrop(action, draggedObjects, summaryCaseCollection);
return handleSummaryCaseCollectionDrop( action, draggedObjects, summaryCaseCollection );
}
RimSummaryCaseMainCollection* summaryCaseMainCollection;
dropTarget->firstAncestorOrThisOfType(summaryCaseMainCollection);
if (summaryCaseMainCollection)
dropTarget->firstAncestorOrThisOfType( summaryCaseMainCollection );
if ( summaryCaseMainCollection )
{
return handleSummaryCaseMainCollectionDrop(action, draggedObjects, summaryCaseMainCollection);
return handleSummaryCaseMainCollectionDrop( action, draggedObjects, summaryCaseMainCollection );
}
}
@@ -316,18 +310,18 @@ bool RiuDragDrop::dropMimeData(const QMimeData *data, Qt::DropAction action, int
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QMimeData* RiuDragDrop::mimeData(const QModelIndexList &indexes) const
QMimeData* RiuDragDrop::mimeData( const QModelIndexList& indexes ) const
{
MimeDataWithIndexes* myObj = new MimeDataWithIndexes();
myObj->setIndexes(indexes);
myObj->setIndexes( indexes );
return myObj;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QStringList RiuDragDrop::mimeTypes() const
{
@@ -337,7 +331,7 @@ QStringList RiuDragDrop::mimeTypes() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuDragDrop::onDragCanceled()
{
@@ -345,73 +339,81 @@ void RiuDragDrop::onDragCanceled()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuDragDrop::moveCasesToGridGroup(caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup)
void RiuDragDrop::moveCasesToGridGroup( caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup )
{
std::vector<RimEclipseCase*> casesToBeDeleted = RiuTypedPdmObjects<RimEclipseCase>::typedObjectsFromGroup(objectGroup);
std::vector<RimEclipseCase*> casesToBeDeleted = RiuTypedPdmObjects<RimEclipseCase>::typedObjectsFromGroup(
objectGroup );
if (RicCloseCaseFeature::userConfirmedGridCaseGroupChange(casesToBeDeleted))
if ( RicCloseCaseFeature::userConfirmedGridCaseGroupChange( casesToBeDeleted ) )
{
RicPasteEclipseCasesFeature::addCasesToGridCaseGroup(objectGroup, gridCaseGroup);
for (size_t i = 0; i < casesToBeDeleted.size(); i++)
RicPasteEclipseCasesFeature::addCasesToGridCaseGroup( objectGroup, gridCaseGroup );
for ( size_t i = 0; i < casesToBeDeleted.size(); i++ )
{
RicCloseCaseFeature::deleteEclipseCase(casesToBeDeleted[i]);
RicCloseCaseFeature::deleteEclipseCase( casesToBeDeleted[i] );
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuDragDrop::handleGridCaseGroupDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup)
bool RiuDragDrop::handleGridCaseGroupDrop( Qt::DropAction action,
caf::PdmObjectGroup& objectGroup,
RimIdenticalGridCaseGroup* gridCaseGroup )
{
if (action == Qt::CopyAction)
if ( action == Qt::CopyAction )
{
RicPasteEclipseCasesFeature::addCasesToGridCaseGroup(objectGroup, gridCaseGroup);
RicPasteEclipseCasesFeature::addCasesToGridCaseGroup( objectGroup, gridCaseGroup );
}
else if (action == Qt::MoveAction)
else if ( action == Qt::MoveAction )
{
moveCasesToGridGroup(objectGroup, gridCaseGroup);
moveCasesToGridGroup( objectGroup, gridCaseGroup );
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuDragDrop::handleWellLogPlotTrackDrop(Qt::DropAction action, caf::PdmObjectGroup& draggedObjects, RimWellLogTrack* trackTarget)
bool RiuDragDrop::handleWellLogPlotTrackDrop( Qt::DropAction action,
caf::PdmObjectGroup& draggedObjects,
RimWellLogTrack* trackTarget )
{
std::vector<RimWellLogFileChannel*> wellLogFileChannels = RiuTypedPdmObjects<RimWellLogFileChannel>::typedObjectsFromGroup(draggedObjects);
if (wellLogFileChannels.size() > 0)
std::vector<RimWellLogFileChannel*> wellLogFileChannels = RiuTypedPdmObjects<RimWellLogFileChannel>::typedObjectsFromGroup(
draggedObjects );
if ( wellLogFileChannels.size() > 0 )
{
if (action == Qt::CopyAction)
if ( action == Qt::CopyAction )
{
RicWellLogTools::addWellLogChannelsToPlotTrack(trackTarget, wellLogFileChannels);
RicWellLogTools::addWellLogChannelsToPlotTrack( trackTarget, wellLogFileChannels );
return true;
}
}
std::vector<RimWellLogCurve*> wellLogPlotCurves = RiuTypedPdmObjects<RimWellLogCurve>::typedObjectsFromGroup(draggedObjects);
if (wellLogPlotCurves.size() > 0)
std::vector<RimWellLogCurve*> wellLogPlotCurves = RiuTypedPdmObjects<RimWellLogCurve>::typedObjectsFromGroup(
draggedObjects );
if ( wellLogPlotCurves.size() > 0 )
{
if (action == Qt::MoveAction)
if ( action == Qt::MoveAction )
{
RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(trackTarget, wellLogPlotCurves, nullptr);
RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack( trackTarget, wellLogPlotCurves, nullptr );
return true;
}
}
std::vector<RimWellLogTrack*> wellLogPlotTracks = RiuTypedPdmObjects<RimWellLogTrack>::typedObjectsFromGroup(draggedObjects);
if (wellLogPlotTracks.size() > 0)
std::vector<RimWellLogTrack*> wellLogPlotTracks = RiuTypedPdmObjects<RimWellLogTrack>::typedObjectsFromGroup(
draggedObjects );
if ( wellLogPlotTracks.size() > 0 )
{
if (action == Qt::MoveAction)
if ( action == Qt::MoveAction )
{
RimWellLogPlot* wellLogPlot;
trackTarget->firstAncestorOrThisOfType(wellLogPlot);
RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(wellLogPlot, wellLogPlotTracks, trackTarget);
trackTarget->firstAncestorOrThisOfType( wellLogPlot );
RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot( wellLogPlot, wellLogPlotTracks, trackTarget );
return true;
}
}
@@ -420,16 +422,19 @@ bool RiuDragDrop::handleWellLogPlotTrackDrop(Qt::DropAction action, caf::PdmObje
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuDragDrop::handleWellLogPlotDrop(Qt::DropAction action, caf::PdmObjectGroup& draggedObjects, RimWellLogPlot* wellLogPlotTarget)
bool RiuDragDrop::handleWellLogPlotDrop( Qt::DropAction action,
caf::PdmObjectGroup& draggedObjects,
RimWellLogPlot* wellLogPlotTarget )
{
std::vector<RimWellLogTrack*> wellLogPlotTracks = RiuTypedPdmObjects<RimWellLogTrack>::typedObjectsFromGroup(draggedObjects);
if (wellLogPlotTracks.size() > 0)
std::vector<RimWellLogTrack*> wellLogPlotTracks = RiuTypedPdmObjects<RimWellLogTrack>::typedObjectsFromGroup(
draggedObjects );
if ( wellLogPlotTracks.size() > 0 )
{
if (action == Qt::MoveAction)
if ( action == Qt::MoveAction )
{
RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(wellLogPlotTarget, wellLogPlotTracks, nullptr);
RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot( wellLogPlotTarget, wellLogPlotTracks, nullptr );
return true;
}
}
@@ -438,19 +443,24 @@ bool RiuDragDrop::handleWellLogPlotDrop(Qt::DropAction action, caf::PdmObjectGro
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuDragDrop::handleWellLogPlotCurveDrop(Qt::DropAction action, caf::PdmObjectGroup& draggedObjects, RimWellLogCurve* curveDropTarget)
bool RiuDragDrop::handleWellLogPlotCurveDrop( Qt::DropAction action,
caf::PdmObjectGroup& draggedObjects,
RimWellLogCurve* curveDropTarget )
{
std::vector<RimWellLogCurve*> wellLogPlotCurves = RiuTypedPdmObjects<RimWellLogCurve>::typedObjectsFromGroup(draggedObjects);
if (wellLogPlotCurves.size() > 0)
std::vector<RimWellLogCurve*> wellLogPlotCurves = RiuTypedPdmObjects<RimWellLogCurve>::typedObjectsFromGroup(
draggedObjects );
if ( wellLogPlotCurves.size() > 0 )
{
if (action == Qt::MoveAction)
if ( action == Qt::MoveAction )
{
RimWellLogTrack* wellLogPlotTrack;
curveDropTarget->firstAncestorOrThisOfType(wellLogPlotTrack);
curveDropTarget->firstAncestorOrThisOfType( wellLogPlotTrack );
RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(wellLogPlotTrack, wellLogPlotCurves, curveDropTarget);
RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack( wellLogPlotTrack,
wellLogPlotCurves,
curveDropTarget );
return true;
}
}
@@ -459,33 +469,36 @@ bool RiuDragDrop::handleWellLogPlotCurveDrop(Qt::DropAction action, caf::PdmObje
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuDragDrop::handleSummaryCaseCollectionDrop(Qt::DropAction action, caf::PdmObjectGroup& draggedObjects, RimSummaryCaseCollection* summaryCaseDropTarget)
bool RiuDragDrop::handleSummaryCaseCollectionDrop( Qt::DropAction action,
caf::PdmObjectGroup& draggedObjects,
RimSummaryCaseCollection* summaryCaseDropTarget )
{
std::vector<RimSummaryCase*> summaryCases = RiuTypedPdmObjects<RimSummaryCase>::typedObjectsFromGroup(draggedObjects);
std::vector<RimSummaryCase*> summaryCases = RiuTypedPdmObjects<RimSummaryCase>::typedObjectsFromGroup(
draggedObjects );
if (action != Qt::MoveAction || summaryCases.size() == 0) return false;
if ( action != Qt::MoveAction || summaryCases.size() == 0 ) return false;
for (RimSummaryCase* summaryCase : summaryCases)
for ( RimSummaryCase* summaryCase : summaryCases )
{
RimSummaryCaseCollection* summaryCaseCollection;
summaryCase->firstAncestorOrThisOfType(summaryCaseCollection);
if (summaryCaseCollection)
summaryCase->firstAncestorOrThisOfType( summaryCaseCollection );
if ( summaryCaseCollection )
{
summaryCaseCollection->removeCase(summaryCase);
summaryCaseDropTarget->addCase(summaryCase);
summaryCaseCollection->removeCase( summaryCase );
summaryCaseDropTarget->addCase( summaryCase );
summaryCaseCollection->updateConnectedEditors();
continue;
}
RimSummaryCaseMainCollection* summaryCaseMainCollection;
summaryCase->firstAncestorOrThisOfType(summaryCaseMainCollection);
if (summaryCaseMainCollection)
summaryCase->firstAncestorOrThisOfType( summaryCaseMainCollection );
if ( summaryCaseMainCollection )
{
summaryCaseMainCollection->removeCase(summaryCase);
summaryCaseDropTarget->addCase(summaryCase);
summaryCaseMainCollection->removeCase( summaryCase );
summaryCaseDropTarget->addCase( summaryCase );
summaryCaseMainCollection->updateConnectedEditors();
}
}
@@ -494,75 +507,78 @@ bool RiuDragDrop::handleSummaryCaseCollectionDrop(Qt::DropAction action, caf::Pd
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuDragDrop::handleSummaryCaseMainCollectionDrop(Qt::DropAction action, caf::PdmObjectGroup& draggedObjects, RimSummaryCaseMainCollection* summaryCaseDropTarget)
bool RiuDragDrop::handleSummaryCaseMainCollectionDrop( Qt::DropAction action,
caf::PdmObjectGroup& draggedObjects,
RimSummaryCaseMainCollection* summaryCaseDropTarget )
{
std::vector<RimSummaryCase*> summaryCases = RiuTypedPdmObjects<RimSummaryCase>::typedObjectsFromGroup(draggedObjects);
if (action != Qt::MoveAction || summaryCases.size() == 0 ) return false;
std::vector<RimSummaryCase*> summaryCases = RiuTypedPdmObjects<RimSummaryCase>::typedObjectsFromGroup(
draggedObjects );
for (RimSummaryCase* summaryCase : summaryCases)
if ( action != Qt::MoveAction || summaryCases.size() == 0 ) return false;
for ( RimSummaryCase* summaryCase : summaryCases )
{
RimSummaryCaseCollection* summaryCaseCollection;
summaryCase->firstAncestorOrThisOfType(summaryCaseCollection);
summaryCase->firstAncestorOrThisOfType( summaryCaseCollection );
if (summaryCaseCollection)
if ( summaryCaseCollection )
{
summaryCaseCollection->removeCase(summaryCase);
summaryCaseDropTarget->addCase(summaryCase);
summaryCaseCollection->removeCase( summaryCase );
summaryCaseDropTarget->addCase( summaryCase );
summaryCaseCollection->updateConnectedEditors();
}
}
summaryCaseDropTarget->updateConnectedEditors();
return true;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuDragDrop::objectGroupFromModelIndexes(caf::PdmObjectGroup* objectGroup, const QModelIndexList& indexes)
void RiuDragDrop::objectGroupFromModelIndexes( caf::PdmObjectGroup* objectGroup, const QModelIndexList& indexes )
{
CVF_ASSERT(objectGroup);
CVF_ASSERT( objectGroup );
objectGroup->objects.clear();
caf::PdmUiTreeView* uiTreeView = RiuMainWindow::instance()->projectTreeView();
for (int i = 0; i < indexes.size(); i++)
for ( int i = 0; i < indexes.size(); i++ )
{
caf::PdmUiItem* uiItem = uiTreeView->uiItemFromModelIndex(indexes[i]);
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(uiItem);
if (objHandle)
caf::PdmUiItem* uiItem = uiTreeView->uiItemFromModelIndex( indexes[i] );
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>( uiItem );
if ( objHandle )
{
objectGroup->objects.push_back(objHandle);
objectGroup->objects.push_back( objHandle );
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<caf::PdmPointer<caf::PdmObjectHandle> > RiuDragDrop::objectHandlesFromSelection()
std::vector<caf::PdmPointer<caf::PdmObjectHandle>> RiuDragDrop::objectHandlesFromSelection()
{
std::vector<caf::PdmObjectHandle*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
caf::SelectionManager::instance()->objectsByType( &selection );
std::vector<caf::PdmPointer<caf::PdmObjectHandle> > objectHandles;
std::vector<caf::PdmPointer<caf::PdmObjectHandle>> objectHandles;
for (size_t sIdx = 0; sIdx < selection.size(); sIdx++)
for ( size_t sIdx = 0; sIdx < selection.size(); sIdx++ )
{
objectHandles.push_back(selection[sIdx]);
objectHandles.push_back( selection[sIdx] );
}
return objectHandles;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuDragDrop::onProposedDropActionUpdated(Qt::DropAction action)
void RiuDragDrop::onProposedDropActionUpdated( Qt::DropAction action )
{
m_proposedDropAction = action;
}

View File

@@ -1,32 +1,32 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmUiDragDropInterface.h"
#include "cafPdmPointer.h"
#include "cafPdmObjectGroup.h"
#include "cafPdmPointer.h"
#include "cafPdmUiDragDropInterface.h"
#include <vector>
namespace caf
{
class PdmObjectHandle;
class PdmObjectHandle;
}
class RimIdenticalGridCaseGroup;
@@ -37,38 +37,47 @@ class RimWellLogTrack;
class RimWellLogCurve;
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
class RiuDragDrop : public caf::PdmUiDragDropInterface
{
public:
RiuDragDrop();
~RiuDragDrop() override;
protected:
Qt::DropActions supportedDropActions() const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
QMimeData* mimeData(const QModelIndexList &indexes) const override;
Qt::ItemFlags flags( const QModelIndex& index ) const override;
bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent ) override;
QMimeData* mimeData( const QModelIndexList& indexes ) const override;
QStringList mimeTypes() const override;
void onDragCanceled() override;
void onProposedDropActionUpdated(Qt::DropAction action) override;
void onProposedDropActionUpdated( Qt::DropAction action ) override;
private:
void moveCasesToGridGroup(caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup);
bool handleGridCaseGroupDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup);
bool handleWellLogPlotTrackDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimWellLogTrack* wellLogPlotTrack);
bool handleWellLogPlotDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimWellLogPlot* wellLogPlot);
bool handleWellLogPlotCurveDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimWellLogCurve* wellLogPlotCurve);
bool handleSummaryCaseCollectionDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimSummaryCaseCollection* summaryCaseCollection);
bool handleSummaryCaseMainCollectionDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimSummaryCaseMainCollection* summaryCaseMainCollection);
void moveCasesToGridGroup( caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup );
bool handleGridCaseGroupDrop( Qt::DropAction action,
caf::PdmObjectGroup& objectGroup,
RimIdenticalGridCaseGroup* gridCaseGroup );
bool handleWellLogPlotTrackDrop( Qt::DropAction action,
caf::PdmObjectGroup& objectGroup,
RimWellLogTrack* wellLogPlotTrack );
bool handleWellLogPlotDrop( Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimWellLogPlot* wellLogPlot );
bool handleWellLogPlotCurveDrop( Qt::DropAction action,
caf::PdmObjectGroup& objectGroup,
RimWellLogCurve* wellLogPlotCurve );
bool handleSummaryCaseCollectionDrop( Qt::DropAction action,
caf::PdmObjectGroup& objectGroup,
RimSummaryCaseCollection* summaryCaseCollection );
bool handleSummaryCaseMainCollectionDrop( Qt::DropAction action,
caf::PdmObjectGroup& objectGroup,
RimSummaryCaseMainCollection* summaryCaseMainCollection );
static void objectGroupFromModelIndexes(caf::PdmObjectGroup* objectGroup, const QModelIndexList &indexes);
static std::vector<caf::PdmPointer<caf::PdmObjectHandle> > objectHandlesFromSelection();
static void objectGroupFromModelIndexes( caf::PdmObjectGroup* objectGroup, const QModelIndexList& indexes );
static std::vector<caf::PdmPointer<caf::PdmObjectHandle>> objectHandlesFromSelection();
private:
mutable std::vector<caf::PdmPointer<caf::PdmObjectHandle> > m_dragItems;
Qt::DropAction m_proposedDropAction;
mutable std::vector<caf::PdmPointer<caf::PdmObjectHandle>> m_dragItems;
Qt::DropAction m_proposedDropAction;
};

View File

@@ -25,31 +25,31 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuDraggableOverlayFrame::RiuDraggableOverlayFrame(QWidget* parent, QWidget* widgetToSnapTo, const QColor& backgroundColor)
: QFrame(parent)
RiuDraggableOverlayFrame::RiuDraggableOverlayFrame( QWidget* parent, QWidget* widgetToSnapTo, const QColor& backgroundColor )
: QFrame( parent )
{
RiuWidgetDragger* dragger = new RiuWidgetDragger(this, widgetToSnapTo);
RiuWidgetDragger* dragger = new RiuWidgetDragger( this, widgetToSnapTo );
QPalette pal = this->palette();
pal.setColor(QPalette::Background, backgroundColor);
setAutoFillBackground(true);
setPalette(pal);
setFrameShape(QFrame::Box);
QGraphicsDropShadowEffect* dropShadowEffect = new QGraphicsDropShadowEffect(this);
dropShadowEffect->setOffset(1.0, 1.0);
dropShadowEffect->setBlurRadius(3.0);
dropShadowEffect->setColor(QColor(100, 100, 100, 100));
setGraphicsEffect(dropShadowEffect);
pal.setColor( QPalette::Background, backgroundColor );
setAutoFillBackground( true );
setPalette( pal );
setFrameShape( QFrame::Box );
QGraphicsDropShadowEffect* dropShadowEffect = new QGraphicsDropShadowEffect( this );
dropShadowEffect->setOffset( 1.0, 1.0 );
dropShadowEffect->setBlurRadius( 3.0 );
dropShadowEffect->setColor( QColor( 100, 100, 100, 100 ) );
setGraphicsEffect( dropShadowEffect );
auto hblayout = new QVBoxLayout(this);
this->setLayout(hblayout);
auto hblayout = new QVBoxLayout( this );
this->setLayout( hblayout );
m_overlayItemLabel = new QLabel(this);
hblayout->addWidget(m_overlayItemLabel);
m_overlayItemLabel->setObjectName("OverlayFrameLabel");
m_overlayItemLabel->setGraphicsEffect(nullptr);
m_overlayItemLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
dragger->addWidget(m_overlayItemLabel);
m_overlayItemLabel = new QLabel( this );
hblayout->addWidget( m_overlayItemLabel );
m_overlayItemLabel->setObjectName( "OverlayFrameLabel" );
m_overlayItemLabel->setGraphicsEffect( nullptr );
m_overlayItemLabel->setAlignment( Qt::AlignTop | Qt::AlignLeft );
dragger->addWidget( m_overlayItemLabel );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -27,7 +27,9 @@ class RiuDraggableOverlayFrame : public QFrame
{
Q_OBJECT
public:
RiuDraggableOverlayFrame(QWidget* parent, QWidget* widgetToSnapTo = nullptr, const QColor& backgroundColor = QColor(255, 255, 255, 100));
RiuDraggableOverlayFrame( QWidget* parent,
QWidget* widgetToSnapTo = nullptr,
const QColor& backgroundColor = QColor( 255, 255, 255, 100 ) );
QLabel* label();
protected:

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -29,78 +29,80 @@
#include <QAbstractItemView>
#include <QBoxLayout>
#include <QDialogButtonBox>
#include <QHeaderView>
#include <QMenu>
#include <QTableView>
#include <QWidget>
#include <QHeaderView>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuEditPerforationCollectionWidget::RiuEditPerforationCollectionWidget(QWidget* parent, RimPerforationCollection* perforationCollection)
: QDialog(parent, RiuTools::defaultDialogFlags()),
m_perforationCollection(perforationCollection)
RiuEditPerforationCollectionWidget::RiuEditPerforationCollectionWidget( QWidget* parent,
RimPerforationCollection* perforationCollection )
: QDialog( parent, RiuTools::defaultDialogFlags() )
, m_perforationCollection( perforationCollection )
{
setWindowTitle("Edit Perforation Intervals");
setWindowTitle( "Edit Perforation Intervals" );
QVBoxLayout* dialogLayout = new QVBoxLayout;
setLayout(dialogLayout);
setLayout( dialogLayout );
m_pdmTableView = new caf::PdmUiTableView(this);
m_pdmTableView->tableView()->setSelectionMode(QAbstractItemView::ExtendedSelection);
m_pdmTableView->tableView()->setContextMenuPolicy(Qt::CustomContextMenu);
m_pdmTableView->enableHeaderText(false);
m_pdmTableView = new caf::PdmUiTableView( this );
m_pdmTableView->tableView()->setSelectionMode( QAbstractItemView::ExtendedSelection );
m_pdmTableView->tableView()->setContextMenuPolicy( Qt::CustomContextMenu );
m_pdmTableView->enableHeaderText( false );
connect(m_pdmTableView->tableView(), SIGNAL(customContextMenuRequested(QPoint)), SLOT(customMenuRequested(QPoint)));
connect( m_pdmTableView->tableView(),
SIGNAL( customContextMenuRequested( QPoint ) ),
SLOT( customMenuRequested( QPoint ) ) );
m_pdmTableView->setChildArrayField(&(m_perforationCollection->m_perforations));
m_pdmTableView->setChildArrayField( &( m_perforationCollection->m_perforations ) );
QHeaderView* verticalHeader = m_pdmTableView->tableView()->verticalHeader();
#if QT_VERSION >= 0x050000
verticalHeader->setSectionResizeMode(QHeaderView::Interactive);
verticalHeader->setSectionResizeMode( QHeaderView::Interactive );
#else
verticalHeader->setResizeMode(QHeaderView::Interactive);
verticalHeader->setResizeMode( QHeaderView::Interactive );
#endif
m_pdmTableView->tableView()->resizeColumnsToContents();
// Set active child array to be able to use generic delete
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle(&(m_perforationCollection->m_perforations));
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle( &( m_perforationCollection->m_perforations ) );
dialogLayout->addWidget(m_pdmTableView);
dialogLayout->addWidget( m_pdmTableView );
// Buttons
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Close );
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
dialogLayout->addWidget(buttonBox);
dialogLayout->addWidget( buttonBox );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuEditPerforationCollectionWidget::~RiuEditPerforationCollectionWidget()
{
m_pdmTableView->setChildArrayField(nullptr);
m_pdmTableView->setChildArrayField( nullptr );
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle(nullptr);
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle( nullptr );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuEditPerforationCollectionWidget::customMenuRequested(QPoint pos)
void RiuEditPerforationCollectionWidget::customMenuRequested( QPoint pos )
{
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
QMenu menu;
menu.addAction(commandManager->action("PdmListField_AddItem","New row"));
menu.addAction(commandManager->action("PdmListField_DeleteItem","Delete row"));
// Qt doc: QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the viewport().
QPoint globalPos = m_pdmTableView->tableView()->viewport()->mapToGlobal(pos);
menu.addAction( commandManager->action( "PdmListField_AddItem", "New row" ) );
menu.addAction( commandManager->action( "PdmListField_DeleteItem", "Delete row" ) );
menu.exec(globalPos);
// Qt doc: QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the viewport().
QPoint globalPos = m_pdmTableView->tableView()->viewport()->mapToGlobal( pos );
menu.exec( globalPos );
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -24,8 +24,9 @@ class RimProject;
class RimPerforationCollection;
namespace caf {
class PdmUiTableView;
namespace caf
{
class PdmUiTableView;
}
class QWidget;
@@ -35,13 +36,13 @@ class RiuEditPerforationCollectionWidget : public QDialog
{
Q_OBJECT
public:
RiuEditPerforationCollectionWidget(QWidget* parent, RimPerforationCollection* perforationCollection);
RiuEditPerforationCollectionWidget( QWidget* parent, RimPerforationCollection* perforationCollection );
~RiuEditPerforationCollectionWidget() override;
private slots:
void customMenuRequested(QPoint pos);
void customMenuRequested( QPoint pos );
private:
RimPerforationCollection* m_perforationCollection;
caf::PdmUiTableView* m_pdmTableView;
RimPerforationCollection* m_perforationCollection;
caf::PdmUiTableView* m_pdmTableView;
};

View File

@@ -1,128 +1,100 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiuExpressionContextMenuManager.h"
#include <QTextEdit>
#include <QMenu>
#include <QTextEdit>
const std::map<QString, std::set<QString>> RiuExpressionContextMenuManager::MENU_MAP =
{
{
"Basic Operators",
{
"+", "-", "*", "/", "x^n"
}
},
{
"Assignment Operators",
{
":="
}
},
{
"Scalar Functions",
{
"avg(x)", "max(x)", "min(x)", "sum(x)"
}
},
{
"Vector Functions",
{
"abs(x)", "ceil(x)", "floor(x)", "frac(x)",
"log(x)", "log10(x)", "pow(x, n)", "round(x)",
"sgn(x)", "sqrt(x)", "trunc(x)"
}
},
{
"Trigonometry Functions",
{
"acos(x)", "acosh(x)", "asin(x)", "asinh(x)", "atan(x)", "atanh(x)",
"cos(x)", "cosh(x)", "cot(x)", "csc(x)", "sec(x)", "sin(x)", "sinc(x)", "sinh(x)",
"tan(x)", "tanh(x)", "rad2deg(x)", "deg2grad(x)", "deg2rad(x)", "grad2deg(x)"
}
}
};
{{"Basic Operators", {"+", "-", "*", "/", "x^n"}},
{"Assignment Operators", {":="}},
{"Scalar Functions", {"avg(x)", "max(x)", "min(x)", "sum(x)"}},
{"Vector Functions",
{"abs(x)", "ceil(x)", "floor(x)", "frac(x)", "log(x)", "log10(x)", "pow(x, n)", "round(x)", "sgn(x)", "sqrt(x)", "trunc(x)"}},
{"Trigonometry Functions",
{"acos(x)", "acosh(x)", "asin(x)", "asinh(x)", "atan(x)", "atanh(x)", "cos(x)",
"cosh(x)", "cot(x)", "csc(x)", "sec(x)", "sin(x)", "sinc(x)", "sinh(x)",
"tan(x)", "tanh(x)", "rad2deg(x)", "deg2grad(x)", "deg2rad(x)", "grad2deg(x)"}}};
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuExpressionContextMenuManager::attachTextEdit(QTextEdit* textEdit)
void RiuExpressionContextMenuManager::attachTextEdit( QTextEdit* textEdit )
{
if (m_textEdit != textEdit)
if ( m_textEdit != textEdit )
{
textEdit->setContextMenuPolicy(Qt::CustomContextMenu);
QObject::connect(textEdit, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotMenuItems(QPoint)));
textEdit->setContextMenuPolicy( Qt::CustomContextMenu );
QObject::connect( textEdit, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( slotMenuItems( QPoint ) ) );
}
m_textEdit = textEdit;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuExpressionContextMenuManager::slotMenuItems(QPoint point)
void RiuExpressionContextMenuManager::slotMenuItems( QPoint point )
{
QMenu menu;
for (const std::pair<QString, std::set<QString>>& subMenuPair : MENU_MAP)
for ( const std::pair<QString, std::set<QString>>& subMenuPair : MENU_MAP )
{
QMenu* subMenu = menu.addMenu(subMenuPair.first);
QMenu* subMenu = menu.addMenu( subMenuPair.first );
for (const QString& menuItemText : subMenuPair.second)
for ( const QString& menuItemText : subMenuPair.second )
{
if (m_actionCache.count(menuItemText) == 0)
if ( m_actionCache.count( menuItemText ) == 0 )
{
QAction* action = new QAction(menuItemText, this);
connect(action, SIGNAL(triggered()), SLOT(slotShowText()));
m_actionCache.insert(std::make_pair(menuItemText, std::unique_ptr<QAction>(action)));
QAction* action = new QAction( menuItemText, this );
connect( action, SIGNAL( triggered() ), SLOT( slotShowText() ) );
m_actionCache.insert( std::make_pair( menuItemText, std::unique_ptr<QAction>( action ) ) );
}
subMenu->addAction(m_actionCache[menuItemText].get());
subMenu->addAction( m_actionCache[menuItemText].get() );
}
}
QPoint globalPoint = point;
if (m_textEdit)
if ( m_textEdit )
{
globalPoint = m_textEdit->mapToGlobal(point);
globalPoint = m_textEdit->mapToGlobal( point );
m_textPosition = m_textEdit->textCursor().position();
}
menu.exec(globalPoint);
menu.exec( globalPoint );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuExpressionContextMenuManager::slotShowText()
{
if (m_textEdit)
if ( m_textEdit )
{
QAction* action = qobject_cast<QAction *>(sender());
if (action)
QAction* action = qobject_cast<QAction*>( sender() );
if ( action )
{
QTextCursor cursor = m_textEdit->textCursor();
cursor.setPosition(m_textPosition);
cursor.setPosition( m_textPosition );
m_textEdit->setTextCursor(cursor);
m_textEdit->insertPlainText(action->text());
m_textEdit->setTextCursor( cursor );
m_textEdit->insertPlainText( action->text() );
}
}
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -19,35 +19,35 @@
#pragma once
#include "cafPdmChildArrayField.h"
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include <QPointer>
#include "cafPdmObject.h"
#include <QAction>
#include <QPointer>
#include <memory>
class RimSummaryCalculationVariable;
class QTextEdit;
//==================================================================================================
///
///
///
///
//==================================================================================================
class RiuExpressionContextMenuManager : public QObject
{
Q_OBJECT
static const std::map<QString, std::set<QString>> MENU_MAP;
static const std::map<QString, std::set<QString>> MENU_MAP;
public:
RiuExpressionContextMenuManager()
: m_textPosition(0)
: m_textPosition( 0 )
{
}
void attachTextEdit(QTextEdit* textEdit);
void attachTextEdit( QTextEdit* textEdit );
public slots:
void slotMenuItems(QPoint point);
void slotMenuItems( QPoint point );
private slots:
void slotShowText();

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -38,63 +38,61 @@
#include "cafDisplayCoordTransform.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuFemResultTextBuilder::RiuFemResultTextBuilder(RimGeoMechView* reservoirView,
int gridIndex,
int cellIndex,
int timeStepIndex)
: m_isIntersectionTriangleSet(false)
RiuFemResultTextBuilder::RiuFemResultTextBuilder( RimGeoMechView* reservoirView,
int gridIndex,
int cellIndex,
int timeStepIndex )
: m_isIntersectionTriangleSet( false )
{
CVF_ASSERT(reservoirView);
CVF_ASSERT( reservoirView );
m_reservoirView = reservoirView;
m_gridIndex = gridIndex;
m_cellIndex = cellIndex;
m_gridIndex = gridIndex;
m_cellIndex = cellIndex;
m_timeStepIndex = timeStepIndex;
m_intersectionPointInDisplay = cvf::Vec3d::UNDEFINED;
m_face = cvf::StructGridInterface::NO_FACE;
m_face = cvf::StructGridInterface::NO_FACE;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFemResultTextBuilder::setIntersectionPointInDisplay(cvf::Vec3d intersectionPointInDisplay)
void RiuFemResultTextBuilder::setIntersectionPointInDisplay( cvf::Vec3d intersectionPointInDisplay )
{
m_intersectionPointInDisplay = intersectionPointInDisplay;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFemResultTextBuilder::setIntersectionTriangle(const std::array<cvf::Vec3f, 3>& triangle)
void RiuFemResultTextBuilder::setIntersectionTriangle( const std::array<cvf::Vec3f, 3>& triangle )
{
m_intersectionTriangle = triangle;
m_intersectionTriangle = triangle;
m_isIntersectionTriangleSet = true;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFemResultTextBuilder::set2dIntersectionView(Rim2dIntersectionView* intersectionView)
void RiuFemResultTextBuilder::set2dIntersectionView( Rim2dIntersectionView* intersectionView )
{
m_2dIntersectionView = intersectionView;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFemResultTextBuilder::setFace(int face)
void RiuFemResultTextBuilder::setFace( int face )
{
m_face = face;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QString RiuFemResultTextBuilder::mainResultText()
{
@@ -102,74 +100,80 @@ QString RiuFemResultTextBuilder::mainResultText()
RimGeoMechResultDefinition* cellResultDefinition = m_reservoirView->cellResultResultDefinition();
text = closestNodeResultText(cellResultDefinition);
text = closestNodeResultText( cellResultDefinition );
if (!text.isEmpty()) text += "\n";
if ( !text.isEmpty() ) text += "\n";
QString topoText = this->geometrySelectionText("\n");
QString topoText = this->geometrySelectionText( "\n" );
text += topoText;
appendDetails(text, formationDetails());
appendDetails( text, formationDetails() );
text += "\n";
if (cellResultDefinition->resultPositionType() != RIG_ELEMENT)
if ( cellResultDefinition->resultPositionType() != RIG_ELEMENT )
{
appendDetails(text, gridResultDetails());
appendDetails( text, gridResultDetails() );
}
return text;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QString RiuFemResultTextBuilder::geometrySelectionText(QString itemSeparator)
QString RiuFemResultTextBuilder::geometrySelectionText( QString itemSeparator )
{
QString text;
if (m_reservoirView->geoMechCase())
if ( m_reservoirView->geoMechCase() )
{
RigGeoMechCaseData* geomData = m_reservoirView->geoMechCase()->geoMechData();
if (geomData)
if ( geomData )
{
RigFemPart* femPart = geomData->femParts()->part(m_gridIndex);
int elementId = femPart->elmId(m_cellIndex);
auto elementType = femPart->elementType(m_cellIndex);
RigFemPart* femPart = geomData->femParts()->part( m_gridIndex );
int elementId = femPart->elmId( m_cellIndex );
auto elementType = femPart->elementType( m_cellIndex );
text += QString("Element : Id[%1], Type[%2]").arg(elementId).arg(RigFemTypes::elementTypeText(elementType));
text += QString( "Element : Id[%1], Type[%2]" ).arg( elementId ).arg( RigFemTypes::elementTypeText( elementType ) );
size_t i = 0;
size_t j = 0;
size_t k = 0;
if (geomData->femParts()->part(m_gridIndex)->getOrCreateStructGrid()->ijkFromCellIndex(m_cellIndex, &i, &j, &k))
if ( geomData->femParts()->part( m_gridIndex )->getOrCreateStructGrid()->ijkFromCellIndex( m_cellIndex, &i, &j, &k ) )
{
// Adjust to 1-based Eclipse indexing
i++;
j++;
k++;
text += QString(", ijk[%1, %2, %3]").arg(i).arg(j).arg(k) + itemSeparator;
text += QString( ", ijk[%1, %2, %3]" ).arg( i ).arg( j ).arg( k ) + itemSeparator;
QString formattedText;
if (m_2dIntersectionView)
if ( m_2dIntersectionView )
{
formattedText.sprintf("Horizontal length from well start: %.2f", m_intersectionPointInDisplay.x());
formattedText.sprintf( "Horizontal length from well start: %.2f", m_intersectionPointInDisplay.x() );
text += formattedText + itemSeparator;
cvf::Mat4d t = m_2dIntersectionView->flatIntersectionPartMgr()->unflattenTransformMatrix(m_intersectionPointInDisplay);
if (!t.isZero())
cvf::Mat4d t = m_2dIntersectionView->flatIntersectionPartMgr()->unflattenTransformMatrix(
m_intersectionPointInDisplay );
if ( !t.isZero() )
{
cvf::Vec3d intPt = m_intersectionPointInDisplay.getTransformedPoint(t);
formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", intPt.x(), intPt.y(), -intPt.z());
cvf::Vec3d intPt = m_intersectionPointInDisplay.getTransformedPoint( t );
formattedText.sprintf( "Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]",
intPt.x(),
intPt.y(),
-intPt.z() );
text += formattedText;
}
}
else
{
cvf::ref<caf::DisplayCoordTransform> transForm = m_reservoirView->displayCoordTransform();
cvf::Vec3d domainCoord = transForm->translateToDomainCoord(m_intersectionPointInDisplay);
cvf::Vec3d domainCoord = transForm->translateToDomainCoord( m_intersectionPointInDisplay );
formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z());
formattedText.sprintf( "Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]",
domainCoord.x(),
domainCoord.y(),
-domainCoord.z() );
text += formattedText;
}
}
@@ -180,42 +184,46 @@ QString RiuFemResultTextBuilder::geometrySelectionText(QString itemSeparator)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QString RiuFemResultTextBuilder::gridResultDetails()
{
QString text;
if (m_reservoirView->geoMechCase() && m_reservoirView->geoMechCase()->geoMechData())
if ( m_reservoirView->geoMechCase() && m_reservoirView->geoMechCase()->geoMechData() )
{
RigGeoMechCaseData* eclipseCaseData = m_reservoirView->geoMechCase()->geoMechData();
this->appendTextFromResultColors(eclipseCaseData, m_gridIndex, m_cellIndex, m_timeStepIndex, m_reservoirView->cellResultResultDefinition(), &text);
this->appendTextFromResultColors( eclipseCaseData,
m_gridIndex,
m_cellIndex,
m_timeStepIndex,
m_reservoirView->cellResultResultDefinition(),
&text );
if (!text.isEmpty())
if ( !text.isEmpty() )
{
text.prepend("-- Element result details --\n");
text.prepend( "-- Element result details --\n" );
}
}
return text;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QString RiuFemResultTextBuilder::formationDetails()
{
QString text;
QString text;
RimCase* rimCase = m_reservoirView->ownerCase();
if(rimCase)
if ( rimCase )
{
if(rimCase->activeFormationNames() && rimCase->activeFormationNames()->formationNamesData())
if ( rimCase->activeFormationNames() && rimCase->activeFormationNames()->formationNamesData() )
{
RigFormationNames* formNames = rimCase->activeFormationNames()->formationNamesData();
size_t k = cvf::UNDEFINED_SIZE_T;
size_t k = cvf::UNDEFINED_SIZE_T;
{
if ( m_reservoirView->geoMechCase() )
{
@@ -224,19 +232,22 @@ QString RiuFemResultTextBuilder::formationDetails()
{
size_t i = 0;
size_t j = 0;
geomData->femParts()->part(m_gridIndex)->getOrCreateStructGrid()->ijkFromCellIndex(m_cellIndex, &i, &j, &k);
geomData->femParts()
->part( m_gridIndex )
->getOrCreateStructGrid()
->ijkFromCellIndex( m_cellIndex, &i, &j, &k );
}
}
}
if(k != cvf::UNDEFINED_SIZE_T)
if ( k != cvf::UNDEFINED_SIZE_T )
{
QString formName = formNames->formationNameFromKLayerIdx(k);
if(!formName.isEmpty())
QString formName = formNames->formationNameFromKLayerIdx( k );
if ( !formName.isEmpty() )
{
//text += "-- Formation details --\n";
// text += "-- Formation details --\n";
text += QString("Formation Name: %1\n").arg(formName);
text += QString( "Formation Name: %1\n" ).arg( formName );
}
}
}
@@ -245,117 +256,125 @@ QString RiuFemResultTextBuilder::formationDetails()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFemResultTextBuilder::appendTextFromResultColors(RigGeoMechCaseData* geomData, int gridIndex, int cellIndex, int timeStepIndex, RimGeoMechResultDefinition* resultDefinition, QString* resultInfoText)
void RiuFemResultTextBuilder::appendTextFromResultColors( RigGeoMechCaseData* geomData,
int gridIndex,
int cellIndex,
int timeStepIndex,
RimGeoMechResultDefinition* resultDefinition,
QString* resultInfoText )
{
if (!resultDefinition)
if ( !resultDefinition )
{
return;
}
if (resultDefinition->hasResult())
if ( resultDefinition->hasResult() )
{
const std::vector<float>& scalarResults = geomData->femPartResults()->resultValues(resultDefinition->resultAddress(), gridIndex, timeStepIndex);
if (scalarResults.size())
const std::vector<float>& scalarResults =
geomData->femPartResults()->resultValues( resultDefinition->resultAddress(), gridIndex, timeStepIndex );
if ( scalarResults.size() )
{
caf::AppEnum<RigFemResultPosEnum> resPosAppEnum = resultDefinition->resultPositionType();
resultInfoText->append(resPosAppEnum.uiText() + ", ");
resultInfoText->append(resultDefinition->resultFieldUiName()+ ", ") ;
resultInfoText->append(resultDefinition->resultComponentUiName() + ":\n");
resultInfoText->append( resPosAppEnum.uiText() + ", " );
resultInfoText->append( resultDefinition->resultFieldUiName() + ", " );
resultInfoText->append( resultDefinition->resultComponentUiName() + ":\n" );
if (resultDefinition->resultPositionType() != RIG_ELEMENT_NODAL_FACE)
if ( resultDefinition->resultPositionType() != RIG_ELEMENT_NODAL_FACE )
{
RigFemPart* femPart = geomData->femParts()->part(gridIndex);
RigElementType elmType = femPart->elementType(cellIndex);
const int* elmentConn = femPart->connectivities(cellIndex);
int elmNodeCount = RigFemTypes::elmentNodeCount(elmType);
const int* lElmNodeToIpMap = RigFemTypes::localElmNodeToIntegrationPointMapping(elmType);
RigFemPart* femPart = geomData->femParts()->part( gridIndex );
RigElementType elmType = femPart->elementType( cellIndex );
const int* elmentConn = femPart->connectivities( cellIndex );
int elmNodeCount = RigFemTypes::elmentNodeCount( elmType );
const int* lElmNodeToIpMap = RigFemTypes::localElmNodeToIntegrationPointMapping( elmType );
for (int lNodeIdx = 0; lNodeIdx < elmNodeCount; ++lNodeIdx)
for ( int lNodeIdx = 0; lNodeIdx < elmNodeCount; ++lNodeIdx )
{
float scalarValue = std::numeric_limits<float>::infinity();
int nodeIdx = elmentConn[lNodeIdx];
if (resultDefinition->resultPositionType() == RIG_NODAL)
int nodeIdx = elmentConn[lNodeIdx];
if ( resultDefinition->resultPositionType() == RIG_NODAL )
{
scalarValue = scalarResults[nodeIdx];
}
else if (resultDefinition->resultPositionType() == RIG_ELEMENT)
else if ( resultDefinition->resultPositionType() == RIG_ELEMENT )
{
scalarValue = scalarResults[cellIndex];
}
else
{
size_t resIdx = femPart->elementNodeResultIdx(cellIndex, lNodeIdx);
scalarValue = scalarResults[resIdx];
size_t resIdx = femPart->elementNodeResultIdx( cellIndex, lNodeIdx );
scalarValue = scalarResults[resIdx];
}
if (resultDefinition->resultPositionType() == RIG_INTEGRATION_POINT)
if ( resultDefinition->resultPositionType() == RIG_INTEGRATION_POINT )
{
resultInfoText->append(QString("\tIP:%1 \t: %2 \tAss. Node: \t%3").arg(lElmNodeToIpMap[lNodeIdx] + 1 ).arg(scalarValue).arg(femPart->nodes().nodeIds[nodeIdx]));
resultInfoText->append( QString( "\tIP:%1 \t: %2 \tAss. Node: \t%3" )
.arg( lElmNodeToIpMap[lNodeIdx] + 1 )
.arg( scalarValue )
.arg( femPart->nodes().nodeIds[nodeIdx] ) );
}
else
{
resultInfoText->append(QString("\tN:%1 \t: %2").arg(femPart->nodes().nodeIds[nodeIdx]).arg(scalarValue));
resultInfoText->append(
QString( "\tN:%1 \t: %2" ).arg( femPart->nodes().nodeIds[nodeIdx] ).arg( scalarValue ) );
}
cvf::Vec3f nodeCoord = femPart->nodes().coordinates[nodeIdx];
resultInfoText->append(QString("\t( %3, %4, %5)\n").arg(nodeCoord[0]).arg(nodeCoord[1]).arg(nodeCoord[2]));
resultInfoText->append(
QString( "\t( %3, %4, %5)\n" ).arg( nodeCoord[0] ).arg( nodeCoord[1] ).arg( nodeCoord[2] ) );
}
}
else
{
int elmNodeFaceStartResIdx = cellIndex *24;
resultInfoText->append(QString("Pos I Face:\n"));
for (int ptIdx = 0; ptIdx < 4; ++ptIdx)
int elmNodeFaceStartResIdx = cellIndex * 24;
resultInfoText->append( QString( "Pos I Face:\n" ) );
for ( int ptIdx = 0; ptIdx < 4; ++ptIdx )
{
resultInfoText->append(QString("\t%2\n").arg(scalarResults[elmNodeFaceStartResIdx+ptIdx]));
}
resultInfoText->append(QString("Neg I Face:\n"));
for(int ptIdx = 4; ptIdx < 8; ++ptIdx)
{
resultInfoText->append(QString("\t%2\n").arg(scalarResults[elmNodeFaceStartResIdx+ptIdx]));
}
resultInfoText->append(QString("Pos J Face:\n"));
for(int ptIdx = 8; ptIdx < 12; ++ptIdx)
{
resultInfoText->append(QString("\t%2\n").arg(scalarResults[elmNodeFaceStartResIdx+ptIdx]));
}
resultInfoText->append(QString("Neg J Face:\n"));
for(int ptIdx = 12; ptIdx < 16; ++ptIdx)
{
resultInfoText->append(QString("\t%2\n").arg(scalarResults[elmNodeFaceStartResIdx+ptIdx]));
}
resultInfoText->append(QString("Pos K Face:\n"));
for(int ptIdx = 16; ptIdx < 20; ++ptIdx)
{
resultInfoText->append(QString("\t%2\n").arg(scalarResults[elmNodeFaceStartResIdx+ptIdx]));
}
resultInfoText->append(QString("Neg K Face:\n"));
for(int ptIdx = 20; ptIdx < 24; ++ptIdx)
{
resultInfoText->append(QString("\t%2\n").arg(scalarResults[elmNodeFaceStartResIdx+ptIdx]));
resultInfoText->append( QString( "\t%2\n" ).arg( scalarResults[elmNodeFaceStartResIdx + ptIdx] ) );
}
resultInfoText->append( QString( "Neg I Face:\n" ) );
for ( int ptIdx = 4; ptIdx < 8; ++ptIdx )
{
resultInfoText->append( QString( "\t%2\n" ).arg( scalarResults[elmNodeFaceStartResIdx + ptIdx] ) );
}
resultInfoText->append( QString( "Pos J Face:\n" ) );
for ( int ptIdx = 8; ptIdx < 12; ++ptIdx )
{
resultInfoText->append( QString( "\t%2\n" ).arg( scalarResults[elmNodeFaceStartResIdx + ptIdx] ) );
}
resultInfoText->append( QString( "Neg J Face:\n" ) );
for ( int ptIdx = 12; ptIdx < 16; ++ptIdx )
{
resultInfoText->append( QString( "\t%2\n" ).arg( scalarResults[elmNodeFaceStartResIdx + ptIdx] ) );
}
resultInfoText->append( QString( "Pos K Face:\n" ) );
for ( int ptIdx = 16; ptIdx < 20; ++ptIdx )
{
resultInfoText->append( QString( "\t%2\n" ).arg( scalarResults[elmNodeFaceStartResIdx + ptIdx] ) );
}
resultInfoText->append( QString( "Neg K Face:\n" ) );
for ( int ptIdx = 20; ptIdx < 24; ++ptIdx )
{
resultInfoText->append( QString( "\t%2\n" ).arg( scalarResults[elmNodeFaceStartResIdx + ptIdx] ) );
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFemResultTextBuilder::appendDetails(QString& text, const QString& details)
void RiuFemResultTextBuilder::appendDetails( QString& text, const QString& details )
{
if (!details.isEmpty())
if ( !details.isEmpty() )
{
text += "\n";
text += details;
@@ -363,70 +382,74 @@ void RiuFemResultTextBuilder::appendDetails(QString& text, const QString& detail
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QString RiuFemResultTextBuilder::closestNodeResultText(RimGeoMechResultDefinition* resultColors)
QString RiuFemResultTextBuilder::closestNodeResultText( RimGeoMechResultDefinition* resultColors )
{
QString text;
if (!resultColors)
if ( !resultColors )
{
return text;
}
if (resultColors->hasResult())
if ( resultColors->hasResult() )
{
if (! (m_reservoirView->geoMechCase() && m_reservoirView->geoMechCase()->geoMechData())) return text;
if ( !( m_reservoirView->geoMechCase() && m_reservoirView->geoMechCase()->geoMechData() ) ) return text;
RigGeoMechCaseData* geomData = m_reservoirView->geoMechCase()->geoMechData();
const std::vector<float>& scalarResults = geomData->femPartResults()->resultValues(resultColors->resultAddress(), m_gridIndex, m_timeStepIndex);
const std::vector<float>& scalarResults = geomData->femPartResults()->resultValues( resultColors->resultAddress(),
m_gridIndex,
m_timeStepIndex );
if (scalarResults.size())
if ( scalarResults.size() )
{
RigFemPart* femPart = geomData->femParts()->part(m_gridIndex);
RigFemPart* femPart = geomData->femParts()->part( m_gridIndex );
RigFemResultPosEnum activeResultPosition = resultColors->resultPositionType();
cvf::Vec3d intersectionPointInDomain = m_reservoirView->displayCoordTransform()->translateToDomainCoord(m_intersectionPointInDisplay);
RigFemClosestResultIndexCalculator closestIndexCalc(femPart,
activeResultPosition,
m_cellIndex,
m_face,
intersectionPointInDomain);
int resultIndex = closestIndexCalc.resultIndexToClosestResult();
int closestNodeId = closestIndexCalc.closestNodeId();
int closestElmNodResIdx = closestIndexCalc.closestElementNodeResIdx();
cvf::Vec3d intersectionPointInDomain = m_reservoirView->displayCoordTransform()->translateToDomainCoord(
m_intersectionPointInDisplay );
RigFemClosestResultIndexCalculator closestIndexCalc( femPart,
activeResultPosition,
m_cellIndex,
m_face,
intersectionPointInDomain );
int resultIndex = closestIndexCalc.resultIndexToClosestResult();
int closestNodeId = closestIndexCalc.closestNodeId();
int closestElmNodResIdx = closestIndexCalc.closestElementNodeResIdx();
float scalarValue = (resultIndex >= 0) ? scalarResults[resultIndex]: std::numeric_limits<float>::infinity();
float scalarValue = ( resultIndex >= 0 ) ? scalarResults[resultIndex]
: std::numeric_limits<float>::infinity();
if (activeResultPosition == RIG_ELEMENT)
if ( activeResultPosition == RIG_ELEMENT )
{
text.append(QString("Element result: %1\n").arg(scalarValue));
text.append( QString( "Element result: %1\n" ).arg( scalarValue ) );
}
else if (activeResultPosition != RIG_ELEMENT_NODAL_FACE)
else if ( activeResultPosition != RIG_ELEMENT_NODAL_FACE )
{
text.append(QString("Closest result: N[%1], %2\n").arg(closestNodeId)
.arg(scalarValue));
text.append( QString( "Closest result: N[%1], %2\n" ).arg( closestNodeId ).arg( scalarValue ) );
}
else if ( m_face != -1 )
{
text.append(QString("Closest result: N[%1], on face: %2, %3\n").arg(closestNodeId)
.arg(caf::AppEnum<cvf::StructGridInterface::FaceType>::textFromIndex(m_face))
.arg(scalarValue));
text.append( QString( "Closest result: N[%1], on face: %2, %3\n" )
.arg( closestNodeId )
.arg( caf::AppEnum<cvf::StructGridInterface::FaceType>::textFromIndex( m_face ) )
.arg( scalarValue ) );
}
else if (m_isIntersectionTriangleSet && activeResultPosition == RIG_ELEMENT_NODAL_FACE)
else if ( m_isIntersectionTriangleSet && activeResultPosition == RIG_ELEMENT_NODAL_FACE )
{
RiuGeoMechXfTensorResultAccessor tensAccessor(geomData->femPartResults(), resultColors->resultAddress(), m_timeStepIndex);
float tensValue = tensAccessor.calculateElmNodeValue(m_intersectionTriangle, closestElmNodResIdx);
RiuGeoMechXfTensorResultAccessor tensAccessor( geomData->femPartResults(),
resultColors->resultAddress(),
m_timeStepIndex );
float tensValue = tensAccessor.calculateElmNodeValue( m_intersectionTriangle, closestElmNodResIdx );
text.append(QString("Closest result: N[%1], in Element[%2] transformed onto intersection: %3 \n")
.arg(closestNodeId)
.arg(femPart->elmId(m_cellIndex))
.arg(tensValue));
text.append( QString( "Closest result: N[%1], in Element[%2] transformed onto intersection: %3 \n" )
.arg( closestNodeId )
.arg( femPart->elmId( m_cellIndex ) )
.arg( tensValue ) );
}
}
}
return text;
}

View File

@@ -2,24 +2,23 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmPointer.h"
#include "cvfStructGrid.h"
@@ -32,8 +31,9 @@ class RimGeoMechResultDefinition;
class RimGeoMechView;
class Rim2dIntersectionView;
namespace cvf {
class Part;
namespace cvf
{
class Part;
}
//==================================================================================================
@@ -43,36 +43,41 @@ namespace cvf {
class RiuFemResultTextBuilder
{
public:
RiuFemResultTextBuilder(RimGeoMechView* reservoirView, int gridIndex, int cellIndex, int timeStepIndex);
void setFace(int face);
void setIntersectionPointInDisplay(cvf::Vec3d intersectionPointInDisplay);
void setIntersectionTriangle(const std::array<cvf::Vec3f, 3>& triangle);
void set2dIntersectionView(Rim2dIntersectionView* intersectionView);
RiuFemResultTextBuilder( RimGeoMechView* reservoirView, int gridIndex, int cellIndex, int timeStepIndex );
void setFace( int face );
void setIntersectionPointInDisplay( cvf::Vec3d intersectionPointInDisplay );
void setIntersectionTriangle( const std::array<cvf::Vec3f, 3>& triangle );
void set2dIntersectionView( Rim2dIntersectionView* intersectionView );
QString mainResultText();
QString geometrySelectionText(QString itemSeparator);
QString geometrySelectionText( QString itemSeparator );
private:
void appendDetails(QString& text, const QString& details);
void appendDetails( QString& text, const QString& details );
QString gridResultDetails();
QString formationDetails();
QString closestNodeResultText(RimGeoMechResultDefinition* resultDefinition);
QString closestNodeResultText( RimGeoMechResultDefinition* resultDefinition );
void appendTextFromResultColors(RigGeoMechCaseData* eclipseCase, int gridIndex, int cellIndex, int timeStepIndex, RimGeoMechResultDefinition* resultDefinition, QString* resultInfoText);
void appendTextFromResultColors( RigGeoMechCaseData* eclipseCase,
int gridIndex,
int cellIndex,
int timeStepIndex,
RimGeoMechResultDefinition* resultDefinition,
QString* resultInfoText );
private:
caf::PdmPointer<RimGeoMechView> m_reservoirView;
caf::PdmPointer<RimGeoMechView> m_reservoirView;
caf::PdmPointer<Rim2dIntersectionView> m_2dIntersectionView;
int m_gridIndex;
int m_cellIndex;
int m_timeStepIndex;
int m_face;
bool m_isIntersectionTriangleSet;
int m_face;
bool m_isIntersectionTriangleSet;
std::array<cvf::Vec3f, 3> m_intersectionTriangle;
cvf::Vec3d m_intersectionPointInDisplay;

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -30,64 +30,67 @@
#include <cmath> // Needed for HUGE_VAL on Linux
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuFemTimeHistoryResultAccessor::RiuFemTimeHistoryResultAccessor(RigGeoMechCaseData* geomData,
RigFemResultAddress femResultAddress,
size_t gridIndex,
int elementIndex,
int face,
const cvf::Vec3d& intersectionPointInDomain)
: m_geoMechCaseData(geomData),
m_femResultAddress(new RigFemResultAddress(femResultAddress)),
m_gridIndex(gridIndex),
m_elementIndex(elementIndex),
m_face(face),
m_intersectionPointInDomain(intersectionPointInDomain),
m_hasIntersectionTriangle(false)
RiuFemTimeHistoryResultAccessor::RiuFemTimeHistoryResultAccessor( RigGeoMechCaseData* geomData,
RigFemResultAddress femResultAddress,
size_t gridIndex,
int elementIndex,
int face,
const cvf::Vec3d& intersectionPointInDomain )
: m_geoMechCaseData( geomData )
, m_femResultAddress( new RigFemResultAddress( femResultAddress ) )
, m_gridIndex( gridIndex )
, m_elementIndex( elementIndex )
, m_face( face )
, m_intersectionPointInDomain( intersectionPointInDomain )
, m_hasIntersectionTriangle( false )
{
computeTimeHistoryData();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuFemTimeHistoryResultAccessor::RiuFemTimeHistoryResultAccessor(RigGeoMechCaseData* geomData,
RigFemResultAddress femResultAddress,
size_t gridIndex,
int elementIndex,
int face,
const cvf::Vec3d& intersectionPointInDomain,
const std::array<cvf::Vec3f, 3>& intersectionTriangle)
: m_geoMechCaseData(geomData),
m_femResultAddress(new RigFemResultAddress(femResultAddress)),
m_gridIndex(gridIndex),
m_elementIndex(elementIndex),
m_face(face),
m_intersectionPointInDomain(intersectionPointInDomain),
m_hasIntersectionTriangle(true),
m_intersectionTriangle(intersectionTriangle)
RiuFemTimeHistoryResultAccessor::RiuFemTimeHistoryResultAccessor( RigGeoMechCaseData* geomData,
RigFemResultAddress femResultAddress,
size_t gridIndex,
int elementIndex,
int face,
const cvf::Vec3d& intersectionPointInDomain,
const std::array<cvf::Vec3f, 3>& intersectionTriangle )
: m_geoMechCaseData( geomData )
, m_femResultAddress( new RigFemResultAddress( femResultAddress ) )
, m_gridIndex( gridIndex )
, m_elementIndex( elementIndex )
, m_face( face )
, m_intersectionPointInDomain( intersectionPointInDomain )
, m_hasIntersectionTriangle( true )
, m_intersectionTriangle( intersectionTriangle )
{
computeTimeHistoryData();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QString RiuFemTimeHistoryResultAccessor::geometrySelectionText() const
{
QString text;
if (m_geoMechCaseData)
if ( m_geoMechCaseData )
{
RigFemPart* femPart = m_geoMechCaseData->femParts()->part(m_gridIndex);
int elementId = femPart->elmId(m_elementIndex);
text += QString("Element : Id[%1]").arg(elementId);
RigFemPart* femPart = m_geoMechCaseData->femParts()->part( m_gridIndex );
int elementId = femPart->elmId( m_elementIndex );
text += QString( "Element : Id[%1]" ).arg( elementId );
size_t i = 0;
size_t j = 0;
size_t k = 0;
if (m_geoMechCaseData->femParts()->part(m_gridIndex)->getOrCreateStructGrid()->ijkFromCellIndex(m_elementIndex, &i, &j, &k))
if ( m_geoMechCaseData->femParts()
->part( m_gridIndex )
->getOrCreateStructGrid()
->ijkFromCellIndex( m_elementIndex, &i, &j, &k ) )
{
// Adjust to 1-based Eclipse indexing
i++;
@@ -95,10 +98,13 @@ QString RiuFemTimeHistoryResultAccessor::geometrySelectionText() const
k++;
cvf::Vec3d domainCoord = m_intersectionPointInDomain;
text += QString(", ijk[%1, %2, %3] ").arg(i).arg(j).arg(k);
text += QString( ", ijk[%1, %2, %3] " ).arg( i ).arg( j ).arg( k );
QString formattedText;
formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z());
formattedText.sprintf( "Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]",
domainCoord.x(),
domainCoord.y(),
-domainCoord.z() );
text += formattedText;
}
@@ -108,7 +114,7 @@ QString RiuFemTimeHistoryResultAccessor::geometrySelectionText() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RiuFemTimeHistoryResultAccessor::timeHistoryValues() const
{
@@ -116,7 +122,7 @@ std::vector<double> RiuFemTimeHistoryResultAccessor::timeHistoryValues() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
int RiuFemTimeHistoryResultAccessor::closestNodeId() const
{
@@ -124,32 +130,32 @@ int RiuFemTimeHistoryResultAccessor::closestNodeId() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFemTimeHistoryResultAccessor::computeTimeHistoryData()
{
m_timeHistoryValues.clear();
RigFemClosestResultIndexCalculator closestCalc(m_geoMechCaseData->femParts()->part(m_gridIndex),
m_femResultAddress->resultPosType,
m_elementIndex,
m_face,
m_intersectionPointInDomain );
RigFemClosestResultIndexCalculator closestCalc( m_geoMechCaseData->femParts()->part( m_gridIndex ),
m_femResultAddress->resultPosType,
m_elementIndex,
m_face,
m_intersectionPointInDomain );
int scalarResultIndex = closestCalc.resultIndexToClosestResult();
m_closestNodeId = closestCalc.closestNodeId();
m_closestNodeId = closestCalc.closestNodeId();
RigFemPartResultsCollection* femPartResultsColl = m_geoMechCaseData->femPartResults();
if (m_femResultAddress->resultPosType == RIG_ELEMENT_NODAL_FACE && m_hasIntersectionTriangle)
if ( m_femResultAddress->resultPosType == RIG_ELEMENT_NODAL_FACE && m_hasIntersectionTriangle )
{
int closestElmNodeResIndex = closestCalc.closestElementNodeResIdx();
for ( int frameIdx = 0; frameIdx < femPartResultsColl->frameCount(); frameIdx++ )
{
RiuGeoMechXfTensorResultAccessor stressXfAccessor(femPartResultsColl, *m_femResultAddress, frameIdx);
float scalarValue = stressXfAccessor.calculateElmNodeValue(m_intersectionTriangle, closestElmNodeResIndex);
m_timeHistoryValues.push_back(scalarValue);
RiuGeoMechXfTensorResultAccessor stressXfAccessor( femPartResultsColl, *m_femResultAddress, frameIdx );
float scalarValue = stressXfAccessor.calculateElmNodeValue( m_intersectionTriangle, closestElmNodeResIndex );
m_timeHistoryValues.push_back( scalarValue );
}
}
else
@@ -158,14 +164,16 @@ void RiuFemTimeHistoryResultAccessor::computeTimeHistoryData()
for ( int frameIdx = 0; frameIdx < femPartResultsColl->frameCount(); frameIdx++ )
{
const std::vector<float>& scalarResults = m_geoMechCaseData->femPartResults()->resultValues(*m_femResultAddress, static_cast<int>(m_gridIndex), frameIdx);
const std::vector<float>& scalarResults = m_geoMechCaseData->femPartResults()
->resultValues( *m_femResultAddress,
static_cast<int>( m_gridIndex ),
frameIdx );
if ( scalarResults.size() )
{
float scalarValue = scalarResults[scalarResultIndex];
m_timeHistoryValues.push_back(scalarValue);
m_timeHistoryValues.push_back( scalarValue );
}
}
}
}

View File

@@ -2,24 +2,23 @@
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfVector3.h"
#include <QString>
@@ -34,43 +33,42 @@ class RigFemResultAddress;
class RiuFemTimeHistoryResultAccessor
{
public:
RiuFemTimeHistoryResultAccessor(RigGeoMechCaseData* geomData,
RigFemResultAddress femResultAddress,
size_t gridIndex,
int elementIndex,
int face,
const cvf::Vec3d& intersectionPointInDomain);
RiuFemTimeHistoryResultAccessor( RigGeoMechCaseData* geomData,
RigFemResultAddress femResultAddress,
size_t gridIndex,
int elementIndex,
int face,
const cvf::Vec3d& intersectionPointInDomain );
RiuFemTimeHistoryResultAccessor(RigGeoMechCaseData* geomData,
RigFemResultAddress femResultAddress,
size_t gridIndex,
int elementIndex,
int face,
const cvf::Vec3d& intersectionPointInDomain,
const std::array<cvf::Vec3f, 3>& m_intersectionTriangle);
RiuFemTimeHistoryResultAccessor( RigGeoMechCaseData* geomData,
RigFemResultAddress femResultAddress,
size_t gridIndex,
int elementIndex,
int face,
const cvf::Vec3d& intersectionPointInDomain,
const std::array<cvf::Vec3f, 3>& m_intersectionTriangle );
QString geometrySelectionText() const;
std::vector<double> timeHistoryValues() const;
int closestNodeId() const;
int closestNodeId() const;
private:
void computeTimeHistoryData();
void computeTimeHistoryData();
private:
RigGeoMechCaseData* m_geoMechCaseData;
std::unique_ptr<RigFemResultAddress> m_femResultAddress;
size_t m_gridIndex;
int m_elementIndex;
int m_face;
int m_closestNodeId;
size_t m_gridIndex;
int m_elementIndex;
int m_face;
int m_closestNodeId;
cvf::Vec3d m_intersectionPointInDomain;
cvf::Vec3d m_intersectionPointInDomain;
bool m_hasIntersectionTriangle;
std::array<cvf::Vec3f, 3> m_intersectionTriangle;
std::vector<double> m_timeHistoryValues;
std::vector<double> m_timeHistoryValues;
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -27,11 +27,10 @@
#include "RimFlowCharacteristicsPlot.h"
#include "RiuQwtPlotCurve.h"
#include "RiuQwtPlotTools.h"
#include "RiuQwtPlotWheelZoomer.h"
#include "RiuQwtPlotZoomer.h"
#include "RiuResultQwtPlot.h"
#include "RiuQwtPlotTools.h"
#include "cvfColor3.h"
@@ -49,132 +48,136 @@
#include <QLabel>
#include <QMenu>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot(RimFlowCharacteristicsPlot* plotDefinition, QWidget* parent)
: QFrame(parent)
, m_plotDefinition(plotDefinition)
RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot( RimFlowCharacteristicsPlot* plotDefinition, QWidget* parent )
: QFrame( parent )
, m_plotDefinition( plotDefinition )
{
Q_ASSERT(m_plotDefinition);
Q_ASSERT( m_plotDefinition );
QGridLayout* mainLayout = new QGridLayout();
this->setLayout(mainLayout);
this->layout()->setMargin(3);
this->layout()->setSpacing(3);
this->setLayout( mainLayout );
this->layout()->setMargin( 3 );
this->layout()->setSpacing( 3 );
// White background
QPalette pal = this->palette();
pal.setColor(QPalette::Background, Qt::white);
this->setAutoFillBackground(true);
this->setPalette(pal);
pal.setColor( QPalette::Background, Qt::white );
this->setAutoFillBackground( true );
this->setPalette( pal );
m_lorenzPlot = new QwtPlot(this);
m_flowCapVsStorageCapPlot = new QwtPlot(this);
m_sweepEffPlot = new QwtPlot(this);
m_lorenzPlot = new QwtPlot( this );
m_flowCapVsStorageCapPlot = new QwtPlot( this );
m_sweepEffPlot = new QwtPlot( this );
mainLayout->addWidget(m_lorenzPlot, 0 ,0, 1, 2);
mainLayout->addWidget(m_flowCapVsStorageCapPlot, 1, 0);
mainLayout->addWidget(m_sweepEffPlot, 1, 1);
mainLayout->addWidget( m_lorenzPlot, 0, 0, 1, 2 );
mainLayout->addWidget( m_flowCapVsStorageCapPlot, 1, 0 );
mainLayout->addWidget( m_sweepEffPlot, 1, 1 );
RiuQwtPlotTools::setCommonPlotBehaviour(m_lorenzPlot);
new RiuQwtPlotWheelZoomer(m_lorenzPlot);
addWindowZoom(m_lorenzPlot);
RiuQwtPlotTools::setCommonPlotBehaviour( m_lorenzPlot );
new RiuQwtPlotWheelZoomer( m_lorenzPlot );
addWindowZoom( m_lorenzPlot );
QString dateFormat = RiaApplication::instance()->preferences()->dateFormat();
QString dateFormat = RiaApplication::instance()->preferences()->dateFormat();
QString timeFormat = RiaApplication::instance()->preferences()->timeFormat();
RiuQwtPlotTools::enableDateBasedBottomXAxis(m_lorenzPlot, dateFormat, timeFormat);
m_lorenzPlot->setTitle("Lorenz Coefficient");
RiuQwtPlotTools::enableDateBasedBottomXAxis( m_lorenzPlot, dateFormat, timeFormat );
m_lorenzPlot->setTitle( "Lorenz Coefficient" );
RiuQwtPlotTools::setCommonPlotBehaviour(m_sweepEffPlot);
new RiuQwtPlotWheelZoomer(m_sweepEffPlot);
addWindowZoom(m_sweepEffPlot);
m_sweepEffPlot->setTitle("Sweep Efficiency");
RiuQwtPlotTools::setCommonPlotBehaviour( m_sweepEffPlot );
new RiuQwtPlotWheelZoomer( m_sweepEffPlot );
addWindowZoom( m_sweepEffPlot );
m_sweepEffPlot->setTitle( "Sweep Efficiency" );
int legendFontSize = RiaFontCache::pointSizeFromFontSizeEnum(RiaApplication::instance()->preferences()->defaultPlotFontSize());
int legendFontSize = RiaFontCache::pointSizeFromFontSizeEnum(
RiaApplication::instance()->preferences()->defaultPlotFontSize() );
{
QwtText axisTitle = m_sweepEffPlot->axisTitle(QwtPlot::xBottom);
QwtText axisTitle = m_sweepEffPlot->axisTitle( QwtPlot::xBottom );
auto font = axisTitle.font();
font.setPointSize(legendFontSize);
axisTitle.setFont(font);
axisTitle.setText("Dimensionless Time");
m_sweepEffPlot->setAxisTitle(QwtPlot::xBottom, axisTitle);
font.setPointSize( legendFontSize );
axisTitle.setFont( font );
axisTitle.setText( "Dimensionless Time" );
m_sweepEffPlot->setAxisTitle( QwtPlot::xBottom, axisTitle );
}
{
QwtText axisTitle = m_sweepEffPlot->axisTitle(QwtPlot::yLeft);
QwtText axisTitle = m_sweepEffPlot->axisTitle( QwtPlot::yLeft );
auto font = axisTitle.font();
font.setPointSize(legendFontSize);
axisTitle.setFont(font);
axisTitle.setText("Sweep Efficiency");
m_sweepEffPlot->setAxisTitle(QwtPlot::yLeft, axisTitle);
font.setPointSize( legendFontSize );
axisTitle.setFont( font );
axisTitle.setText( "Sweep Efficiency" );
m_sweepEffPlot->setAxisTitle( QwtPlot::yLeft, axisTitle );
}
RiuQwtPlotTools::setCommonPlotBehaviour(m_flowCapVsStorageCapPlot);
new RiuQwtPlotWheelZoomer(m_flowCapVsStorageCapPlot);
addWindowZoom(m_flowCapVsStorageCapPlot);
m_flowCapVsStorageCapPlot->setTitle("Flow Capacity vs Storage Capacity");
RiuQwtPlotTools::setCommonPlotBehaviour( m_flowCapVsStorageCapPlot );
new RiuQwtPlotWheelZoomer( m_flowCapVsStorageCapPlot );
addWindowZoom( m_flowCapVsStorageCapPlot );
m_flowCapVsStorageCapPlot->setTitle( "Flow Capacity vs Storage Capacity" );
{
QwtText axisTitle = m_flowCapVsStorageCapPlot->axisTitle(QwtPlot::xBottom);
QwtText axisTitle = m_flowCapVsStorageCapPlot->axisTitle( QwtPlot::xBottom );
auto font = axisTitle.font();
font.setPointSize(legendFontSize);
axisTitle.setFont(font);
axisTitle.setText("Storage Capacity [C]");
m_flowCapVsStorageCapPlot->setAxisTitle(QwtPlot::xBottom, axisTitle);
font.setPointSize( legendFontSize );
axisTitle.setFont( font );
axisTitle.setText( "Storage Capacity [C]" );
m_flowCapVsStorageCapPlot->setAxisTitle( QwtPlot::xBottom, axisTitle );
}
{
QwtText axisTitle = m_flowCapVsStorageCapPlot->axisTitle(QwtPlot::yLeft);
QwtText axisTitle = m_flowCapVsStorageCapPlot->axisTitle( QwtPlot::yLeft );
auto font = axisTitle.font();
font.setPointSize(legendFontSize);
axisTitle.setFont(font);
axisTitle.setText("Flow Capacity [F]");
m_flowCapVsStorageCapPlot->setAxisTitle(QwtPlot::yLeft, axisTitle);
font.setPointSize( legendFontSize );
axisTitle.setFont( font );
axisTitle.setText( "Flow Capacity [F]" );
m_flowCapVsStorageCapPlot->setAxisTitle( QwtPlot::yLeft, axisTitle );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFlowCharacteristicsPlot::addWindowZoom(QwtPlot* plot)
void RiuFlowCharacteristicsPlot::addWindowZoom( QwtPlot* plot )
{
auto zoomer = new RiuQwtPlotZoomer(plot->canvas());
zoomer->setRubberBandPen(QColor(Qt::black));
zoomer->setTrackerMode(QwtPicker::AlwaysOff);
zoomer->setTrackerPen(QColor(Qt::black));
zoomer->initMousePattern(1);
auto zoomer = new RiuQwtPlotZoomer( plot->canvas() );
zoomer->setRubberBandPen( QColor( Qt::black ) );
zoomer->setTrackerMode( QwtPicker::AlwaysOff );
zoomer->setTrackerPen( QColor( Qt::black ) );
zoomer->initMousePattern( 1 );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuFlowCharacteristicsPlot::~RiuFlowCharacteristicsPlot()
{
}
RiuFlowCharacteristicsPlot::~RiuFlowCharacteristicsPlot() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFlowCharacteristicsPlot::setLorenzCurve(const QStringList& dateTimeStrings, const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues)
void RiuFlowCharacteristicsPlot::setLorenzCurve( const QStringList& dateTimeStrings,
const std::vector<QDateTime>& dateTimes,
const std::vector<double>& timeHistoryValues )
{
m_lorenzPlot->detachItems(QwtPlotItem::Rtti_PlotCurve, true);
m_lorenzPlot->detachItems( QwtPlotItem::Rtti_PlotCurve, true );
if (!dateTimes.empty())
if ( !dateTimes.empty() )
{
initializeColors(dateTimes);
initializeColors( dateTimes );
for (size_t tsIdx = 0; tsIdx < dateTimes.size(); ++tsIdx)
for ( size_t tsIdx = 0; tsIdx < dateTimes.size(); ++tsIdx )
{
if (timeHistoryValues[tsIdx] == HUGE_VAL) continue;
if ( timeHistoryValues[tsIdx] == HUGE_VAL ) continue;
QDateTime dateTime = dateTimes[tsIdx];
double timeHistoryValue = timeHistoryValues[tsIdx];
QDateTime dateTime = dateTimes[tsIdx];
double timeHistoryValue = timeHistoryValues[tsIdx];
QString curveName = dateTimeStrings[static_cast<int>(tsIdx)];
QString curveName = dateTimeStrings[static_cast<int>( tsIdx )];
RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol(m_lorenzPlot, curveName, m_dateToColorMap[dateTime], dateTime, timeHistoryValue);
RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol( m_lorenzPlot,
curveName,
m_dateToColorMap[dateTime],
dateTime,
timeHistoryValue );
}
}
@@ -182,124 +185,132 @@ void RiuFlowCharacteristicsPlot::setLorenzCurve(const QStringList& dateTimeStrin
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol(QwtPlot* plot, const QString& curveName, const QColor& color, const QDateTime& dateTime, double timeHistoryValue)
void RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol(
QwtPlot* plot, const QString& curveName, const QColor& color, const QDateTime& dateTime, double timeHistoryValue )
{
auto curve = createEmptyCurve(plot, curveName, color);
auto curve = createEmptyCurve( plot, curveName, color );
QwtSymbol::Style style = QwtSymbol::Diamond;
QwtSymbol* symbol = new QwtSymbol(style);
QwtSymbol::Style style = QwtSymbol::Diamond;
QwtSymbol* symbol = new QwtSymbol( style );
symbol->setSize(15, 15);
symbol->setColor(color);
symbol->setSize( 15, 15 );
symbol->setColor( color );
curve->setSymbol(symbol);
curve->setSymbol( symbol );
// Add date and value twice to avoid a cross as symbol generated by RiuQwtPlotCurve
std::vector<QDateTime> dateTimes;
dateTimes.push_back(dateTime);
dateTimes.push_back(dateTime);
dateTimes.push_back( dateTime );
dateTimes.push_back( dateTime );
std::vector<double> timeHistoryValues;
timeHistoryValues.push_back(timeHistoryValue);
timeHistoryValues.push_back(timeHistoryValue);
timeHistoryValues.push_back( timeHistoryValue );
timeHistoryValues.push_back( timeHistoryValue );
curve->setSamplesFromDatesAndYValues(dateTimes, timeHistoryValues, false);
curve->setSamplesFromDatesAndYValues( dateTimes, timeHistoryValues, false );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotCurve* RiuFlowCharacteristicsPlot::createEmptyCurve(QwtPlot* plot, const QString& curveName, const QColor& curveColor )
RiuQwtPlotCurve*
RiuFlowCharacteristicsPlot::createEmptyCurve( QwtPlot* plot, const QString& curveName, const QColor& curveColor )
{
RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve(curveName);
plotCurve->setTitle(curveName);
plotCurve->setPen(QPen(curveColor));
plotCurve->attach(plot);
RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve( curveName );
plotCurve->setTitle( curveName );
plotCurve->setPen( QPen( curveColor ) );
plotCurve->attach( plot );
return plotCurve;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFlowCharacteristicsPlot::addFlowCapStorageCapCurve(const QDateTime& dateTime, const std::vector<double>& xVals, const std::vector<double>& yVals)
void RiuFlowCharacteristicsPlot::addFlowCapStorageCapCurve( const QDateTime& dateTime,
const std::vector<double>& xVals,
const std::vector<double>& yVals )
{
CVF_ASSERT(!m_dateToColorMap.empty());
CVF_ASSERT( !m_dateToColorMap.empty() );
RiuQwtPlotCurve* plotCurve = createEmptyCurve(m_flowCapVsStorageCapPlot, dateTime.toString(), m_dateToColorMap[dateTime]);
plotCurve->setSamplesFromXValuesAndYValues(xVals, yVals, false);
RiuQwtPlotCurve* plotCurve = createEmptyCurve( m_flowCapVsStorageCapPlot,
dateTime.toString(),
m_dateToColorMap[dateTime] );
plotCurve->setSamplesFromXValuesAndYValues( xVals, yVals, false );
m_flowCapVsStorageCapPlot->replot();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFlowCharacteristicsPlot::addSweepEfficiencyCurve(const QDateTime& dateTime, const std::vector<double>& xVals, const std::vector<double>& yVals)
void RiuFlowCharacteristicsPlot::addSweepEfficiencyCurve( const QDateTime& dateTime,
const std::vector<double>& xVals,
const std::vector<double>& yVals )
{
CVF_ASSERT(!m_dateToColorMap.empty());
CVF_ASSERT( !m_dateToColorMap.empty() );
RiuQwtPlotCurve* plotCurve = createEmptyCurve(m_sweepEffPlot, dateTime.toString(), m_dateToColorMap[dateTime]);
plotCurve->setSamplesFromXValuesAndYValues(xVals, yVals, false);
RiuQwtPlotCurve* plotCurve = createEmptyCurve( m_sweepEffPlot, dateTime.toString(), m_dateToColorMap[dateTime] );
plotCurve->setSamplesFromXValuesAndYValues( xVals, yVals, false );
m_sweepEffPlot->replot();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFlowCharacteristicsPlot::removeAllCurves()
{
m_lorenzPlot->detachItems(QwtPlotItem::Rtti_PlotCurve, true);
m_lorenzPlot->detachItems( QwtPlotItem::Rtti_PlotCurve, true );
m_lorenzPlot->replot();
m_sweepEffPlot->detachItems(QwtPlotItem::Rtti_PlotCurve, true);
m_sweepEffPlot->detachItems( QwtPlotItem::Rtti_PlotCurve, true );
m_sweepEffPlot->replot();
m_flowCapVsStorageCapPlot->detachItems(QwtPlotItem::Rtti_PlotCurve, true);
m_flowCapVsStorageCapPlot->detachItems( QwtPlotItem::Rtti_PlotCurve, true );
m_flowCapVsStorageCapPlot->replot();
m_dateToColorMap.clear();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void zoomAllInPlot(QwtPlot * plot)
void zoomAllInPlot( QwtPlot* plot )
{
plot->setAxisAutoScale(QwtPlot::xBottom, true);
plot->setAxisAutoScale(QwtPlot::yLeft, true);
plot->setAxisAutoScale( QwtPlot::xBottom, true );
plot->setAxisAutoScale( QwtPlot::yLeft, true );
plot->replot();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFlowCharacteristicsPlot::zoomAll()
{
zoomAllInPlot(m_lorenzPlot);
zoomAllInPlot(m_sweepEffPlot);
zoomAllInPlot(m_flowCapVsStorageCapPlot);
zoomAllInPlot( m_lorenzPlot );
zoomAllInPlot( m_sweepEffPlot );
zoomAllInPlot( m_flowCapVsStorageCapPlot );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFlowCharacteristicsPlot::showLegend(bool show)
void RiuFlowCharacteristicsPlot::showLegend( bool show )
{
if (show)
if ( show )
{
// Will be released in plot destructor or when a new legend is set
QwtLegend* legend = new QwtLegend(m_lorenzPlot);
m_lorenzPlot->insertLegend(legend, QwtPlot::BottomLegend);
QwtLegend* legend = new QwtLegend( m_lorenzPlot );
m_lorenzPlot->insertLegend( legend, QwtPlot::BottomLegend );
}
else
{
m_lorenzPlot->insertLegend(nullptr);
m_lorenzPlot->insertLegend( nullptr );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RimFlowCharacteristicsPlot* RiuFlowCharacteristicsPlot::ownerPlotDefinition()
{
@@ -307,7 +318,7 @@ RimFlowCharacteristicsPlot* RiuFlowCharacteristicsPlot::ownerPlotDefinition()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RimViewWindow* RiuFlowCharacteristicsPlot::ownerViewWindow() const
{
@@ -315,35 +326,35 @@ RimViewWindow* RiuFlowCharacteristicsPlot::ownerViewWindow() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QSize RiuFlowCharacteristicsPlot::minimumSizeHint() const
{
return QSize(0, 100);
return QSize( 0, 100 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuFlowCharacteristicsPlot::contextMenuEvent(QContextMenuEvent* event)
void RiuFlowCharacteristicsPlot::contextMenuEvent( QContextMenuEvent* event )
{
if (m_plotDefinition)
if ( m_plotDefinition )
{
QString curveDataAsText = m_plotDefinition->curveDataAsText();
QString dialogTitle = "Flow Characteristics";
RiaFeatureCommandContextTextHelper helper(dialogTitle, curveDataAsText);
RiaFeatureCommandContextTextHelper helper( dialogTitle, curveDataAsText );
caf::CmdFeatureMenuBuilder menuBuilder;
menuBuilder << "RicShowPlotDataFeature";
QMenu menu;
menuBuilder.appendToMenu(&menu);
menuBuilder.appendToMenu( &menu );
if (menu.actions().size() > 0)
if ( menu.actions().size() > 0 )
{
menu.exec(event->globalPos());
menu.exec( event->globalPos() );
}
}
}
@@ -353,30 +364,26 @@ void RiuFlowCharacteristicsPlot::contextMenuEvent(QContextMenuEvent* event)
//--------------------------------------------------------------------------------------------------
QSize RiuFlowCharacteristicsPlot::sizeHint() const
{
return QSize(0, 0);
return QSize( 0, 0 );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFlowCharacteristicsPlot::setDefaults()
{
}
void RiuFlowCharacteristicsPlot::setDefaults() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuFlowCharacteristicsPlot::initializeColors(const std::vector<QDateTime>& dateTimes)
void RiuFlowCharacteristicsPlot::initializeColors( const std::vector<QDateTime>& dateTimes )
{
CVF_ASSERT(m_dateToColorMap.empty());
CVF_ASSERT( m_dateToColorMap.empty() );
const caf::ColorTable& palette = RiaColorTables::timestepsPaletteColors();
cvf::Color3ubArray colorArray = caf::ColorTable::interpolateColorArray(palette.color3ubArray(), dateTimes.size());
cvf::Color3ubArray colorArray = caf::ColorTable::interpolateColorArray( palette.color3ubArray(), dateTimes.size() );
for (size_t tsIdx = 0; tsIdx < dateTimes.size(); ++tsIdx)
for ( size_t tsIdx = 0; tsIdx < dateTimes.size(); ++tsIdx )
{
m_dateToColorMap[dateTimes[tsIdx]] = QColor( colorArray[tsIdx].r(), colorArray[tsIdx].g(), colorArray[tsIdx].b());
m_dateToColorMap[dateTimes[tsIdx]] = QColor( colorArray[tsIdx].r(), colorArray[tsIdx].g(), colorArray[tsIdx].b() );
}
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -34,8 +34,9 @@ class RiuQwtPlotCurve;
class QLabel;
namespace cvf {
class Color3f;
namespace cvf
{
class Color3f;
}
//==================================================================================================
@@ -46,35 +47,46 @@ namespace cvf {
class RiuFlowCharacteristicsPlot : public QFrame, public RiuInterfaceToViewWindow
{
Q_OBJECT;
public:
RiuFlowCharacteristicsPlot(RimFlowCharacteristicsPlot* plotDefinition, QWidget* parent = nullptr);
RiuFlowCharacteristicsPlot( RimFlowCharacteristicsPlot* plotDefinition, QWidget* parent = nullptr );
~RiuFlowCharacteristicsPlot() override;
void setLorenzCurve(const QStringList& dateTimeStrings, const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues);
void addFlowCapStorageCapCurve(const QDateTime& dateTime, const std::vector<double>& xVals, const std::vector<double>& yVals);
void addSweepEfficiencyCurve(const QDateTime& dateTime, const std::vector<double>& xVals, const std::vector<double>& yVals);
void setLorenzCurve( const QStringList& dateTimeStrings,
const std::vector<QDateTime>& dateTimes,
const std::vector<double>& timeHistoryValues );
void addFlowCapStorageCapCurve( const QDateTime& dateTime,
const std::vector<double>& xVals,
const std::vector<double>& yVals );
void addSweepEfficiencyCurve( const QDateTime& dateTime,
const std::vector<double>& xVals,
const std::vector<double>& yVals );
void removeAllCurves();
void zoomAll();
void showLegend(bool show);
void showLegend( bool show );
RimFlowCharacteristicsPlot* ownerPlotDefinition();
RimViewWindow* ownerViewWindow() const override;
RimFlowCharacteristicsPlot* ownerPlotDefinition();
RimViewWindow* ownerViewWindow() const override;
static void addWindowZoom(QwtPlot* plot);
static RiuQwtPlotCurve* createEmptyCurve(QwtPlot* plot, const QString& curveName, const QColor& curveColor);
static void addWindowZoom( QwtPlot* plot );
static RiuQwtPlotCurve* createEmptyCurve( QwtPlot* plot, const QString& curveName, const QColor& curveColor );
protected:
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
void contextMenuEvent(QContextMenuEvent* event) override;
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
void contextMenuEvent( QContextMenuEvent* event ) override;
private:
void setDefaults();
void initializeColors(const std::vector<QDateTime>& dateTimes);
static void addCurveWithLargeSymbol(QwtPlot* plot, const QString& curveName, const QColor& color, const QDateTime& dateTime, double timeHistoryValue);
void setDefaults();
void initializeColors( const std::vector<QDateTime>& dateTimes );
static void addCurveWithLargeSymbol( QwtPlot* plot,
const QString& curveName,
const QColor& color,
const QDateTime& dateTime,
double timeHistoryValue );
private:
caf::PdmPointer<RimFlowCharacteristicsPlot> m_plotDefinition;
@@ -82,6 +94,5 @@ private:
QPointer<QwtPlot> m_flowCapVsStorageCapPlot;
QPointer<QwtPlot> m_sweepEffPlot;
std::map<QDateTime, QColor> m_dateToColorMap;
std::map<QDateTime, QColor> m_dateToColorMap;
};

View File

@@ -1,52 +1,70 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiuGeoMechXfTensorResultAccessor.h"
#include "RigFemPartResultsCollection.h"
#include "cvfGeometryTools.h"
#include "RivHexGridIntersectionTools.h"
#include "cvfAssert.h"
#include "cvfGeometryTools.h"
float RiuGeoMechXfTensorResultAccessor::SN (const caf::Ten3f& t) const { return t[caf::Ten3f::SZZ];}
float RiuGeoMechXfTensorResultAccessor::STH (const caf::Ten3f& t) const { return t[caf::Ten3f::SXX]; }
float RiuGeoMechXfTensorResultAccessor::STQV (const caf::Ten3f& t) const { return t[caf::Ten3f::SYY]; }
float RiuGeoMechXfTensorResultAccessor::TNH (const caf::Ten3f& t) const { return t[caf::Ten3f::SZX]; }
float RiuGeoMechXfTensorResultAccessor::TNQV (const caf::Ten3f& t) const { return t[caf::Ten3f::SYZ]; }
float RiuGeoMechXfTensorResultAccessor::THQV (const caf::Ten3f& t) const { return t[caf::Ten3f::SXY]; }
float RiuGeoMechXfTensorResultAccessor::SN( const caf::Ten3f& t ) const
{
return t[caf::Ten3f::SZZ];
}
float RiuGeoMechXfTensorResultAccessor::STH( const caf::Ten3f& t ) const
{
return t[caf::Ten3f::SXX];
}
float RiuGeoMechXfTensorResultAccessor::STQV( const caf::Ten3f& t ) const
{
return t[caf::Ten3f::SYY];
}
float RiuGeoMechXfTensorResultAccessor::TNH( const caf::Ten3f& t ) const
{
return t[caf::Ten3f::SZX];
}
float RiuGeoMechXfTensorResultAccessor::TNQV( const caf::Ten3f& t ) const
{
return t[caf::Ten3f::SYZ];
}
float RiuGeoMechXfTensorResultAccessor::THQV( const caf::Ten3f& t ) const
{
return t[caf::Ten3f::SXY];
}
float RiuGeoMechXfTensorResultAccessor::TP (const caf::Ten3f& t) const
{
float RiuGeoMechXfTensorResultAccessor::TP( const caf::Ten3f& t ) const
{
float szx = t[caf::Ten3f::SZX];
float szy = t[caf::Ten3f::SYZ];
float tp = sqrt(szx*szx + szy*szy);
float tp = sqrt( szx * szx + szy * szy );
return tp;
}
float RiuGeoMechXfTensorResultAccessor::TPinc (const caf::Ten3f& t) const
{
float RiuGeoMechXfTensorResultAccessor::TPinc( const caf::Ten3f& t ) const
{
float szy = t[caf::Ten3f::SYZ];
float tp = TP(t);
float tp = TP( t );
if ( tp > 1e-5 )
{
return cvf::Math::toDegrees(acos(szy/tp));
return cvf::Math::toDegrees( acos( szy / tp ) );
}
else
{
@@ -54,66 +72,96 @@ float RiuGeoMechXfTensorResultAccessor::TPinc (const caf::Ten3f& t) const
}
}
float RiuGeoMechXfTensorResultAccessor::FAULTMOB(const caf::Ten3f& t) const
{
float szz = t[caf::Ten3f::SZZ];
float tp = TP(t);
return tp/(m_tanFricAng * (szz + m_cohPrTanFricAngle));
}
float RiuGeoMechXfTensorResultAccessor::PCRIT (const caf::Ten3f& t) const
float RiuGeoMechXfTensorResultAccessor::FAULTMOB( const caf::Ten3f& t ) const
{
float szz = t[caf::Ten3f::SZZ];
float tp = TP(t);
float tp = TP( t );
return szz - tp/m_tanFricAng;
return tp / ( m_tanFricAng * ( szz + m_cohPrTanFricAngle ) );
}
float RiuGeoMechXfTensorResultAccessor::PCRIT( const caf::Ten3f& t ) const
{
float szz = t[caf::Ten3f::SZZ];
float tp = TP( t );
return szz - tp / m_tanFricAng;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuGeoMechXfTensorResultAccessor::RiuGeoMechXfTensorResultAccessor(RigFemPartResultsCollection * femResCollection,
const RigFemResultAddress& resVarAddress,
int timeStepIdx)
RiuGeoMechXfTensorResultAccessor::RiuGeoMechXfTensorResultAccessor( RigFemPartResultsCollection* femResCollection,
const RigFemResultAddress& resVarAddress,
int timeStepIdx )
{
RigFemResultAddress tensComp = resVarAddress;
tensComp.resultPosType = RIG_ELEMENT_NODAL;
tensComp.resultPosType = RIG_ELEMENT_NODAL;
tensComp.componentName = "S11";
tens11 = &femResCollection->resultValues(tensComp, 0, timeStepIdx);
tens11 = &femResCollection->resultValues( tensComp, 0, timeStepIdx );
tensComp.componentName = "S22";
tens22 = &femResCollection->resultValues(tensComp, 0, timeStepIdx);
tens22 = &femResCollection->resultValues( tensComp, 0, timeStepIdx );
tensComp.componentName = "S33";
tens33 = &femResCollection->resultValues(tensComp, 0, timeStepIdx);
tens33 = &femResCollection->resultValues( tensComp, 0, timeStepIdx );
tensComp.componentName = "S12";
tens12 = &femResCollection->resultValues(tensComp, 0, timeStepIdx);
tens12 = &femResCollection->resultValues( tensComp, 0, timeStepIdx );
tensComp.componentName = "S23";
tens23 = &femResCollection->resultValues(tensComp, 0, timeStepIdx);
tens23 = &femResCollection->resultValues( tensComp, 0, timeStepIdx );
tensComp.componentName = "S13";
tens13 = &femResCollection->resultValues(tensComp, 0, timeStepIdx);
tens13 = &femResCollection->resultValues( tensComp, 0, timeStepIdx );
if ( resVarAddress.componentName == "SN" ) { m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::SN ;}
if ( resVarAddress.componentName == "STH" ) { m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::STH ;}
if ( resVarAddress.componentName == "STQV" ) { m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::STQV ;}
if ( resVarAddress.componentName == "TPH" ) { m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::TNH ;}
if ( resVarAddress.componentName == "TPQV" ) { m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::TNQV ;}
if ( resVarAddress.componentName == "THQV" ) { m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::THQV ;}
if ( resVarAddress.componentName == "TP" ) { m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::TP ;}
if ( resVarAddress.componentName == "TPinc" ) { m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::TPinc ;}
if ( resVarAddress.componentName == "FAULTMOB" ) { m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::FAULTMOB;}
if ( resVarAddress.componentName == "PCRIT" ) { m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::PCRIT ;}
if ( resVarAddress.componentName == "SN" )
{
m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::SN;
}
if ( resVarAddress.componentName == "STH" )
{
m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::STH;
}
if ( resVarAddress.componentName == "STQV" )
{
m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::STQV;
}
if ( resVarAddress.componentName == "TPH" )
{
m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::TNH;
}
if ( resVarAddress.componentName == "TPQV" )
{
m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::TNQV;
}
if ( resVarAddress.componentName == "THQV" )
{
m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::THQV;
}
if ( resVarAddress.componentName == "TP" )
{
m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::TP;
}
if ( resVarAddress.componentName == "TPinc" )
{
m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::TPinc;
}
if ( resVarAddress.componentName == "FAULTMOB" )
{
m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::FAULTMOB;
}
if ( resVarAddress.componentName == "PCRIT" )
{
m_tensorOperation = &RiuGeoMechXfTensorResultAccessor::PCRIT;
}
m_tanFricAng = tan((float)femResCollection->parameterFrictionAngleRad());
m_cohPrTanFricAngle = (float)((float)femResCollection->parameterCohesion()/m_tanFricAng);
m_tanFricAng = tan( (float)femResCollection->parameterFrictionAngleRad() );
m_cohPrTanFricAngle = (float)( (float)femResCollection->parameterCohesion() / m_tanFricAng );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuGeoMechXfTensorResultAccessor::calculateInterpolatedValue(const cvf::Vec3f triangle[3], const RivIntersectionVertexWeights vertexWeights[3], float returnValues[3])
void RiuGeoMechXfTensorResultAccessor::calculateInterpolatedValue( const cvf::Vec3f triangle[3],
const RivIntersectionVertexWeights vertexWeights[3],
float returnValues[3] )
{
if ( tens11->size() == 0 )
{
@@ -121,7 +169,8 @@ void RiuGeoMechXfTensorResultAccessor::calculateInterpolatedValue(const cvf::Vec
return;
}
cvf::Mat3f triangleXf = cvf::GeometryTools::computePlaneHorizontalRotationMx(triangle[1] - triangle[0], triangle[2] - triangle[0]);
cvf::Mat3f triangleXf = cvf::GeometryTools::computePlaneHorizontalRotationMx( triangle[1] - triangle[0],
triangle[2] - triangle[0] );
for ( int triangleVxIdx = 0; triangleVxIdx < 3; ++triangleVxIdx )
{
@@ -135,68 +184,62 @@ void RiuGeoMechXfTensorResultAccessor::calculateInterpolatedValue(const cvf::Vec
int weightCount = vertexWeights[triangleVxIdx].size();
for ( int wIdx = 0; wIdx < weightCount; ++wIdx )
{
size_t resIdx = vertexWeights[triangleVxIdx].vxId(wIdx) ;
float interpolationWeight = vertexWeights[triangleVxIdx].weight(wIdx);
ipT11 += (*tens11)[resIdx] * interpolationWeight;
ipT22 += (*tens22)[resIdx] * interpolationWeight;
ipT33 += (*tens33)[resIdx] * interpolationWeight;
ipT12 += (*tens12)[resIdx] * interpolationWeight;
ipT23 += (*tens23)[resIdx] * interpolationWeight;
ipT13 += (*tens13)[resIdx] * interpolationWeight;
size_t resIdx = vertexWeights[triangleVxIdx].vxId( wIdx );
float interpolationWeight = vertexWeights[triangleVxIdx].weight( wIdx );
ipT11 += ( *tens11 )[resIdx] * interpolationWeight;
ipT22 += ( *tens22 )[resIdx] * interpolationWeight;
ipT33 += ( *tens33 )[resIdx] * interpolationWeight;
ipT12 += ( *tens12 )[resIdx] * interpolationWeight;
ipT23 += ( *tens23 )[resIdx] * interpolationWeight;
ipT13 += ( *tens13 )[resIdx] * interpolationWeight;
}
if ( ipT11 == HUGE_VAL || ipT11 != ipT11
|| ipT22 == HUGE_VAL || ipT22 != ipT22
|| ipT33 == HUGE_VAL || ipT33 != ipT33
|| ipT12 == HUGE_VAL || ipT12 != ipT12
|| ipT23 == HUGE_VAL || ipT23 != ipT23
|| ipT13 == HUGE_VAL || ipT13 != ipT13 ) // a != a is true for NAN's
if ( ipT11 == HUGE_VAL || ipT11 != ipT11 || ipT22 == HUGE_VAL || ipT22 != ipT22 || ipT33 == HUGE_VAL ||
ipT33 != ipT33 || ipT12 == HUGE_VAL || ipT12 != ipT12 || ipT23 == HUGE_VAL || ipT23 != ipT23 ||
ipT13 == HUGE_VAL || ipT13 != ipT13 ) // a != a is true for NAN's
{
returnValues[triangleVxIdx] = std::numeric_limits<float>::infinity();
}
else
{
caf::Ten3f tensor(ipT11, ipT22, ipT33,
ipT12, ipT23, ipT13);
caf::Ten3f xfTen = tensor.rotated(triangleXf);
caf::Ten3f tensor( ipT11, ipT22, ipT33, ipT12, ipT23, ipT13 );
caf::Ten3f xfTen = tensor.rotated( triangleXf );
returnValues[triangleVxIdx] = m_tensorOperation(*this, xfTen);
returnValues[triangleVxIdx] = m_tensorOperation( *this, xfTen );
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
float RiuGeoMechXfTensorResultAccessor::calculateElmNodeValue(const std::array<cvf::Vec3f, 3> & triangle, int globalElmNodeResIndex)
float RiuGeoMechXfTensorResultAccessor::calculateElmNodeValue( const std::array<cvf::Vec3f, 3>& triangle,
int globalElmNodeResIndex )
{
if ( tens11->size() == 0 ) return std::numeric_limits<float>::infinity();
cvf::Mat3f triangleXf = cvf::GeometryTools::computePlaneHorizontalRotationMx(triangle[1] - triangle[0], triangle[2] - triangle[0]);
cvf::Mat3f triangleXf = cvf::GeometryTools::computePlaneHorizontalRotationMx( triangle[1] - triangle[0],
triangle[2] - triangle[0] );
float ipT11 = (*tens11)[globalElmNodeResIndex];
float ipT22 = (*tens22)[globalElmNodeResIndex];
float ipT33 = (*tens33)[globalElmNodeResIndex];
float ipT12 = (*tens12)[globalElmNodeResIndex];
float ipT23 = (*tens23)[globalElmNodeResIndex];
float ipT13 = (*tens13)[globalElmNodeResIndex];
float ipT11 = ( *tens11 )[globalElmNodeResIndex];
float ipT22 = ( *tens22 )[globalElmNodeResIndex];
float ipT33 = ( *tens33 )[globalElmNodeResIndex];
float ipT12 = ( *tens12 )[globalElmNodeResIndex];
float ipT23 = ( *tens23 )[globalElmNodeResIndex];
float ipT13 = ( *tens13 )[globalElmNodeResIndex];
if ( ipT11 == HUGE_VAL || ipT11 != ipT11
|| ipT22 == HUGE_VAL || ipT22 != ipT22
|| ipT33 == HUGE_VAL || ipT33 != ipT33
|| ipT12 == HUGE_VAL || ipT12 != ipT12
|| ipT23 == HUGE_VAL || ipT23 != ipT23
|| ipT13 == HUGE_VAL || ipT13 != ipT13 ) // a != a is true for NAN's
if ( ipT11 == HUGE_VAL || ipT11 != ipT11 || ipT22 == HUGE_VAL || ipT22 != ipT22 || ipT33 == HUGE_VAL ||
ipT33 != ipT33 || ipT12 == HUGE_VAL || ipT12 != ipT12 || ipT23 == HUGE_VAL || ipT23 != ipT23 ||
ipT13 == HUGE_VAL || ipT13 != ipT13 ) // a != a is true for NAN's
{
return std::numeric_limits<float>::infinity();
}
else
{
caf::Ten3f tensor(ipT11, ipT22, ipT33,
ipT12, ipT23, ipT13);
caf::Ten3f xfTen = tensor.rotated(triangleXf);
caf::Ten3f tensor( ipT11, ipT22, ipT33, ipT12, ipT23, ipT13 );
caf::Ten3f xfTen = tensor.rotated( triangleXf );
float scalarValue = m_tensorOperation(*this, xfTen);
float scalarValue = m_tensorOperation( *this, xfTen );
return scalarValue;
}
}

View File

@@ -1,24 +1,24 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <vector>
#include <array>
#include <vector>
#include "cafTensor3.h"
#include <functional>
@@ -30,17 +30,17 @@ class RivIntersectionVertexWeights;
class RiuGeoMechXfTensorResultAccessor
{
public:
RiuGeoMechXfTensorResultAccessor(RigFemPartResultsCollection * femResCollection,
const RigFemResultAddress& resVarAddress,
int timeStepIdx);
RiuGeoMechXfTensorResultAccessor( RigFemPartResultsCollection* femResCollection,
const RigFemResultAddress& resVarAddress,
int timeStepIdx );
void calculateInterpolatedValue(const cvf::Vec3f triangle[3], const RivIntersectionVertexWeights vertexWeights[3], float returnValues[3]);
float calculateElmNodeValue(const std::array<cvf::Vec3f, 3> & triangle, int globalElmNodeResIndex);
void calculateInterpolatedValue( const cvf::Vec3f triangle[3],
const RivIntersectionVertexWeights vertexWeights[3],
float returnValues[3] );
float calculateElmNodeValue( const std::array<cvf::Vec3f, 3>& triangle, int globalElmNodeResIndex );
private:
const std::vector<float>* tens11;
const std::vector<float>* tens22;
const std::vector<float>* tens33;
@@ -48,21 +48,19 @@ private:
const std::vector<float>* tens23;
const std::vector<float>* tens13;
float m_tanFricAng ;
float m_tanFricAng;
float m_cohPrTanFricAngle;
std::function<float (const RiuGeoMechXfTensorResultAccessor&, const caf::Ten3f&) > m_tensorOperation;
float SN (const caf::Ten3f& t) const;
float STH (const caf::Ten3f& t) const;
float STQV (const caf::Ten3f& t) const;
float TNH (const caf::Ten3f& t) const;
float TNQV (const caf::Ten3f& t) const;
float THQV (const caf::Ten3f& t) const;
float TP (const caf::Ten3f& t) const;
float TPinc (const caf::Ten3f& t) const;
float FAULTMOB(const caf::Ten3f& t) const;
float PCRIT (const caf::Ten3f& t) const;
std::function<float( const RiuGeoMechXfTensorResultAccessor&, const caf::Ten3f& )> m_tensorOperation;
float SN( const caf::Ten3f& t ) const;
float STH( const caf::Ten3f& t ) const;
float STQV( const caf::Ten3f& t ) const;
float TNH( const caf::Ten3f& t ) const;
float TNQV( const caf::Ten3f& t ) const;
float THQV( const caf::Ten3f& t ) const;
float TP( const caf::Ten3f& t ) const;
float TPinc( const caf::Ten3f& t ) const;
float FAULTMOB( const caf::Ten3f& t ) const;
float PCRIT( const caf::Ten3f& t ) const;
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -20,153 +20,149 @@
#include "RiuGeoQuestNavigation.h"
#include "cafViewer.h"
#include "cvfCamera.h"
#include "cvfViewport.h"
#include "cvfHitItemCollection.h"
#include "cvfRay.h"
#include "cvfManipulatorTrackball.h"
#include "cvfRay.h"
#include "cvfViewport.h"
#include <QInputEvent>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuGeoQuestNavigation::RiuGeoQuestNavigation()
RiuGeoQuestNavigation::RiuGeoQuestNavigation() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuGeoQuestNavigation::~RiuGeoQuestNavigation() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuGeoQuestNavigation::handleInputEvent( QInputEvent* inputEvent )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuGeoQuestNavigation::~RiuGeoQuestNavigation()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuGeoQuestNavigation::handleInputEvent(QInputEvent* inputEvent)
{
if (! inputEvent) return false;
if ( !inputEvent ) return false;
bool isEventHandled = false;
switch (inputEvent->type())
switch ( inputEvent->type() )
{
case QEvent::MouseButtonPress:
case QEvent::MouseButtonPress:
{
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
QMouseEvent* me = static_cast<QMouseEvent*>( inputEvent );
int translatedMousePosX, translatedMousePosY;
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
cvfEventPos( me->x(), me->y(), &translatedMousePosX, &translatedMousePosY );
if (me->button() == Qt::LeftButton && isRotationEnabled())
if ( me->button() == Qt::LeftButton && isRotationEnabled() )
{
cvf::HitItemCollection hic;
bool hitSomething = m_viewer->rayPick(me->x(), me->y(), &hic);
bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic );
if (hitSomething)
{
if ( hitSomething )
{
cvf::Vec3d pointOfInterest = hic.firstItem()->intersectionPoint();
this->setPointOfInterest(pointOfInterest);
this->setPointOfInterest( pointOfInterest );
}
else
{
initializeRotationCenter();
}
m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY);
m_isNavigating = true;
m_trackball->startNavigation( cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY );
m_isNavigating = true;
m_hasMovedMouseDuringNavigation = false;
isEventHandled = true;
isEventHandled = true;
}
else if (me->button() == Qt::MidButton)
else if ( me->button() == Qt::MidButton )
{
if (me->modifiers() == Qt::NoModifier)
if ( me->modifiers() == Qt::NoModifier )
{
m_trackball->startNavigation(cvf::ManipulatorTrackball::PAN, translatedMousePosX, translatedMousePosY);
m_isNavigating = true;
m_trackball->startNavigation( cvf::ManipulatorTrackball::PAN,
translatedMousePosX,
translatedMousePosY );
m_isNavigating = true;
m_hasMovedMouseDuringNavigation = false;
isEventHandled = true;
isEventHandled = true;
}
}
forcePointOfInterestUpdateDuringNextWheelZoom();
}
break;
case QEvent::MouseButtonRelease:
case QEvent::MouseButtonRelease:
{
if (m_isNavigating)
if ( m_isNavigating )
{
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
if (me->button() == Qt::LeftButton || me->button() == Qt::MidButton )
QMouseEvent* me = static_cast<QMouseEvent*>( inputEvent );
if ( me->button() == Qt::LeftButton || me->button() == Qt::MidButton )
{
m_trackball->endNavigation();
m_isNavigating = false;
if (m_hasMovedMouseDuringNavigation) isEventHandled = true;
if ( m_hasMovedMouseDuringNavigation ) isEventHandled = true;
m_hasMovedMouseDuringNavigation = false;
}
}
}
break;
case QEvent::MouseMove:
case QEvent::MouseMove:
{
initializeRotationCenter();
if (m_isRotCenterInitialized)
if ( m_isRotCenterInitialized )
{
QMouseEvent * me = static_cast<QMouseEvent*>( inputEvent);
QMouseEvent* me = static_cast<QMouseEvent*>( inputEvent );
int translatedMousePosX, translatedMousePosY;
cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY);
cvfEventPos( me->x(), me->y(), &translatedMousePosX, &translatedMousePosY );
if (m_isNavigating)
if ( m_isNavigating )
{
if (m_isZooming)
if ( m_isZooming )
{
int delta = 3*(m_lastPosY - me->y());
this->zoomAlongRay(m_zoomRay.p(), delta);
int delta = 3 * ( m_lastPosY - me->y() );
this->zoomAlongRay( m_zoomRay.p(), delta );
m_lastPosX = me->x();
m_lastPosY = me->y();
}
else
{
bool needRedraw = m_trackball->updateNavigation(translatedMousePosX, translatedMousePosY);
if (needRedraw)
bool needRedraw = m_trackball->updateNavigation( translatedMousePosX, translatedMousePosY );
if ( needRedraw )
{
m_viewer->navigationPolicyUpdate();
}
}
isEventHandled = true;
isEventHandled = true;
m_hasMovedMouseDuringNavigation = true;
}
}
}
break;
case QEvent::Wheel:
case QEvent::Wheel:
{
if (inputEvent->modifiers() == Qt::NoModifier)
if ( inputEvent->modifiers() == Qt::NoModifier )
{
QWheelEvent* we = static_cast<QWheelEvent*>(inputEvent);
QWheelEvent* we = static_cast<QWheelEvent*>( inputEvent );
updatePointOfInterestDuringZoomIfNecessary(we->x(), we->y());
updatePointOfInterestDuringZoomIfNecessary( we->x(), we->y() );
if (m_isRotCenterInitialized)
if ( m_isRotCenterInitialized )
{
int translatedMousePosX, translatedMousePosY;
cvfEventPos(we->x(), we->y(), &translatedMousePosX, &translatedMousePosY);
cvfEventPos( we->x(), we->y(), &translatedMousePosX, &translatedMousePosY );
cvf::ref<cvf::Ray> ray = createZoomRay(translatedMousePosX, translatedMousePosY);
cvf::ref<cvf::Ray> ray = createZoomRay( translatedMousePosX, translatedMousePosY );
zoomAlongRay(ray.p(), -we->delta());
zoomAlongRay( ray.p(), -we->delta() );
}
isEventHandled = true;
}
}
break;
default:
break;
default:
break;
}
if (isSupposedToConsumeEvents())
if ( isSupposedToConsumeEvents() )
return isEventHandled;
else
return false;

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -21,12 +21,12 @@
#include "cafTrackBallBasedNavigation.h"
class RiuGeoQuestNavigation : public caf::TrackBallBasedNavigation
{
public:
RiuGeoQuestNavigation();
~RiuGeoQuestNavigation() override;
protected:
bool handleInputEvent(QInputEvent* inputEvent) override;
bool handleInputEvent( QInputEvent* inputEvent ) override;
};

View File

@@ -20,13 +20,13 @@
#include "RiaFontCache.h"
#include "RiuCvfOverlayItemWidget.h"
#include "RiuRimQwtPlotCurve.h"
#include "RiuQwtCurvePointTracker.h"
#include "RiuRimQwtPlotCurve.h"
#include "RiuWidgetDragger.h"
#include "RimGridCrossPlot.h"
#include "RimGridCrossPlotDataSet.h"
#include "RimGridCrossPlotCurve.h"
#include "RimGridCrossPlotDataSet.h"
#include "RimRegularLegendConfig.h"
#include "cafCmdFeatureMenuBuilder.h"
@@ -49,19 +49,22 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuGridCrossQwtPlot::RiuGridCrossQwtPlot(RimViewWindow* ownerViewWindow, QWidget* parent /*= nullptr*/)
: RiuQwtPlot(ownerViewWindow, parent)
RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimViewWindow* ownerViewWindow, QWidget* parent /*= nullptr*/ )
: RiuQwtPlot( ownerViewWindow, parent )
{
m_annotationTool = std::unique_ptr<RiuPlotAnnotationTool>(new RiuPlotAnnotationTool());
m_infoBox = new RiuDraggableOverlayFrame(this, canvas());
m_annotationTool = std::unique_ptr<RiuPlotAnnotationTool>( new RiuPlotAnnotationTool() );
m_infoBox = new RiuDraggableOverlayFrame( this, canvas() );
m_selectedPointMarker = new QwtPlotMarker;
// QwtPlotMarker takes ownership of the symbol, it is deleted in destructor of QwtPlotMarker
QwtSymbol* mySymbol = new QwtSymbol(QwtSymbol::Ellipse, QBrush(QColor(255, 255, 255, 50)), QPen(Qt::black, 2.0), QSize(10, 10));
m_selectedPointMarker->setSymbol(mySymbol);
m_selectedPointMarker->setLabelAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_selectedPointMarker->setSpacing(3);
QwtSymbol* mySymbol = new QwtSymbol( QwtSymbol::Ellipse,
QBrush( QColor( 255, 255, 255, 50 ) ),
QPen( Qt::black, 2.0 ),
QSize( 10, 10 ) );
m_selectedPointMarker->setSymbol( mySymbol );
m_selectedPointMarker->setLabelAlignment( Qt::AlignRight | Qt::AlignVCenter );
m_selectedPointMarker->setSpacing( 3 );
}
//--------------------------------------------------------------------------------------------------
@@ -69,7 +72,7 @@ RiuGridCrossQwtPlot::RiuGridCrossQwtPlot(RimViewWindow* ownerViewWindow, QWidget
//--------------------------------------------------------------------------------------------------
RiuGridCrossQwtPlot::~RiuGridCrossQwtPlot()
{
if (m_selectedPointMarker->plot())
if ( m_selectedPointMarker->plot() )
{
m_selectedPointMarker->detach();
}
@@ -79,14 +82,14 @@ RiuGridCrossQwtPlot::~RiuGridCrossQwtPlot()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::addOrUpdateDataSetLegend(RimGridCrossPlotDataSet* dataSet)
void RiuGridCrossQwtPlot::addOrUpdateDataSetLegend( RimGridCrossPlotDataSet* dataSet )
{
RiuCvfOverlayItemWidget* overlayWidget = nullptr;
auto it = m_legendWidgets.find(dataSet);
if (it == m_legendWidgets.end() || it->second == nullptr)
auto it = m_legendWidgets.find( dataSet );
if ( it == m_legendWidgets.end() || it->second == nullptr )
{
overlayWidget = new RiuCvfOverlayItemWidget(this, canvas());
overlayWidget = new RiuCvfOverlayItemWidget( this, canvas() );
m_legendWidgets[dataSet] = overlayWidget;
}
else
@@ -94,12 +97,12 @@ void RiuGridCrossQwtPlot::addOrUpdateDataSetLegend(RimGridCrossPlotDataSet* data
overlayWidget = it->second;
}
if (overlayWidget)
if ( overlayWidget )
{
caf::TitledOverlayFrame* overlayItem = dataSet->legendConfig()->titledOverlayFrame();
applyFontSizeToOverlayItem(overlayItem);
resizeOverlayItemToFitPlot(overlayItem);
overlayWidget->updateFromOverlayItem(overlayItem);
applyFontSizeToOverlayItem( overlayItem );
resizeOverlayItemToFitPlot( overlayItem );
overlayWidget->updateFromOverlayItem( overlayItem );
}
this->updateLegendLayout();
}
@@ -107,18 +110,18 @@ void RiuGridCrossQwtPlot::addOrUpdateDataSetLegend(RimGridCrossPlotDataSet* data
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::removeDataSetLegend(RimGridCrossPlotDataSet* dataSetToShowLegendFor)
void RiuGridCrossQwtPlot::removeDataSetLegend( RimGridCrossPlotDataSet* dataSetToShowLegendFor )
{
auto it = m_legendWidgets.find(dataSetToShowLegendFor);
if (it != m_legendWidgets.end())
auto it = m_legendWidgets.find( dataSetToShowLegendFor );
if ( it != m_legendWidgets.end() )
{
if (it->second != nullptr)
if ( it->second != nullptr )
{
it->second->hide();
it->second->deleteLater();
}
m_legendWidgets.erase(it);
m_legendWidgets.erase( it );
}
this->updateLegendLayout();
@@ -129,16 +132,16 @@ void RiuGridCrossQwtPlot::removeDataSetLegend(RimGridCrossPlotDataSet* dataSetTo
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::removeDanglingDataSetLegends()
{
for (auto it = m_legendWidgets.begin(); it != m_legendWidgets.end();)
for ( auto it = m_legendWidgets.begin(); it != m_legendWidgets.end(); )
{
if (it->first.isNull())
if ( it->first.isNull() )
{
if (it->second != nullptr)
if ( it->second != nullptr )
{
it->second->hide();
it->second->deleteLater();
}
m_legendWidgets.erase(it++);
m_legendWidgets.erase( it++ );
}
else
{
@@ -152,29 +155,29 @@ void RiuGridCrossQwtPlot::removeDanglingDataSetLegends()
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::updateLegendSizesToMatchPlot()
{
RimGridCrossPlot* crossPlot = dynamic_cast<RimGridCrossPlot*>(ownerPlotDefinition());
if (!crossPlot) return;
RimGridCrossPlot* crossPlot = dynamic_cast<RimGridCrossPlot*>( ownerPlotDefinition() );
if ( !crossPlot ) return;
bool anyLegendResized = false;
for (RimGridCrossPlotDataSet* dataSet : crossPlot->dataSets())
for ( RimGridCrossPlotDataSet* dataSet : crossPlot->dataSets() )
{
if (!dataSet->isChecked() || !dataSet->legendConfig()->showLegend()) continue;
if ( !dataSet->isChecked() || !dataSet->legendConfig()->showLegend() ) continue;
auto pairIt = m_legendWidgets.find(dataSet);
if (pairIt != m_legendWidgets.end())
auto pairIt = m_legendWidgets.find( dataSet );
if ( pairIt != m_legendWidgets.end() )
{
RiuCvfOverlayItemWidget* overlayWidget = pairIt->second;
caf::TitledOverlayFrame* overlayItem = dataSet->legendConfig()->titledOverlayFrame();
applyFontSizeToOverlayItem(overlayItem);
if (resizeOverlayItemToFitPlot(overlayItem))
caf::TitledOverlayFrame* overlayItem = dataSet->legendConfig()->titledOverlayFrame();
applyFontSizeToOverlayItem( overlayItem );
if ( resizeOverlayItemToFitPlot( overlayItem ) )
{
anyLegendResized = true;
overlayWidget->updateFromOverlayItem(overlayItem);
overlayWidget->updateFromOverlayItem( overlayItem );
}
}
}
if (anyLegendResized)
if ( anyLegendResized )
{
updateLegendLayout();
}
@@ -183,13 +186,13 @@ void RiuGridCrossQwtPlot::updateLegendSizesToMatchPlot()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::updateAnnotationObjects(RimPlotAxisProperties* axisProperties)
void RiuGridCrossQwtPlot::updateAnnotationObjects( RimPlotAxisProperties* axisProperties )
{
m_annotationTool->detachAllAnnotations();
for (auto annotation : axisProperties->annotations())
for ( auto annotation : axisProperties->annotations() )
{
m_annotationTool->attachAnnotationLine(this, annotation->color(), annotation->name(), annotation->value());
m_annotationTool->attachAnnotationLine( this, annotation->color(), annotation->name(), annotation->value() );
}
}
@@ -208,51 +211,51 @@ void RiuGridCrossQwtPlot::updateLayout()
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::updateInfoBoxLayout()
{
RimGridCrossPlot* crossPlot = dynamic_cast<RimGridCrossPlot*>(ownerPlotDefinition());
if (!crossPlot) return;
RimGridCrossPlot* crossPlot = dynamic_cast<RimGridCrossPlot*>( ownerPlotDefinition() );
if ( !crossPlot ) return;
bool showInfo = false;
if (crossPlot->showInfoBox())
if ( crossPlot->showInfoBox() )
{
QStringList curveInfoTexts;
for (auto dataSet : crossPlot->dataSets())
for ( auto dataSet : crossPlot->dataSets() )
{
QString curveInfoText = dataSet->infoText();
if (dataSet->isChecked() && !curveInfoText.isEmpty())
if ( dataSet->isChecked() && !curveInfoText.isEmpty() )
{
curveInfoTexts += curveInfoText;
}
}
QStringList infoText;
if (curveInfoTexts.size() > 1)
if ( curveInfoTexts.size() > 1 )
{
infoText += QString("<ol style=\"margin-top: 0px; margin-left: 15px; -qt-list-indent:0;\">");
for (QString curveInfoText : curveInfoTexts)
infoText += QString( "<ol style=\"margin-top: 0px; margin-left: 15px; -qt-list-indent:0;\">" );
for ( QString curveInfoText : curveInfoTexts )
{
infoText += QString("<li>%1</li>").arg(curveInfoText);
infoText += QString( "<li>%1</li>" ).arg( curveInfoText );
}
infoText += QString("</ol>");
infoText += QString( "</ol>" );
}
else if (curveInfoTexts.size() > 0)
else if ( curveInfoTexts.size() > 0 )
{
infoText += curveInfoTexts.front();
}
if (!infoText.empty())
if ( !infoText.empty() )
{
m_infoBox->label()->setText(infoText.join("\n"));
m_infoBox->label()->setText( infoText.join( "\n" ) );
QFont font = m_infoBox->font();
font.setPointSize(crossPlot->legendFontSize());
m_infoBox->setFont(font);
font.setPointSize( crossPlot->legendFontSize() );
m_infoBox->setFont( font );
m_infoBox->adjustSize();
QRect infoRect = m_infoBox->frameGeometry();
QRect infoRect = m_infoBox->frameGeometry();
QRect canvasRect = canvas()->frameGeometry();
infoRect.moveTop(canvasRect.top() + 4);
infoRect.moveRight(canvasRect.right() - 4);
m_infoBox->move(infoRect.topLeft());
infoRect.moveTop( canvasRect.top() + 4 );
infoRect.moveRight( canvasRect.right() - 4 );
m_infoBox->move( infoRect.topLeft() );
showInfo = true;
}
}
if (showInfo)
if ( showInfo )
{
m_infoBox->show();
}
@@ -277,38 +280,37 @@ void RiuGridCrossQwtPlot::updateLegendLayout()
removeDanglingDataSetLegends();
RimGridCrossPlot* crossPlot = dynamic_cast<RimGridCrossPlot*>(ownerPlotDefinition());
RimGridCrossPlot* crossPlot = dynamic_cast<RimGridCrossPlot*>( ownerPlotDefinition() );
if (!crossPlot) return;
if ( !crossPlot ) return;
std::set<QString> legendTypes;
for (RimGridCrossPlotDataSet* dataSet : crossPlot->dataSets())
for ( RimGridCrossPlotDataSet* dataSet : crossPlot->dataSets() )
{
if (dataSet->isChecked() && dataSet->groupingEnabled() && dataSet->legendConfig()->showLegend())
if ( dataSet->isChecked() && dataSet->groupingEnabled() && dataSet->legendConfig()->showLegend() )
{
auto pairIt = m_legendWidgets.find(dataSet);
if (pairIt != m_legendWidgets.end())
auto pairIt = m_legendWidgets.find( dataSet );
if ( pairIt != m_legendWidgets.end() )
{
RiuCvfOverlayItemWidget* overlayWidget = pairIt->second;
// Show only one copy of each legend type
if (!legendTypes.count(dataSet->groupParameter()))
if ( !legendTypes.count( dataSet->groupParameter() ) )
{
if (ypos + overlayWidget->height() + spacing > this->canvas()->height())
if ( ypos + overlayWidget->height() + spacing > this->canvas()->height() )
{
xpos += spacing + maxColumnWidth;
ypos = startMarginY;
ypos = startMarginY;
maxColumnWidth = 0;
}
overlayWidget->show();
overlayWidget->move(xpos, ypos);
overlayWidget->move( xpos, ypos );
ypos += pairIt->second->height() + spacing;
maxColumnWidth = std::max(maxColumnWidth, pairIt->second->width());
legendTypes.insert(dataSet->groupParameter());
maxColumnWidth = std::max( maxColumnWidth, pairIt->second->width() );
legendTypes.insert( dataSet->groupParameter() );
}
}
}
@@ -318,36 +320,36 @@ void RiuGridCrossQwtPlot::updateLegendLayout()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::resizeEvent(QResizeEvent* e)
void RiuGridCrossQwtPlot::resizeEvent( QResizeEvent* e )
{
QwtPlot::resizeEvent(e);
QwtPlot::resizeEvent( e );
updateLegendSizesToMatchPlot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuGridCrossQwtPlot::resizeOverlayItemToFitPlot(caf::TitledOverlayFrame* overlayItem)
bool RiuGridCrossQwtPlot::resizeOverlayItemToFitPlot( caf::TitledOverlayFrame* overlayItem )
{
QSize plotSize = this->canvas()->contentsRect().size();
QSize plotSize = this->canvas()->contentsRect().size();
cvf::Vec2ui existingRenderSize = overlayItem->renderSize();
cvf::Vec2ui legendSize = overlayItem->preferredSize();
cvf::Vec2ui legendSize = overlayItem->preferredSize();
bool sizeAltered = false;
if (plotSize.width() > 0 && (double)legendSize.x() > 0.9 * plotSize.width())
if ( plotSize.width() > 0 && (double)legendSize.x() > 0.9 * plotSize.width() )
{
legendSize.x() = (plotSize.width() * 9) / 10;
legendSize.x() = ( plotSize.width() * 9 ) / 10;
sizeAltered = true;
}
if (plotSize.height() > 0 && (double)legendSize.y() > 0.9 * plotSize.height())
if ( plotSize.height() > 0 && (double)legendSize.y() > 0.9 * plotSize.height() )
{
legendSize.y() = (plotSize.height() * 9) / 10;
legendSize.y() = ( plotSize.height() * 9 ) / 10;
sizeAltered = true;
}
overlayItem->setRenderSize(legendSize);
overlayItem->setRenderSize( legendSize );
if (legendSize.x() != existingRenderSize.x() || legendSize.y() != existingRenderSize.y())
if ( legendSize.x() != existingRenderSize.x() || legendSize.y() != existingRenderSize.y() )
{
sizeAltered = true;
}
@@ -358,45 +360,46 @@ bool RiuGridCrossQwtPlot::resizeOverlayItemToFitPlot(caf::TitledOverlayFrame* ov
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::contextMenuEvent(QContextMenuEvent* event)
void RiuGridCrossQwtPlot::contextMenuEvent( QContextMenuEvent* event )
{
QMenu menu;
caf::CmdFeatureMenuBuilder menuBuilder;
caf::SelectionManager::instance()->setSelectedItem(ownerViewWindow());
caf::SelectionManager::instance()->setSelectedItem( ownerViewWindow() );
menuBuilder << "RicSwapGridCrossPlotDataSetAxesFeature";
menuBuilder << "Separator";
menuBuilder << "RicShowPlotDataFeature";
menuBuilder.appendToMenu(&menu);
menuBuilder.appendToMenu( &menu );
if (menu.actions().size() > 0)
if ( menu.actions().size() > 0 )
{
menu.exec(event->globalPos());
menu.exec( event->globalPos() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::selectSample(QwtPlotCurve* curve, int sampleNumber)
void RiuGridCrossQwtPlot::selectSample( QwtPlotCurve* curve, int sampleNumber )
{
QPointF sample = curve->sample(sampleNumber);
m_selectedPointMarker->setValue(sample);
m_selectedPointMarker->setAxes(QwtPlot::xBottom, QwtPlot::yLeft);
m_selectedPointMarker->attach(this);
QPointF sample = curve->sample( sampleNumber );
m_selectedPointMarker->setValue( sample );
m_selectedPointMarker->setAxes( QwtPlot::xBottom, QwtPlot::yLeft );
m_selectedPointMarker->attach( this );
QString curveName, xAxisName, yAxisName;
if (curveText(curve, &curveName, &xAxisName, &yAxisName))
if ( curveText( curve, &curveName, &xAxisName, &yAxisName ) )
{
QString labelFormat("<div style=\"margin: 4px;\"><b>%1:</b><br/>%2 = %3, %4 = %5</div>");
QString labelString = labelFormat.arg(curveName).arg(xAxisName).arg(sample.x()).arg(yAxisName).arg(sample.y());
QwtText curveLabel(labelString, QwtText::RichText);
curveLabel.setBackgroundBrush(QBrush(QColor(250, 250, 250, 220)));
curveLabel.setPaintAttribute(QwtText::PaintBackground);
curveLabel.setBorderPen(QPen(Qt::black, 1.0));
curveLabel.setBorderRadius(2.0);
m_selectedPointMarker->setLabel(curveLabel);
QString labelFormat( "<div style=\"margin: 4px;\"><b>%1:</b><br/>%2 = %3, %4 = %5</div>" );
QString labelString =
labelFormat.arg( curveName ).arg( xAxisName ).arg( sample.x() ).arg( yAxisName ).arg( sample.y() );
QwtText curveLabel( labelString, QwtText::RichText );
curveLabel.setBackgroundBrush( QBrush( QColor( 250, 250, 250, 220 ) ) );
curveLabel.setPaintAttribute( QwtText::PaintBackground );
curveLabel.setBorderPen( QPen( Qt::black, 1.0 ) );
curveLabel.setBorderRadius( 2.0 );
m_selectedPointMarker->setLabel( curveLabel );
}
}
@@ -411,24 +414,24 @@ void RiuGridCrossQwtPlot::clearSampleSelection()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuGridCrossQwtPlot::curveText(const QwtPlotCurve* curve,
QString* curveTitle,
QString* xParamName,
QString* yParamName) const
bool RiuGridCrossQwtPlot::curveText( const QwtPlotCurve* curve,
QString* curveTitle,
QString* xParamName,
QString* yParamName ) const
{
CVF_ASSERT(curveTitle && xParamName && yParamName);
CVF_ASSERT( curveTitle && xParamName && yParamName );
auto riuCurve = dynamic_cast<const RiuRimQwtPlotCurve*>(curve);
if (riuCurve)
auto riuCurve = dynamic_cast<const RiuRimQwtPlotCurve*>( curve );
if ( riuCurve )
{
auto crossPlotCurve = dynamic_cast<const RimGridCrossPlotCurve*>(riuCurve->ownerRimCurve());
if (crossPlotCurve)
auto crossPlotCurve = dynamic_cast<const RimGridCrossPlotCurve*>( riuCurve->ownerRimCurve() );
if ( crossPlotCurve )
{
*curveTitle = crossPlotCurve->curveName();
RimGridCrossPlotDataSet* dataSet = nullptr;
crossPlotCurve->firstAncestorOrThisOfType(dataSet);
if (dataSet)
crossPlotCurve->firstAncestorOrThisOfType( dataSet );
if ( dataSet )
{
*xParamName = dataSet->xAxisName();
*yParamName = dataSet->yAxisName();
@@ -442,10 +445,10 @@ bool RiuGridCrossQwtPlot::curveText(const QwtPlotCurve* curve,
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuGridCrossQwtPlot::applyFontSizeToOverlayItem(caf::TitledOverlayFrame* overlayItem)
void RiuGridCrossQwtPlot::applyFontSizeToOverlayItem( caf::TitledOverlayFrame* overlayItem )
{
RimGridCrossPlot* crossPlot = static_cast<RimGridCrossPlot*>(ownerViewWindow());
int fontSize = crossPlot->legendFontSize();
cvf::ref<cvf::Font> cafFont = RiaFontCache::getFont(RiaFontCache::fontSizeEnumFromPointSize(fontSize));
overlayItem->setFont(cafFont.p());
RimGridCrossPlot* crossPlot = static_cast<RimGridCrossPlot*>( ownerViewWindow() );
int fontSize = crossPlot->legendFontSize();
cvf::ref<cvf::Font> cafFont = RiaFontCache::getFont( RiaFontCache::fontSizeEnumFromPointSize( fontSize ) );
overlayItem->setFont( cafFont.p() );
}

View File

@@ -48,34 +48,34 @@ class RiuGridCrossQwtPlot : public RiuQwtPlot
Q_OBJECT;
public:
RiuGridCrossQwtPlot(RimViewWindow* ownerViewWindow, QWidget* parent = nullptr);
RiuGridCrossQwtPlot( RimViewWindow* ownerViewWindow, QWidget* parent = nullptr );
~RiuGridCrossQwtPlot();
void addOrUpdateDataSetLegend(RimGridCrossPlotDataSet* dataSetToShowLegendFor);
void removeDataSetLegend(RimGridCrossPlotDataSet* dataSetToShowLegendFor);
void addOrUpdateDataSetLegend( RimGridCrossPlotDataSet* dataSetToShowLegendFor );
void removeDataSetLegend( RimGridCrossPlotDataSet* dataSetToShowLegendFor );
void removeDanglingDataSetLegends();
void updateLegendSizesToMatchPlot();
void updateAnnotationObjects(RimPlotAxisProperties* axisProperties);
void updateAnnotationObjects( RimPlotAxisProperties* axisProperties );
protected:
void updateLayout() override;
void updateInfoBoxLayout();
void updateLegendLayout();
void resizeEvent(QResizeEvent* e) override;
bool resizeOverlayItemToFitPlot(caf::TitledOverlayFrame* overlayItem);
void contextMenuEvent(QContextMenuEvent*) override;
void resizeEvent( QResizeEvent* e ) override;
bool resizeOverlayItemToFitPlot( caf::TitledOverlayFrame* overlayItem );
void contextMenuEvent( QContextMenuEvent* ) override;
void selectSample(QwtPlotCurve* curve, int sampleNumber) override;
void selectSample( QwtPlotCurve* curve, int sampleNumber ) override;
void clearSampleSelection() override;
bool curveText(const QwtPlotCurve* curve, QString* curveTitle, QString* xParamName, QString* yParamName) const;
void applyFontSizeToOverlayItem(caf::TitledOverlayFrame* overlayItem);
bool curveText( const QwtPlotCurve* curve, QString* curveTitle, QString* xParamName, QString* yParamName ) const;
void applyFontSizeToOverlayItem( caf::TitledOverlayFrame* overlayItem );
private:
typedef caf::PdmPointer<RimGridCrossPlotDataSet> DataSetPtr;
typedef QPointer<RiuCvfOverlayItemWidget> LegendPtr;
typedef QPointer<RiuDraggableOverlayFrame> InfoBoxPtr;
typedef QPointer<RiuCvfOverlayItemWidget> LegendPtr;
typedef QPointer<RiuDraggableOverlayFrame> InfoBoxPtr;
InfoBoxPtr m_infoBox;
std::map<DataSetPtr, LegendPtr> m_legendWidgets;
std::unique_ptr<RiuPlotAnnotationTool> m_annotationTool;
QwtPlotMarker* m_selectedPointMarker;
};

View File

@@ -3,17 +3,17 @@
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -25,149 +25,147 @@
#include <cmath>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuGridStatisticsHistogramWidget::RiuGridStatisticsHistogramWidget(QWidget * parent /*= 0*/, Qt::WindowFlags f /*= 0*/):
QWidget(parent, f)
RiuGridStatisticsHistogramWidget::RiuGridStatisticsHistogramWidget( QWidget* parent /*= 0*/, Qt::WindowFlags f /*= 0*/ )
: QWidget( parent, f )
{
m_minPercentile = HUGE_VAL;
m_maxPercentile = HUGE_VAL;
m_mean = HUGE_VAL;
m_min = HUGE_VAL;
m_max = -HUGE_VAL;
m_minPercentile = HUGE_VAL;
m_maxPercentile = HUGE_VAL;
m_mean = HUGE_VAL;
m_min = HUGE_VAL;
m_max = -HUGE_VAL;
m_maxHistogramCount = 0;
m_width = 0;
m_width = 0;
m_height = 0;
m_x = 0;
m_y = 0;
m_x = 0;
m_y = 0;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuGridStatisticsHistogramWidget::paintEvent(QPaintEvent* event)
void RiuGridStatisticsHistogramWidget::paintEvent( QPaintEvent* event )
{
QPainter painter(this);
this->draw(&painter, 0, 0, this->width()-1, this->height()-1);
QPainter painter( this );
this->draw( &painter, 0, 0, this->width() - 1, this->height() - 1 );
}
void RiuGridStatisticsHistogramWidget::draw(QPainter *painter,int x, int y, int width, int height )
void RiuGridStatisticsHistogramWidget::draw( QPainter* painter, int x, int y, int width, int height )
{
// Initialize variables
m_x = x; m_y = y; m_width = width; m_height = height;
m_x = x;
m_y = y;
m_width = width;
m_height = height;
QRect r1(x,y,width, height);
QRect r1( x, y, width, height );
// Frame around it all;
QColor windowColor = palette().color(QPalette::Window);// QColor(144, 173, 208, 180);
QColor frameColor = palette().color(QPalette::WindowText);//QColor(220, 240, 255, 100);
QColor foregroundColor = palette().color(QPalette::Dark);// QColor(100, 141, 189);
QColor windowColor = palette().color( QPalette::Window ); // QColor(144, 173, 208, 180);
QColor frameColor = palette().color( QPalette::WindowText ); // QColor(220, 240, 255, 100);
QColor foregroundColor = palette().color( QPalette::Dark ); // QColor(100, 141, 189);
//painter->fillRect(r1, windowColor);
painter->setPen(frameColor);
painter->drawRect(r1);
// painter->fillRect(r1, windowColor);
painter->setPen( frameColor );
painter->drawRect( r1 );
// Columns
painter->setPen(foregroundColor);
painter->setPen( foregroundColor );
int yColBottom = yPosFromCount(0);
for ( size_t colIdx = 0; colIdx < m_histogramData.size(); ++colIdx)
int yColBottom = yPosFromCount( 0 );
for ( size_t colIdx = 0; colIdx < m_histogramData.size(); ++colIdx )
{
size_t colCount = m_histogramData[colIdx];
int yColTop = yPosFromCount(colCount);
int xColStart = xPosFromColIdx(colIdx);
int xColEnd = xPosFromColIdx(colIdx+1);
size_t colCount = m_histogramData[colIdx];
int yColTop = yPosFromCount( colCount );
int xColStart = xPosFromColIdx( colIdx );
int xColEnd = xPosFromColIdx( colIdx + 1 );
// First line
painter->drawLine(xColStart, yColBottom, xColStart, yColTop);
painter->drawLine( xColStart, yColBottom, xColStart, yColTop );
// If we span more than one pixel with :
++xColStart;
for (;xColStart < xColEnd; ++xColStart )
for ( ; xColStart < xColEnd; ++xColStart )
{
painter->drawLine(xColStart, yColBottom, xColStart, yColTop);
painter->drawLine( xColStart, yColBottom, xColStart, yColTop );
}
}
// Vertical lines for percentiles
if (m_minPercentile != HUGE_VAL)
if ( m_minPercentile != HUGE_VAL )
{
int xpos = xPosFromDomainValue(m_minPercentile);
painter->setPen(QColor(255, 0, 0, 200));
painter->drawLine(xpos, y+1, xpos, y + height -1);
int xpos = xPosFromDomainValue( m_minPercentile );
painter->setPen( QColor( 255, 0, 0, 200 ) );
painter->drawLine( xpos, y + 1, xpos, y + height - 1 );
}
// Vertical lines for percentiles
if (m_maxPercentile != HUGE_VAL)
if ( m_maxPercentile != HUGE_VAL )
{
int xpos = xPosFromDomainValue(m_maxPercentile);
painter->setPen(QColor(255, 0, 0, 200));
painter->drawLine(xpos, y+1, xpos, y + height -1);
int xpos = xPosFromDomainValue( m_maxPercentile );
painter->setPen( QColor( 255, 0, 0, 200 ) );
painter->drawLine( xpos, y + 1, xpos, y + height - 1 );
}
// Vertical lines for percentiles
if (m_mean != HUGE_VAL)
if ( m_mean != HUGE_VAL )
{
int xpos = xPosFromDomainValue(m_mean);
painter->setPen(QColor(0, 0, 255, 200));
painter->drawLine(xpos, y+1, xpos, y + height -1);
int xpos = xPosFromDomainValue( m_mean );
painter->setPen( QColor( 0, 0, 255, 200 ) );
painter->drawLine( xpos, y + 1, xpos, y + height - 1 );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuGridStatisticsHistogramWidget::setHistogramData(double min, double max, const std::vector<size_t>& histogram)
void RiuGridStatisticsHistogramWidget::setHistogramData( double min, double max, const std::vector<size_t>& histogram )
{
m_min = min;
m_max = max;
m_min = min;
m_max = max;
m_histogramData = histogram;
m_maxHistogramCount = 0;
for (size_t colIdx = 0; colIdx < m_histogramData.size(); ++colIdx)
for ( size_t colIdx = 0; colIdx < m_histogramData.size(); ++colIdx )
{
if (m_maxHistogramCount < m_histogramData[colIdx]) m_maxHistogramCount = m_histogramData[colIdx] ;
if ( m_maxHistogramCount < m_histogramData[colIdx] ) m_maxHistogramCount = m_histogramData[colIdx];
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuGridStatisticsHistogramWidget::setPercentiles(double pmin, double pmax)
void RiuGridStatisticsHistogramWidget::setPercentiles( double pmin, double pmax )
{
m_minPercentile = pmin;
m_minPercentile = pmin;
m_maxPercentile = pmax;
}
#define xBorder 1
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
int RiuGridStatisticsHistogramWidget::xPosFromColIdx(size_t colIdx)
int RiuGridStatisticsHistogramWidget::xPosFromColIdx( size_t colIdx )
{
return (int)(m_x + xBorder + (m_width - 2*xBorder) * colIdx/m_histogramData.size());
return (int)( m_x + xBorder + ( m_width - 2 * xBorder ) * colIdx / m_histogramData.size() );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
int RiuGridStatisticsHistogramWidget::xPosFromDomainValue(double value)
int RiuGridStatisticsHistogramWidget::xPosFromDomainValue( double value )
{
double range = m_max - m_min;
return (range == 0.0) ? (int)(m_x + xBorder) : (int)(m_x + xBorder + (m_width - 2*xBorder) * (value - m_min)/(m_max - m_min));
double range = m_max - m_min;
return ( range == 0.0 ) ? (int)( m_x + xBorder )
: (int)( m_x + xBorder + ( m_width - 2 * xBorder ) * ( value - m_min ) / ( m_max - m_min ) );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
int RiuGridStatisticsHistogramWidget::yPosFromCount(size_t colHeight)
int RiuGridStatisticsHistogramWidget::yPosFromCount( size_t colHeight )
{
return (int)(m_y + m_height - 1 - (m_height - 3) * colHeight/m_maxHistogramCount);
return (int)( m_y + m_height - 1 - ( m_height - 3 ) * colHeight / m_maxHistogramCount );
}

View File

@@ -3,17 +3,17 @@
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -26,26 +26,28 @@ class QPaintEvent;
class QString;
class QStringList;
class RiuGridStatisticsHistogramWidget : public QWidget
{
public:
RiuGridStatisticsHistogramWidget( QWidget * parent = nullptr, Qt::WindowFlags f = nullptr);
RiuGridStatisticsHistogramWidget( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr );
void setHistogramData(double min, double max, const std::vector<size_t>& histogram);
void setPercentiles(double pmin, double pmax);
void setMean(double mean) {m_mean = mean;}
void setHistogramData( double min, double max, const std::vector<size_t>& histogram );
void setPercentiles( double pmin, double pmax );
void setMean( double mean )
{
m_mean = mean;
}
protected:
void paintEvent(QPaintEvent* event) override;
void paintEvent( QPaintEvent* event ) override;
private:
void draw(QPainter *painter,int x, int y, int width, int height );
void draw( QPainter* painter, int x, int y, int width, int height );
int xPosFromColIdx(size_t colIdx);
int yPosFromCount(size_t colHeight);
int xPosFromColIdx( size_t colIdx );
int yPosFromCount( size_t colHeight );
int xPosFromDomainValue(double value);
int xPosFromDomainValue( double value );
std::vector<size_t> m_histogramData;
double m_max;
@@ -55,8 +57,8 @@ private:
double m_mean;
size_t m_maxHistogramCount;
double m_width;
double m_height;
double m_x;
double m_y;
double m_width;
double m_height;
double m_x;
double m_y;
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -21,14 +21,14 @@
#include <QWidget>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RimViewWindow* RiuInterfaceToViewWindow::viewWindowFromWidget(QWidget* possibleViewWindowWidget)
RimViewWindow* RiuInterfaceToViewWindow::viewWindowFromWidget( QWidget* possibleViewWindowWidget )
{
auto interfaceToViewWindow = dynamic_cast<RiuInterfaceToViewWindow*>(possibleViewWindowWidget);
auto interfaceToViewWindow = dynamic_cast<RiuInterfaceToViewWindow*>( possibleViewWindowWidget );
if ( interfaceToViewWindow )
{
return (interfaceToViewWindow->ownerViewWindow());
return ( interfaceToViewWindow->ownerViewWindow() );
}
else
{

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -30,6 +30,5 @@ class RiuInterfaceToViewWindow
{
public:
virtual RimViewWindow* ownerViewWindow() const = 0;
static RimViewWindow* viewWindowFromWidget( QWidget* possibleViewWindowWidget);
static RimViewWindow* viewWindowFromWidget( QWidget* possibleViewWindowWidget );
};

File diff suppressed because it is too large Load Diff

View File

@@ -3,17 +3,17 @@
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -23,8 +23,8 @@
#include "RiuMainWindowBase.h"
#include "RiuMdiArea.h"
#include "cafPdmUiDragDropInterface.h"
#include "cafPdmObjectHandle.h"
#include "cafPdmUiDragDropInterface.h"
#include <QEvent>
#include <QLabel>
@@ -55,21 +55,21 @@ struct RimMdiWindowGeometry;
namespace caf
{
class PdmUiTreeView;
class AnimationToolBar;
class PdmObject;
class PdmUiPropertyView;
class PdmUiItem;
}
class PdmUiTreeView;
class AnimationToolBar;
class PdmObject;
class PdmUiPropertyView;
class PdmUiItem;
} // namespace caf
namespace ssihub
{
class Interface;
class Interface;
}
//==================================================================================================
//
//
//
//
//==================================================================================================
class RiuMainWindow : public RiuMainWindowBase
@@ -81,187 +81,186 @@ public:
static RiuMainWindow* instance();
QString mainWindowName() override;
void initializeGuiNewProjectLoaded();
void cleanupGuiCaseClose();
void cleanupGuiBeforeProjectClose();
QString mainWindowName() override;
void removeViewer( QWidget* viewer ) override;
void addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry) override;
void setActiveViewer(QWidget* subWindow) override;
void initializeGuiNewProjectLoaded();
void cleanupGuiCaseClose();
void cleanupGuiBeforeProjectClose();
void setResultInfo(const QString& info) const;
void removeViewer( QWidget* viewer ) override;
void addViewer( QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry ) override;
void setActiveViewer( QWidget* subWindow ) override;
void refreshViewActions();
void refreshAnimationActions();
void updateScaleValue();
void setResultInfo( const QString& info ) const;
void refreshViewActions();
void refreshAnimationActions();
void updateScaleValue();
RiuProcessMonitor* processMonitor();
void selectedCases(std::vector<RimCase*>& cases);
void selectedCases( std::vector<RimCase*>& cases );
void setDefaultWindowSize();
void setDefaultWindowSize();
void refreshDrawStyleActions();
void tileSubWindows() override;
void storeSubWindowTiling(bool tiled) override;
void clearWindowTiling() override;
void refreshDrawStyleActions();
bool subWindowsAreTiled() const override;
bool isAnyMdiSubWindowVisible();
QMdiSubWindow* findMdiSubWindow(QWidget* viewer) override;
RimViewWindow* findViewWindowFromSubWindow(QMdiSubWindow* lhs);
QList<QMdiSubWindow*> subWindowList(QMdiArea::WindowOrder order);
void tileSubWindows() override;
void storeSubWindowTiling( bool tiled ) override;
void clearWindowTiling() override;
RiuResultQwtPlot* resultPlot();
RiuRelativePermeabilityPlotPanel* relativePermeabilityPlotPanel();
RiuPvtPlotPanel* pvtPlotPanel();
RiuMohrsCirclePlot* mohrsCirclePlot();
RiuMessagePanel* messagePanel();
bool subWindowsAreTiled() const override;
bool isAnyMdiSubWindowVisible();
QMdiSubWindow* findMdiSubWindow( QWidget* viewer ) override;
RimViewWindow* findViewWindowFromSubWindow( QMdiSubWindow* lhs );
QList<QMdiSubWindow*> subWindowList( QMdiArea::WindowOrder order );
void showProcessMonitorDockPanel();
void setDefaultToolbarVisibility();
void applyFontSizesToDockedPlots();
RiuResultQwtPlot* resultPlot();
RiuRelativePermeabilityPlotPanel* relativePermeabilityPlotPanel();
RiuPvtPlotPanel* pvtPlotPanel();
RiuMohrsCirclePlot* mohrsCirclePlot();
RiuMessagePanel* messagePanel();
void showProcessMonitorDockPanel();
void setDefaultToolbarVisibility();
void applyFontSizesToDockedPlots();
protected:
void closeEvent(QCloseEvent* event) override;
void closeEvent( QCloseEvent* event ) override;
private:
void createActions();
void createMenus();
void createToolBars();
void createDockPanels();
void createActions();
void createMenus();
void createToolBars();
void createDockPanels();
void restoreTreeViewState();
void restoreTreeViewState();
void updateUiFieldsFromActiveResult(caf::PdmObjectHandle* objectToUpdate);
void updateUiFieldsFromActiveResult( caf::PdmObjectHandle* objectToUpdate );
private:
// Edit actions
QAction* m_newPropertyView;
QAction* m_newPropertyView;
// View actions
QAction* m_viewFromNorth;
QAction* m_viewFromSouth;
QAction* m_viewFromEast;
QAction* m_viewFromWest;
QAction* m_viewFromAbove;
QAction* m_viewFromBelow;
QAction* m_viewFromNorth;
QAction* m_viewFromSouth;
QAction* m_viewFromEast;
QAction* m_viewFromWest;
QAction* m_viewFromAbove;
QAction* m_viewFromBelow;
// Mock actions
QAction* m_mockModelAction;
QAction* m_mockResultsModelAction;
QAction* m_mockLargeResultsModelAction;
QAction* m_mockModelCustomizedAction;
QAction* m_mockInputModelAction;
QAction* m_mockModelAction;
QAction* m_mockResultsModelAction;
QAction* m_mockLargeResultsModelAction;
QAction* m_mockModelCustomizedAction;
QAction* m_mockInputModelAction;
QAction* m_snapshotAllViewsToFile;
QAction* m_snapshotAllViewsToFile;
QAction* m_createCommandObject;
QAction* m_showRegressionTestDialog;
QAction* m_executePaintEventPerformanceTest;
QAction* m_createCommandObject;
QAction* m_showRegressionTestDialog;
QAction* m_executePaintEventPerformanceTest;
caf::AnimationToolBar* m_animationToolBar;
RiuMdiArea* m_mdiArea;
RiuResultInfoPanel* m_resultInfoPanel;
RiuProcessMonitor* m_processMonitor;
QPointer<RiuMessagePanel> m_messagePanel;
RiuResultQwtPlot* m_resultQwtPlot;
RiuMohrsCirclePlot* m_mohrsCirclePlot;
RiuRelativePermeabilityPlotPanel* m_relPermPlotPanel;
RiuPvtPlotPanel* m_pvtPlotPanel;
RiuMdiArea* m_mdiArea;
RiuResultInfoPanel* m_resultInfoPanel;
RiuProcessMonitor* m_processMonitor;
QPointer<RiuMessagePanel> m_messagePanel;
QMenu* m_windowMenu;
QLabel* m_memoryCriticalWarning;
QToolButton* m_memoryUsedButton;
QLabel* m_memoryTotalStatus;
QTimer* m_memoryRefreshTimer;
RiuResultQwtPlot* m_resultQwtPlot;
RiuMohrsCirclePlot* m_mohrsCirclePlot;
RiuRelativePermeabilityPlotPanel* m_relPermPlotPanel;
RiuPvtPlotPanel* m_pvtPlotPanel;
// Menu and action slots
QMenu* m_windowMenu;
QLabel* m_memoryCriticalWarning;
QToolButton* m_memoryUsedButton;
QLabel* m_memoryTotalStatus;
QTimer* m_memoryRefreshTimer;
// Menu and action slots
private slots:
friend class RiuMdiSubWindow;
// Memory update slot
void updateMemoryUsage();
void updateMemoryUsage();
// File slots
void slotRefreshFileActions();
void slotRefreshFileActions();
// Edit slots
void slotRefreshEditActions();
void slotNewObjectPropertyView();
void slotRefreshEditActions();
void slotNewObjectPropertyView();
// View slots
void slotRefreshViewActions();
void slotViewFromNorth();
void slotViewFromSouth();
void slotViewFromEast();
void slotViewFromWest();
void slotViewFromAbove();
void slotViewFromBelow();
void slotScaleChanged(int scaleValue);
void slotRefreshViewActions();
void slotViewFromNorth();
void slotViewFromSouth();
void slotViewFromEast();
void slotViewFromWest();
void slotViewFromAbove();
void slotViewFromBelow();
void slotScaleChanged( int scaleValue );
void slotDrawStyleChanged(QAction* activatedAction);
void slotToggleHideGridCellsAction(bool);
void slotToggleFaultLabelsAction(bool);
void slotDisableLightingAction(bool);
void slotDrawStyleChanged( QAction* activatedAction );
void slotToggleHideGridCellsAction( bool );
void slotToggleFaultLabelsAction( bool );
void slotDisableLightingAction( bool );
void slotShowWellCellsAction(bool doAdd);
void slotShowWellCellsAction( bool doAdd );
// Debug slots
void slotSnapshotAllViewsToFile();
void slotSnapshotAllViewsToFile();
void slotCreateCommandObject();
void slotCreateCommandObject();
void slotShowRegressionTestDialog();
void slotExecutePaintEventPerformanceTest();
void slotShowRegressionTestDialog();
void slotExecutePaintEventPerformanceTest();
// Mock models
void slotMockModel();
void slotMockResultsModel();
void slotMockLargeResultsModel();
void slotMockModelCustomized();
void slotInputMockModel();
void slotMockModel();
void slotMockResultsModel();
void slotMockLargeResultsModel();
void slotMockModelCustomized();
void slotInputMockModel();
// Windows slots
void slotBuildWindowActions();
void slotBuildWindowActions();
void slotSubWindowActivated(QMdiSubWindow* subWindow);
void slotSubWindowActivated( QMdiSubWindow* subWindow );
void selectedObjectsChanged();
void customMenuRequested(const QPoint& pos);
void selectedObjectsChanged();
void customMenuRequested( const QPoint& pos );
// Pdm System :
public:
void setPdmRoot(caf::PdmObject* pdmRoot);
void setPdmRoot( caf::PdmObject* pdmRoot );
private:
std::unique_ptr<caf::PdmUiDragDropInterface> m_dragDropInterface;
QUndoView* m_undoView;
caf::PdmObject* m_pdmRoot;
caf::PdmUiPropertyView* m_pdmUiPropertyView;
QUndoView* m_undoView;
QSpinBox* m_scaleFactor;
caf::PdmObject* m_pdmRoot;
caf::PdmUiPropertyView* m_pdmUiPropertyView;
QActionGroup* m_dsActionGroup;
QAction* m_disableLightingAction;
QAction* m_drawStyleHideGridCellsAction;
QAction* m_toggleFaultsLabelAction;
QAction* m_drawStyleLinesAction;
QAction* m_drawStyleLinesSolidAction;
QAction* m_drawStyleFaultLinesSolidAction;
QAction* m_drawStyleSurfOnlyAction;
QAction* m_showWellCellsAction;
QSpinBox* m_scaleFactor;
QToolBar* m_holoLensToolBar;
QActionGroup* m_dsActionGroup;
QAction* m_disableLightingAction;
QAction* m_drawStyleHideGridCellsAction;
QAction* m_toggleFaultsLabelAction;
QAction* m_drawStyleLinesAction;
QAction* m_drawStyleLinesSolidAction;
QAction* m_drawStyleFaultLinesSolidAction;
QAction* m_drawStyleSurfOnlyAction;
QAction* m_showWellCellsAction;
std::vector<QPointer<QDockWidget> > m_additionalProjectViews;
QToolBar* m_holoLensToolBar;
std::vector<QPointer<QDockWidget>> m_additionalProjectViews;
};

View File

@@ -39,21 +39,21 @@
///
//--------------------------------------------------------------------------------------------------
RiuMainWindowBase::RiuMainWindowBase()
: m_projectTreeView(nullptr)
, m_allowActiveViewChangeFromSelection(true)
, m_showFirstVisibleWindowMaximized(true)
, m_blockSlotSubWindowActivated(false)
: m_projectTreeView( nullptr )
, m_allowActiveViewChangeFromSelection( true )
, m_showFirstVisibleWindowMaximized( true )
, m_blockSlotSubWindowActivated( false )
{
setDockNestingEnabled(true);
setDockNestingEnabled( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMdiWindowGeometry RiuMainWindowBase::windowGeometryForViewer(QWidget* viewer)
RimMdiWindowGeometry RiuMainWindowBase::windowGeometryForViewer( QWidget* viewer )
{
RiuMdiSubWindow* mdiWindow = dynamic_cast<RiuMdiSubWindow*>(findMdiSubWindow(viewer));
if (mdiWindow)
RiuMdiSubWindow* mdiWindow = dynamic_cast<RiuMdiSubWindow*>( findMdiSubWindow( viewer ) );
if ( mdiWindow )
{
return mdiWindow->windowGeometry();
}
@@ -70,16 +70,16 @@ void RiuMainWindowBase::loadWinGeoAndDockToolBarLayout()
// Company and appname set through QCoreApplication
QSettings settings;
QVariant winGeo = settings.value(QString("%1/winGeometry").arg(registryFolderName()));
QVariant layout = settings.value(QString("%1/dockAndToolBarLayout").arg(registryFolderName()));
QVariant winGeo = settings.value( QString( "%1/winGeometry" ).arg( registryFolderName() ) );
QVariant layout = settings.value( QString( "%1/dockAndToolBarLayout" ).arg( registryFolderName() ) );
if (winGeo.isValid())
if ( winGeo.isValid() )
{
if (restoreGeometry(winGeo.toByteArray()))
if ( restoreGeometry( winGeo.toByteArray() ) )
{
if (layout.isValid())
if ( layout.isValid() )
{
restoreState(layout.toByteArray(), 0);
restoreState( layout.toByteArray(), 0 );
}
}
}
@@ -90,7 +90,7 @@ void RiuMainWindowBase::loadWinGeoAndDockToolBarLayout()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString mainWindowDockWidgetSettingsKey(const QString& settingsFolderName)
QString mainWindowDockWidgetSettingsKey( const QString& settingsFolderName )
{
QString key = settingsFolderName + "/dockWindowVisibilies";
@@ -106,19 +106,19 @@ void RiuMainWindowBase::saveWinGeoAndDockToolBarLayout()
QSettings settings;
QByteArray winGeo = saveGeometry();
settings.setValue(QString("%1/winGeometry").arg(registryFolderName()), winGeo);
settings.setValue( QString( "%1/winGeometry" ).arg( registryFolderName() ), winGeo );
QByteArray layout = saveState(0);
settings.setValue(QString("%1/dockAndToolBarLayout").arg(registryFolderName()), layout);
QByteArray layout = saveState( 0 );
settings.setValue( QString( "%1/dockAndToolBarLayout" ).arg( registryFolderName() ), layout );
settings.setValue(QString("%1/isMaximized").arg(registryFolderName()), isMaximized());
settings.setValue( QString( "%1/isMaximized" ).arg( registryFolderName() ), isMaximized() );
if (this->isVisible())
if ( this->isVisible() )
{
QVariant dockWindowVisibilities = RiuDockWidgetTools::dockWidgetsVisibility(this);
QString key = mainWindowDockWidgetSettingsKey(registryFolderName());
QVariant dockWindowVisibilities = RiuDockWidgetTools::dockWidgetsVisibility( this );
QString key = mainWindowDockWidgetSettingsKey( registryFolderName() );
settings.setValue(key, dockWindowVisibilities);
settings.setValue( key, dockWindowVisibilities );
}
}
@@ -129,12 +129,12 @@ void RiuMainWindowBase::storeDefaultDockWidgetVisibilitiesIfRequired()
{
QSettings settings;
QString key = mainWindowDockWidgetSettingsKey(registryFolderName());
QString key = mainWindowDockWidgetSettingsKey( registryFolderName() );
if (!settings.contains(key))
if ( !settings.contains( key ) )
{
QVariant dockWidgetVisibilities = RiuDockWidgetTools::defaultDockWidgetVisibilities();
settings.setValue(key, dockWidgetVisibilities);
settings.setValue( key, dockWidgetVisibilities );
}
}
@@ -146,10 +146,10 @@ void RiuMainWindowBase::restoreDockWidgetVisibilities()
// Company and appname set through QCoreApplication
QSettings settings;
QString key = mainWindowDockWidgetSettingsKey(registryFolderName());
QString key = mainWindowDockWidgetSettingsKey( registryFolderName() );
QVariant dockWindowVisibilities = settings.value(key);
RiuDockWidgetTools::applyDockWidgetVisibilities(this, dockWindowVisibilities.toMap());
QVariant dockWindowVisibilities = settings.value( key );
RiuDockWidgetTools::applyDockWidgetVisibilities( this, dockWindowVisibilities.toMap() );
}
//--------------------------------------------------------------------------------------------------
@@ -162,8 +162,8 @@ void RiuMainWindowBase::showWindow()
showNormal();
QVariant isMax = settings.value(QString("%1/isMaximized").arg(registryFolderName()), false);
if (isMax.toBool())
QVariant isMax = settings.value( QString( "%1/isMaximized" ).arg( registryFolderName() ), false );
if ( isMax.toBool() )
{
showMaximized();
}
@@ -176,9 +176,9 @@ void RiuMainWindowBase::hideAllDockWidgets()
{
QList<QDockWidget*> dockWidgets = findChildren<QDockWidget*>();
for (QDockWidget* dock : dockWidgets)
for ( QDockWidget* dock : dockWidgets )
{
if (dock)
if ( dock )
{
dock->hide();
}
@@ -190,25 +190,25 @@ void RiuMainWindowBase::hideAllDockWidgets()
//--------------------------------------------------------------------------------------------------
QString RiuMainWindowBase::registryFolderName()
{
QString versionName(STRPRODUCTVER);
QString regFolder = QString("%1_Qt%2/%3").arg(versionName).arg(QT_VERSION_STR).arg(mainWindowName());
QString versionName( STRPRODUCTVER );
QString regFolder = QString( "%1_Qt%2/%3" ).arg( versionName ).arg( QT_VERSION_STR ).arg( mainWindowName() );
return regFolder;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange)
void RiuMainWindowBase::selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange )
{
m_allowActiveViewChangeFromSelection = allowActiveViewChange;
m_projectTreeView->selectAsCurrentItem(object);
m_projectTreeView->selectAsCurrentItem( object );
m_allowActiveViewChangeFromSelection = true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::enableShowFirstVisibleMdiWindowMaximized(bool enable)
void RiuMainWindowBase::enableShowFirstVisibleMdiWindowMaximized( bool enable )
{
m_showFirstVisibleWindowMaximized = enable;
}
@@ -216,7 +216,7 @@ void RiuMainWindowBase::enableShowFirstVisibleMdiWindowMaximized(bool enable)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::setBlockSlotSubWindowActivated(bool block)
void RiuMainWindowBase::setBlockSlotSubWindowActivated( bool block )
{
m_blockSlotSubWindowActivated = block;
}
@@ -232,35 +232,35 @@ bool RiuMainWindowBase::blockSlotSubWindowActivated() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::removeViewerFromMdiArea(QMdiArea* mdiArea, QWidget* viewer)
void RiuMainWindowBase::removeViewerFromMdiArea( QMdiArea* mdiArea, QWidget* viewer )
{
bool wasMaximized = viewer && viewer->isMaximized();
QMdiSubWindow* subWindowBeingClosed = findMdiSubWindow(viewer);
QMdiSubWindow* subWindowBeingClosed = findMdiSubWindow( viewer );
bool removedSubWindowWasActive = false;
if (subWindowBeingClosed->isActiveWindow())
if ( subWindowBeingClosed->isActiveWindow() )
{
// If we are removing the active window, we will need a new active window
// Start by making the window inactive so Qt doesn't pick the active window itself
mdiArea->setActiveSubWindow(nullptr);
mdiArea->setActiveSubWindow( nullptr );
removedSubWindowWasActive = true;
}
mdiArea->removeSubWindow(subWindowBeingClosed);
mdiArea->removeSubWindow( subWindowBeingClosed );
QList<QMdiSubWindow*> subWindowList = mdiArea->subWindowList(QMdiArea::ActivationHistoryOrder);
if (!subWindowList.empty())
QList<QMdiSubWindow*> subWindowList = mdiArea->subWindowList( QMdiArea::ActivationHistoryOrder );
if ( !subWindowList.empty() )
{
if (removedSubWindowWasActive)
if ( removedSubWindowWasActive )
{
mdiArea->setActiveSubWindow(nullptr);
mdiArea->setActiveSubWindow( nullptr );
// Make the last activated window the current activated one
mdiArea->setActiveSubWindow(subWindowList.back());
mdiArea->setActiveSubWindow( subWindowList.back() );
}
if (wasMaximized && mdiArea->currentSubWindow())
if ( wasMaximized && mdiArea->currentSubWindow() )
{
mdiArea->currentSubWindow()->showMaximized();
}
else if (subWindowsAreTiled())
else if ( subWindowsAreTiled() )
{
tileSubWindows();
}
@@ -270,9 +270,9 @@ void RiuMainWindowBase::removeViewerFromMdiArea(QMdiArea* mdiArea, QWidget* view
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::setExpanded(const caf::PdmUiItem* uiItem, bool expanded)
void RiuMainWindowBase::setExpanded( const caf::PdmUiItem* uiItem, bool expanded )
{
m_projectTreeView->setExpanded(uiItem, expanded);
m_projectTreeView->setExpanded( uiItem, expanded );
}
//--------------------------------------------------------------------------------------------------
@@ -281,12 +281,12 @@ void RiuMainWindowBase::setExpanded(const caf::PdmUiItem* uiItem, bool expanded)
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::slotDockWidgetToggleViewActionTriggered()
{
if (!sender()) return;
if ( !sender() ) return;
auto dockWidget = dynamic_cast<QDockWidget*>(sender()->parent());
if (dockWidget)
auto dockWidget = dynamic_cast<QDockWidget*>( sender()->parent() );
if ( dockWidget )
{
if (dockWidget->isVisible())
if ( dockWidget->isVisible() )
{
// Raise the dock widget to make it visible if the widget is part of a tab widget
dockWidget->raise();
@@ -297,46 +297,48 @@ void RiuMainWindowBase::slotDockWidgetToggleViewActionTriggered()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::addViewerToMdiArea(QMdiArea* mdiArea,
QWidget* viewer,
const QPoint& subWindowPos,
const QSize& subWindowSize)
void RiuMainWindowBase::addViewerToMdiArea( QMdiArea* mdiArea,
QWidget* viewer,
const QPoint& subWindowPos,
const QSize& subWindowSize )
{
RiuMdiSubWindow* subWin =
new RiuMdiSubWindow(nullptr, Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | Qt::WindowMaximizeButtonHint);
subWin->setAttribute(Qt::WA_DeleteOnClose); // Make sure the contained widget is destroyed when the MDI window is closed
subWin->setWidget(viewer);
RiuMdiSubWindow* subWin = new RiuMdiSubWindow( nullptr,
Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint |
Qt::WindowMaximizeButtonHint );
subWin->setAttribute(
Qt::WA_DeleteOnClose ); // Make sure the contained widget is destroyed when the MDI window is closed
subWin->setWidget( viewer );
bool initialStateTiled = subWindowsAreTiled();
bool initialStateMaximized = false;
if (m_showFirstVisibleWindowMaximized && mdiArea->subWindowList().empty())
if ( m_showFirstVisibleWindowMaximized && mdiArea->subWindowList().empty() )
{
// Show first 3D view maximized
initialStateMaximized = true;
}
if (mdiArea->currentSubWindow() && mdiArea->currentSubWindow()->isMaximized())
if ( mdiArea->currentSubWindow() && mdiArea->currentSubWindow()->isMaximized() )
{
initialStateMaximized = true;
}
mdiArea->addSubWindow(subWin);
mdiArea->addSubWindow( subWin );
if (subWindowPos.x() > -1)
if ( subWindowPos.x() > -1 )
{
subWin->move(subWindowPos);
subWin->move( subWindowPos );
}
subWin->resize(subWindowSize);
subWin->resize( subWindowSize );
if (initialStateMaximized)
if ( initialStateMaximized )
{
subWin->showMaximized();
}
else
{
subWin->showNormal();
if (initialStateTiled)
if ( initialStateTiled )
{
tileSubWindows();
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -25,18 +25,16 @@ struct RimMdiWindowGeometry;
namespace caf
{
class PdmObject;
class PdmUiTreeView;
class PdmUiItem;
}
class PdmObject;
class PdmUiTreeView;
class PdmUiItem;
} // namespace caf
class QMdiArea;
class QMdiSubWindow;
//==================================================================================================
///
///
//==================================================================================================
class RiuMainWindowBase : public QMainWindow
{
@@ -45,54 +43,56 @@ class RiuMainWindowBase : public QMainWindow
public:
RiuMainWindowBase();
virtual QString mainWindowName() = 0;
virtual QString mainWindowName() = 0;
virtual void removeViewer( QWidget* viewer ) = 0;
virtual void addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry)= 0;
virtual void setActiveViewer(QWidget* subWindow) = 0;
virtual void removeViewer( QWidget* viewer ) = 0;
virtual void addViewer( QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry ) = 0;
virtual void setActiveViewer( QWidget* subWindow ) = 0;
virtual QMdiSubWindow* findMdiSubWindow(QWidget* viewer) = 0;
virtual QMdiSubWindow* findMdiSubWindow( QWidget* viewer ) = 0;
RimMdiWindowGeometry windowGeometryForViewer(QWidget* viewer);
void loadWinGeoAndDockToolBarLayout();
void saveWinGeoAndDockToolBarLayout();
void storeDefaultDockWidgetVisibilitiesIfRequired();
void restoreDockWidgetVisibilities();
void showWindow();
RimMdiWindowGeometry windowGeometryForViewer( QWidget* viewer );
void loadWinGeoAndDockToolBarLayout();
void saveWinGeoAndDockToolBarLayout();
void storeDefaultDockWidgetVisibilitiesIfRequired();
void restoreDockWidgetVisibilities();
void showWindow();
void hideAllDockWidgets();
void hideAllDockWidgets();
caf::PdmUiTreeView* projectTreeView() { return m_projectTreeView;}
void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true);
caf::PdmUiTreeView* projectTreeView()
{
return m_projectTreeView;
}
void setExpanded( const caf::PdmUiItem* uiItem, bool expanded = true );
void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true);
void enableShowFirstVisibleMdiWindowMaximized(bool enable);
virtual void tileSubWindows() = 0;
virtual void storeSubWindowTiling(bool tiled) = 0;
virtual void clearWindowTiling() = 0;
virtual bool subWindowsAreTiled() const = 0;
void selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange = true );
void setBlockSlotSubWindowActivated(bool block);
bool blockSlotSubWindowActivated() const;
void enableShowFirstVisibleMdiWindowMaximized( bool enable );
virtual void tileSubWindows() = 0;
virtual void storeSubWindowTiling( bool tiled ) = 0;
virtual void clearWindowTiling() = 0;
virtual bool subWindowsAreTiled() const = 0;
void setBlockSlotSubWindowActivated( bool block );
bool blockSlotSubWindowActivated() const;
protected:
void removeViewerFromMdiArea(QMdiArea* mdiArea, QWidget* viewer);
void removeViewerFromMdiArea( QMdiArea* mdiArea, QWidget* viewer );
protected slots:
void slotDockWidgetToggleViewActionTriggered();
void addViewerToMdiArea(QMdiArea* mdiArea, QWidget* viewer, const QPoint& subWindowPos, const QSize& subWindowSize);
void slotDockWidgetToggleViewActionTriggered();
void addViewerToMdiArea( QMdiArea* mdiArea, QWidget* viewer, const QPoint& subWindowPos, const QSize& subWindowSize );
protected:
caf::PdmUiTreeView* m_projectTreeView;
bool m_allowActiveViewChangeFromSelection; // To be used in selectedObjectsChanged() to control
// whether to select the corresponding active view or not
bool m_allowActiveViewChangeFromSelection; // To be used in selectedObjectsChanged() to control
// whether to select the corresponding active view or not
private:
QString registryFolderName();
QString registryFolderName();
private:
bool m_showFirstVisibleWindowMaximized;
bool m_blockSlotSubWindowActivated;
bool m_showFirstVisibleWindowMaximized;
bool m_blockSlotSubWindowActivated;
};

View File

@@ -26,15 +26,14 @@
#include "cafPdmUiTreeOrdering.h"
#include "cafPdmUiTreeView.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowTools::collapseSiblings(const caf::PdmUiItem* sourceUiItem)
void RiuMainWindowTools::collapseSiblings( const caf::PdmUiItem* sourceUiItem )
{
if (!sourceUiItem) return;
if ( !sourceUiItem ) return;
if (!RiaGuiApplication::isRunning()) return;
if ( !RiaGuiApplication::isRunning() ) return;
{
caf::PdmUiTreeView* sourceTreeView = nullptr;
@@ -43,41 +42,41 @@ void RiuMainWindowTools::collapseSiblings(const caf::PdmUiItem* sourceUiItem)
{
QModelIndex modIndex;
if (RiuMainWindow::instance())
if ( RiuMainWindow::instance() )
{
modIndex = RiuMainWindow::instance()->projectTreeView()->findModelIndex(sourceUiItem);
modIndex = RiuMainWindow::instance()->projectTreeView()->findModelIndex( sourceUiItem );
}
if (modIndex.isValid())
if ( modIndex.isValid() )
{
sourceTreeView = RiuMainWindow::instance()->projectTreeView();
}
else
{
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
if (mpw)
if ( mpw )
{
modIndex = mpw->projectTreeView()->findModelIndex(sourceUiItem);
if (modIndex.isValid())
modIndex = mpw->projectTreeView()->findModelIndex( sourceUiItem );
if ( modIndex.isValid() )
{
sourceTreeView = mpw->projectTreeView();
}
}
}
if (!modIndex.isValid()) return;
if ( !modIndex.isValid() ) return;
sourceTreeOrderingItem = static_cast<caf::PdmUiTreeOrdering*>(modIndex.internalPointer());
sourceTreeOrderingItem = static_cast<caf::PdmUiTreeOrdering*>( modIndex.internalPointer() );
}
if (sourceTreeView && sourceTreeOrderingItem && sourceTreeOrderingItem->parent())
if ( sourceTreeView && sourceTreeOrderingItem && sourceTreeOrderingItem->parent() )
{
for (int i = 0; i < sourceTreeOrderingItem->parent()->childCount(); i++)
for ( int i = 0; i < sourceTreeOrderingItem->parent()->childCount(); i++ )
{
auto siblingTreeOrderingItem = sourceTreeOrderingItem->parent()->child(i);
if (siblingTreeOrderingItem != sourceTreeOrderingItem)
auto siblingTreeOrderingItem = sourceTreeOrderingItem->parent()->child( i );
if ( siblingTreeOrderingItem != sourceTreeOrderingItem )
{
sourceTreeView->setExpanded(siblingTreeOrderingItem->activeItem(), false);
sourceTreeView->setExpanded( siblingTreeOrderingItem->activeItem(), false );
}
}
}

View File

@@ -26,5 +26,5 @@ class PdmUiItem;
class RiuMainWindowTools
{
public:
static void collapseSiblings(const caf::PdmUiItem* uiItem);
static void collapseSiblings( const caf::PdmUiItem* uiItem );
};

View File

@@ -18,8 +18,8 @@
#include "RiuMdiArea.h"
#include "RiuMainWindow.h"
#include "RiuPlotMainWindow.h"
#include "RiuMdiSubWindow.h"
#include "RiuPlotMainWindow.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -27,80 +27,80 @@ std::list<QMdiSubWindow*> RiuMdiArea::subWindowListSortedByPosition()
{
// Tile Windows so the one with the leftmost left edge gets sorted first.
std::list<QMdiSubWindow*> windowList;
for (QMdiSubWindow* subWindow : subWindowList(QMdiArea::CreationOrder))
for ( QMdiSubWindow* subWindow : subWindowList( QMdiArea::CreationOrder ) )
{
windowList.push_back(subWindow);
windowList.push_back( subWindow );
}
// Sort of list so we first sort by window position but retain activation order
// for windows with the same position
windowList.sort([this](QMdiSubWindow* lhs, QMdiSubWindow* rhs) {
if (lhs->frameGeometry().topLeft().rx() == rhs->frameGeometry().topLeft().rx())
windowList.sort( [this]( QMdiSubWindow* lhs, QMdiSubWindow* rhs ) {
if ( lhs->frameGeometry().topLeft().rx() == rhs->frameGeometry().topLeft().rx() )
{
return lhs->frameGeometry().topLeft().ry() < rhs->frameGeometry().topLeft().ry();
}
return lhs->frameGeometry().topLeft().rx() < rhs->frameGeometry().topLeft().rx();
});
} );
return windowList;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMdiArea::resizeEvent(QResizeEvent* resizeEvent)
void RiuMdiArea::resizeEvent( QResizeEvent* resizeEvent )
{
if (subWindowsAreTiled())
if ( subWindowsAreTiled() )
{
for (auto subWindow : subWindowList())
for ( auto subWindow : subWindowList() )
{
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>(subWindow);
riuWindow->blockTilingChanges(true);
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>( subWindow );
riuWindow->blockTilingChanges( true );
}
RiuMainWindowBase* mainWindow = dynamic_cast<RiuMainWindowBase*>(window());
mainWindow->setBlockSlotSubWindowActivated(true);
RiuMainWindowBase* mainWindow = dynamic_cast<RiuMainWindowBase*>( window() );
mainWindow->setBlockSlotSubWindowActivated( true );
// Workaround for Qt bug #51761: https://bugreports.qt.io/browse/QTBUG-51761
// Set the first window to be the active window then perform resize event and set back.
auto a = activeSubWindow();
setActiveSubWindow(subWindowListSortedByPosition().front());
setActiveSubWindow( subWindowListSortedByPosition().front() );
QMdiArea::resizeEvent(resizeEvent);
QMdiArea::resizeEvent( resizeEvent );
tileSubWindows();
setActiveSubWindow(a);
setActiveSubWindow( a );
mainWindow->setBlockSlotSubWindowActivated(false);
mainWindow->setBlockSlotSubWindowActivated( false );
for (auto subWindow : subWindowList())
for ( auto subWindow : subWindowList() )
{
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>(subWindow);
riuWindow->blockTilingChanges(false);
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>( subWindow );
riuWindow->blockTilingChanges( false );
}
}
else
{
QMdiArea::resizeEvent(resizeEvent);
QMdiArea::resizeEvent( resizeEvent );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMdiArea::moveEvent(QMoveEvent* event)
void RiuMdiArea::moveEvent( QMoveEvent* event )
{
for (auto subWindow : subWindowList())
for ( auto subWindow : subWindowList() )
{
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>(subWindow);
riuWindow->blockTilingChanges(true);
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>( subWindow );
riuWindow->blockTilingChanges( true );
}
QMdiArea::moveEvent(event);
QMdiArea::moveEvent( event );
for (auto subWindow : subWindowList())
for ( auto subWindow : subWindowList() )
{
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>(subWindow);
riuWindow->blockTilingChanges(false);
auto riuWindow = dynamic_cast<RiuMdiSubWindow*>( subWindow );
riuWindow->blockTilingChanges( false );
}
}
@@ -109,16 +109,16 @@ void RiuMdiArea::moveEvent(QMoveEvent* event)
//--------------------------------------------------------------------------------------------------
bool RiuMdiArea::subWindowsAreTiled() const
{
RiuMainWindow* mainWindow = dynamic_cast<RiuMainWindow*>(window());
RiuMainWindow* mainWindow = dynamic_cast<RiuMainWindow*>( window() );
if (mainWindow)
if ( mainWindow )
{
return mainWindow->subWindowsAreTiled() && subWindowList().size() > 0;
}
else
{
RiuPlotMainWindow* plotWindow = dynamic_cast<RiuPlotMainWindow*>(window());
if (plotWindow)
RiuPlotMainWindow* plotWindow = dynamic_cast<RiuPlotMainWindow*>( window() );
if ( plotWindow )
{
return plotWindow->subWindowsAreTiled() && subWindowList().size() > 0;
}

View File

@@ -32,8 +32,8 @@ public:
std::list<QMdiSubWindow*> subWindowListSortedByPosition();
protected:
void resizeEvent(QResizeEvent *resizeEvent) override;
void moveEvent(QMoveEvent *event) override;
void resizeEvent( QResizeEvent* resizeEvent ) override;
void moveEvent( QMoveEvent* event ) override;
bool subWindowsAreTiled() const;
};

View File

@@ -11,17 +11,17 @@ RiuMdiMaximizeWindowGuard::RiuMdiMaximizeWindowGuard()
{
{
RiuMainWindow* mainWindow = RiaGuiApplication::instance()->mainWindow();
if (mainWindow)
if ( mainWindow )
{
mainWindow->enableShowFirstVisibleMdiWindowMaximized(false);
mainWindow->enableShowFirstVisibleMdiWindowMaximized( false );
}
}
{
RiuPlotMainWindow* plotMainWindow = RiaGuiApplication::instance()->mainPlotWindow();
if (plotMainWindow)
if ( plotMainWindow )
{
plotMainWindow->enableShowFirstVisibleMdiWindowMaximized(false);
plotMainWindow->enableShowFirstVisibleMdiWindowMaximized( false );
}
}
}
@@ -33,17 +33,17 @@ RiuMdiMaximizeWindowGuard::~RiuMdiMaximizeWindowGuard()
{
{
RiuMainWindow* mainWindow = RiaGuiApplication::instance()->mainWindow();
if (mainWindow)
if ( mainWindow )
{
mainWindow->enableShowFirstVisibleMdiWindowMaximized(true);
mainWindow->enableShowFirstVisibleMdiWindowMaximized( true );
}
}
{
RiuPlotMainWindow* plotMainWindow = RiaGuiApplication::instance()->mainPlotWindow();
if (plotMainWindow)
if ( plotMainWindow )
{
plotMainWindow->enableShowFirstVisibleMdiWindowMaximized(true);
plotMainWindow->enableShowFirstVisibleMdiWindowMaximized( true );
}
}
}

View File

@@ -28,5 +28,3 @@ public:
RiuMdiMaximizeWindowGuard();
~RiuMdiMaximizeWindowGuard();
};

View File

@@ -36,12 +36,12 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMdiSubWindow::RiuMdiSubWindow(QWidget* parent /*= 0*/, Qt::WindowFlags flags /*= 0*/)
: QMdiSubWindow(parent, flags)
, m_normalWindowGeometry(QRect())
, m_blockTilingChanges(false)
RiuMdiSubWindow::RiuMdiSubWindow( QWidget* parent /*= 0*/, Qt::WindowFlags flags /*= 0*/ )
: QMdiSubWindow( parent, flags )
, m_normalWindowGeometry( QRect() )
, m_blockTilingChanges( false )
{
setWindowIcon(QIcon(":/Window16x16.png"));
setWindowIcon( QIcon( ":/Window16x16.png" ) );
}
//--------------------------------------------------------------------------------------------------
@@ -60,7 +60,7 @@ RimMdiWindowGeometry RiuMdiSubWindow::windowGeometry() const
RimMdiWindowGeometry geo;
int mainWinID = 0;
if (window() == RiaGuiApplication::instance()->mainPlotWindow())
if ( window() == RiaGuiApplication::instance()->mainPlotWindow() )
{
mainWinID = 1;
}
@@ -70,7 +70,7 @@ RimMdiWindowGeometry RiuMdiSubWindow::windowGeometry() const
// Save normal/non-maximized size and position so this can be restored
QRect currentGeometry = frameGeometry();
if (isMaximized() && !m_normalWindowGeometry.isNull())
if ( isMaximized() && !m_normalWindowGeometry.isNull() )
{
currentGeometry = m_normalWindowGeometry;
}
@@ -83,11 +83,10 @@ RimMdiWindowGeometry RiuMdiSubWindow::windowGeometry() const
return geo;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMdiSubWindow::blockTilingChanges(bool block)
void RiuMdiSubWindow::blockTilingChanges( bool block )
{
m_blockTilingChanges = block;
}
@@ -95,78 +94,78 @@ void RiuMdiSubWindow::blockTilingChanges(bool block)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMdiSubWindow::closeEvent(QCloseEvent* event)
void RiuMdiSubWindow::closeEvent( QCloseEvent* event )
{
QWidget* mainWidget = widget();
RimViewWindow* viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget(mainWidget);
if (!viewWindow)
RimViewWindow* viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget( mainWidget );
if ( !viewWindow )
{
RiuViewer* viewer = mainWidget->findChild<RiuViewer*>();
if (viewer)
if ( viewer )
{
viewWindow = viewer->ownerViewWindow();
}
}
if (viewWindow)
if ( viewWindow )
{
viewWindow->setMdiWindowGeometry(windowGeometry());
viewWindow->setMdiWindowGeometry( windowGeometry() );
viewWindow->handleMdiWindowClosed();
event->accept();
}
else
{
QMdiSubWindow::closeEvent(event);
QMdiSubWindow::closeEvent( event );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMdiSubWindow::resizeEvent(QResizeEvent* resizeEvent)
void RiuMdiSubWindow::resizeEvent( QResizeEvent* resizeEvent )
{
if (!isMaximized())
if ( !isMaximized() )
{
m_normalWindowGeometry = frameGeometry();
}
if (!m_blockTilingChanges)
if ( !m_blockTilingChanges )
{
if (window() == RiaGuiApplication::instance()->mainWindow())
if ( window() == RiaGuiApplication::instance()->mainWindow() )
{
RiaGuiApplication::instance()->mainWindow()->storeSubWindowTiling(false);
RiaGuiApplication::instance()->mainWindow()->storeSubWindowTiling( false );
}
else if (window() == RiaGuiApplication::instance()->mainPlotWindow())
else if ( window() == RiaGuiApplication::instance()->mainPlotWindow() )
{
RiaGuiApplication::instance()->mainPlotWindow()->storeSubWindowTiling(false);
RiaGuiApplication::instance()->mainPlotWindow()->storeSubWindowTiling( false );
}
}
QMdiSubWindow::resizeEvent(resizeEvent);
QMdiSubWindow::resizeEvent( resizeEvent );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMdiSubWindow::moveEvent(QMoveEvent* moveEvent)
void RiuMdiSubWindow::moveEvent( QMoveEvent* moveEvent )
{
if (!isMaximized())
if ( !isMaximized() )
{
m_normalWindowGeometry = frameGeometry();
}
if (!m_blockTilingChanges)
if ( !m_blockTilingChanges )
{
if (window() == RiaGuiApplication::instance()->mainWindow())
if ( window() == RiaGuiApplication::instance()->mainWindow() )
{
RiaGuiApplication::instance()->mainWindow()->storeSubWindowTiling(false);
RiaGuiApplication::instance()->mainWindow()->storeSubWindowTiling( false );
}
else if (window() == RiaGuiApplication::instance()->mainPlotWindow())
else if ( window() == RiaGuiApplication::instance()->mainPlotWindow() )
{
RiaGuiApplication::instance()->mainPlotWindow()->storeSubWindowTiling(false);
RiaGuiApplication::instance()->mainPlotWindow()->storeSubWindowTiling( false );
}
}
QMdiSubWindow::moveEvent(moveEvent);
QMdiSubWindow::moveEvent( moveEvent );
}

View File

@@ -1,44 +1,44 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QMdiSubWindow>
#include "RimViewWindow.h"
#include <QMdiSubWindow>
class RiuMdiSubWindow : public QMdiSubWindow
{
Q_OBJECT
public:
RiuMdiSubWindow(QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr);
RiuMdiSubWindow( QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr );
~RiuMdiSubWindow() override;
RimMdiWindowGeometry windowGeometry() const;
void blockTilingChanges(bool block);
protected:
void closeEvent(QCloseEvent* event) override;
void resizeEvent(QResizeEvent* resizeEvent) override;
void moveEvent(QMoveEvent *moveEvent) override;
void blockTilingChanges( bool block );
private:
protected:
void closeEvent( QCloseEvent* event ) override;
void resizeEvent( QResizeEvent* resizeEvent ) override;
void moveEvent( QMoveEvent* moveEvent ) override;
private:
QRect m_normalWindowGeometry;
bool m_blockTilingChanges;
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -25,60 +25,62 @@
#include <QPlainTextEdit>
#include <QVBoxLayout>
//==================================================================================================
//
//
//
//
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuMessagePanel::RiuMessagePanel(QDockWidget* parent)
: QWidget(parent)
RiuMessagePanel::RiuMessagePanel( QDockWidget* parent )
: QWidget( parent )
{
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setMargin(0);
QVBoxLayout* layout = new QVBoxLayout( this );
layout->setMargin( 0 );
m_textEdit = new QPlainTextEdit;
m_textEdit->setReadOnly(true);
m_textEdit->setLineWrapMode(QPlainTextEdit::NoWrap);
m_textEdit->setContextMenuPolicy(Qt::CustomContextMenu);
m_textEdit->setReadOnly( true );
m_textEdit->setLineWrapMode( QPlainTextEdit::NoWrap );
m_textEdit->setContextMenuPolicy( Qt::CustomContextMenu );
connect(m_textEdit, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(slotShowContextMenu(const QPoint&)));
connect( m_textEdit,
SIGNAL( customContextMenuRequested( const QPoint& ) ),
SLOT( slotShowContextMenu( const QPoint& ) ) );
layout->addWidget(m_textEdit);
layout->addWidget( m_textEdit );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuMessagePanel::addMessage(RILogLevel messageLevel, const QString& msg)
void RiuMessagePanel::addMessage( RILogLevel messageLevel, const QString& msg )
{
QColor clr(Qt::black);
if (messageLevel == RI_LL_ERROR) clr = Qt::red;
else if (messageLevel == RI_LL_WARNING) clr = QColor(220,100,10);
else if (messageLevel == RI_LL_DEBUG) clr = QColor(100,100,200);
QColor clr( Qt::black );
if ( messageLevel == RI_LL_ERROR )
clr = Qt::red;
else if ( messageLevel == RI_LL_WARNING )
clr = QColor( 220, 100, 10 );
else if ( messageLevel == RI_LL_DEBUG )
clr = QColor( 100, 100, 200 );
QTextCharFormat form = m_textEdit->currentCharFormat();
form.setForeground(clr);
form.setFontWeight(messageLevel == RI_LL_ERROR ? QFont::DemiBold : QFont::Normal);
form.setFontItalic(messageLevel == RI_LL_DEBUG ? true : false);
m_textEdit->setCurrentCharFormat(form);
m_textEdit->appendPlainText(msg);
form.setForeground( clr );
form.setFontWeight( messageLevel == RI_LL_ERROR ? QFont::DemiBold : QFont::Normal );
form.setFontItalic( messageLevel == RI_LL_DEBUG ? true : false );
m_textEdit->setCurrentCharFormat( form );
m_textEdit->appendPlainText( msg );
m_textEdit->moveCursor(QTextCursor::End);
m_textEdit->moveCursor( QTextCursor::End );
m_textEdit->ensureCursorVisible();
if (!RiaRegressionTestRunner::instance()->isRunningRegressionTests())
if ( !RiaRegressionTestRunner::instance()->isRunningRegressionTests() )
{
if (messageLevel == RI_LL_ERROR || messageLevel == RI_LL_WARNING)
if ( messageLevel == RI_LL_ERROR || messageLevel == RI_LL_WARNING )
{
QDockWidget* parentDockWidget = dynamic_cast<QDockWidget*>(this->parent());
if (parentDockWidget && !parentDockWidget->isVisible())
QDockWidget* parentDockWidget = dynamic_cast<QDockWidget*>( this->parent() );
if ( parentDockWidget && !parentDockWidget->isVisible() )
{
parentDockWidget->toggleViewAction()->trigger();
}
@@ -86,137 +88,123 @@ void RiuMessagePanel::addMessage(RILogLevel messageLevel, const QString& msg)
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QSize RiuMessagePanel::sizeHint() const
{
return QSize(20, 20);
return QSize( 20, 20 );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuMessagePanel::slotShowContextMenu(const QPoint& pos)
void RiuMessagePanel::slotShowContextMenu( const QPoint& pos )
{
QMenu menu;
// Reworked from implemenmtation in QTextControl::createStandardContextMenu()
{
QAction* a = menu.addAction("&Copy", m_textEdit, SLOT(copy()), QKeySequence::Copy);
a->setEnabled(m_textEdit->textCursor().hasSelection());
QAction* a = menu.addAction( "&Copy", m_textEdit, SLOT( copy() ), QKeySequence::Copy );
a->setEnabled( m_textEdit->textCursor().hasSelection() );
}
{
menu.addSeparator();
QAction* a = menu.addAction("Select All", m_textEdit, SLOT(selectAll()), QKeySequence::SelectAll);
a->setEnabled(!m_textEdit->document()->isEmpty());
QAction* a = menu.addAction( "Select All", m_textEdit, SLOT( selectAll() ), QKeySequence::SelectAll );
a->setEnabled( !m_textEdit->document()->isEmpty() );
}
menu.addSeparator();
menu.addAction("Clear All &Messages", this, SLOT(slotClearMessages()));
menu.exec(m_textEdit->mapToGlobal(pos));
menu.addAction( "Clear All &Messages", this, SLOT( slotClearMessages() ) );
menu.exec( m_textEdit->mapToGlobal( pos ) );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuMessagePanel::slotClearMessages()
{
m_textEdit->clear();
RiaLogging::info("Message window cleared.");
RiaLogging::info( "Message window cleared." );
}
//==================================================================================================
//
//
//
//
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuMessagePanelLogger::RiuMessagePanelLogger(RiuMessagePanel* messagePanel)
: m_messagePanel(messagePanel),
m_logLevel(RI_LL_WARNING)
RiuMessagePanelLogger::RiuMessagePanelLogger( RiuMessagePanel* messagePanel )
: m_messagePanel( messagePanel )
, m_logLevel( RI_LL_WARNING )
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
int RiuMessagePanelLogger::level() const
{
return m_logLevel;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuMessagePanelLogger::setLevel(int logLevel)
void RiuMessagePanelLogger::setLevel( int logLevel )
{
m_logLevel = logLevel;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuMessagePanelLogger::error(const char* message)
void RiuMessagePanelLogger::error( const char* message )
{
writeToMessagePanel(RI_LL_ERROR, message);
writeToMessagePanel( RI_LL_ERROR, message );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuMessagePanelLogger::warning(const char* message)
void RiuMessagePanelLogger::warning( const char* message )
{
writeToMessagePanel(RI_LL_WARNING, message);
writeToMessagePanel( RI_LL_WARNING, message );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuMessagePanelLogger::info(const char* message)
void RiuMessagePanelLogger::info( const char* message )
{
writeToMessagePanel(RI_LL_INFO, message);
writeToMessagePanel( RI_LL_INFO, message );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuMessagePanelLogger::debug(const char* message)
void RiuMessagePanelLogger::debug( const char* message )
{
writeToMessagePanel(RI_LL_DEBUG, message);
writeToMessagePanel( RI_LL_DEBUG, message );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuMessagePanelLogger::writeToMessagePanel(RILogLevel messageLevel, const char* message)
void RiuMessagePanelLogger::writeToMessagePanel( RILogLevel messageLevel, const char* message )
{
if (messageLevel > m_logLevel)
if ( messageLevel > m_logLevel )
{
return;
}
if (m_messagePanel)
if ( m_messagePanel )
{
m_messagePanel->addMessage(messageLevel, message);
m_messagePanel->addMessage( messageLevel, message );
}
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -26,10 +26,9 @@
class QDockWidget;
class QPlainTextEdit;
//==================================================================================================
//
//
//
//
//==================================================================================================
class RiuMessagePanel : public QWidget
@@ -37,44 +36,41 @@ class RiuMessagePanel : public QWidget
Q_OBJECT
public:
explicit RiuMessagePanel(QDockWidget* parent);
explicit RiuMessagePanel( QDockWidget* parent );
void addMessage(RILogLevel messageLevel, const QString& msg);
QSize sizeHint () const override;
void addMessage( RILogLevel messageLevel, const QString& msg );
QSize sizeHint() const override;
private slots:
void slotShowContextMenu(const QPoint& pos);
void slotClearMessages();
void slotShowContextMenu( const QPoint& pos );
void slotClearMessages();
private:
QPointer<QPlainTextEdit> m_textEdit;
};
//==================================================================================================
//
//
//
//
//==================================================================================================
class RiuMessagePanelLogger : public RiaLogger
{
public:
explicit RiuMessagePanelLogger(RiuMessagePanel* messagePanel);
explicit RiuMessagePanelLogger( RiuMessagePanel* messagePanel );
int level() const override;
void setLevel(int logLevel) override;
int level() const override;
void setLevel( int logLevel ) override;
void error( const char* message) override;
void warning(const char* message) override;
void info( const char* message) override;
void debug( const char* message) override;
void error( const char* message ) override;
void warning( const char* message ) override;
void info( const char* message ) override;
void debug( const char* message ) override;
private:
void writeToMessagePanel(RILogLevel messageLevel, const char* message);
void writeToMessagePanel( RILogLevel messageLevel, const char* message );
private:
QPointer<RiuMessagePanel> m_messagePanel;
int m_logLevel;
QPointer<RiuMessagePanel> m_messagePanel;
int m_logLevel;
};

View File

@@ -61,27 +61,27 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent)
: RiuDockedQwtPlot(parent)
, m_sourceGeoMechViewOfLastPlot(nullptr)
, m_scheduleUpdateAxisScaleTimer(nullptr)
RiuMohrsCirclePlot::RiuMohrsCirclePlot( QWidget* parent )
: RiuDockedQwtPlot( parent )
, m_sourceGeoMechViewOfLastPlot( nullptr )
, m_scheduleUpdateAxisScaleTimer( nullptr )
{
RiuQwtPlotTools::setCommonPlotBehaviour(this);
RiuQwtPlotTools::setCommonPlotBehaviour( this );
enableAxis(QwtPlot::xBottom, true);
enableAxis(QwtPlot::yLeft, true);
enableAxis(QwtPlot::xTop, false);
enableAxis(QwtPlot::yRight, false);
enableAxis( QwtPlot::xBottom, true );
enableAxis( QwtPlot::yLeft, true );
enableAxis( QwtPlot::xTop, false );
enableAxis( QwtPlot::yRight, false );
setAxisTitle(QwtPlot::xBottom, "Effective Normal Stress");
setAxisTitle(QwtPlot::yLeft, "Shear Stress");
setAxisTitle( QwtPlot::xBottom, "Effective Normal Stress" );
setAxisTitle( QwtPlot::yLeft, "Shear Stress" );
applyFontSizes(false);
applyFontSizes( false );
// The legend will be deleted in the destructor of the plot or when
// another legend is inserted.
QwtLegend* legend = new QwtLegend(this);
this->insertLegend(legend, BottomLegend);
QwtLegend* legend = new QwtLegend( this );
this->insertLegend( legend, BottomLegend );
// this->setTitle(QString("SE"));
}
@@ -97,23 +97,24 @@ RiuMohrsCirclePlot::~RiuMohrsCirclePlot()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::appendSelection(const RiuSelectionItem* selectionItem)
void RiuMohrsCirclePlot::appendSelection( const RiuSelectionItem* selectionItem )
{
if (this->isVisible())
if ( this->isVisible() )
{
m_sourceGeoMechViewOfLastPlot = nullptr;
const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast<const RiuGeoMechSelectionItem*>(selectionItem);
if (geoMechSelectionItem)
const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast<const RiuGeoMechSelectionItem*>(
selectionItem );
if ( geoMechSelectionItem )
{
RimGeoMechView* geoMechView = geoMechSelectionItem->m_view;
CVF_ASSERT(geoMechView);
CVF_ASSERT( geoMechView );
const size_t gridIndex = geoMechSelectionItem->m_gridIndex;
const size_t cellIndex = geoMechSelectionItem->m_cellIndex;
const cvf::Color3f color = geoMechSelectionItem->m_color;
queryData(geoMechView, gridIndex, cellIndex, cvf::Color3ub(color));
queryData( geoMechView, gridIndex, cellIndex, cvf::Color3ub( color ) );
updatePlot();
m_sourceGeoMechViewOfLastPlot = geoMechView;
@@ -140,16 +141,16 @@ void RiuMohrsCirclePlot::clearPlot()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::updateOnTimeStepChanged(Rim3dView* changedView)
void RiuMohrsCirclePlot::updateOnTimeStepChanged( Rim3dView* changedView )
{
if (!this->isVisible())
if ( !this->isVisible() )
{
return;
}
// Don't update the plot if the view that changed time step is different from the view that was the source of the current plot
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>(changedView);
if (!geoMechView || geoMechView != m_sourceGeoMechViewOfLastPlot)
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>( changedView );
if ( !geoMechView || geoMechView != m_sourceGeoMechViewOfLastPlot )
{
return;
}
@@ -157,9 +158,9 @@ void RiuMohrsCirclePlot::updateOnTimeStepChanged(Rim3dView* changedView)
std::vector<MohrsCirclesInfo> mohrsCiclesInfosCopy = m_mohrsCiclesInfos;
deletePlotItems();
for (const MohrsCirclesInfo& mohrInfo : mohrsCiclesInfosCopy)
for ( const MohrsCirclesInfo& mohrInfo : mohrsCiclesInfosCopy )
{
queryData(mohrInfo.view, mohrInfo.gridIndex, mohrInfo.elmIndex, mohrInfo.color);
queryData( mohrInfo.view, mohrInfo.gridIndex, mohrInfo.elmIndex, mohrInfo.color );
}
updatePlot();
@@ -170,7 +171,7 @@ void RiuMohrsCirclePlot::updateOnTimeStepChanged(Rim3dView* changedView)
//--------------------------------------------------------------------------------------------------
QSize RiuMohrsCirclePlot::sizeHint() const
{
return QSize(100, 100);
return QSize( 100, 100 );
}
//--------------------------------------------------------------------------------------------------
@@ -178,61 +179,62 @@ QSize RiuMohrsCirclePlot::sizeHint() const
//--------------------------------------------------------------------------------------------------
QSize RiuMohrsCirclePlot::minimumSizeHint() const
{
return QSize(0, 0);
return QSize( 0, 0 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::addMohrCircles(const MohrsCirclesInfo& mohrsCirclesInfo)
void RiuMohrsCirclePlot::addMohrCircles( const MohrsCirclesInfo& mohrsCirclesInfo )
{
const cvf::Vec3f& principals = mohrsCirclesInfo.principals;
std::array<std::pair<double /*radius*/, double /*centerX*/>, 3> mohrsCircles;
mohrsCircles[0].first = (principals[0] - principals[2]) / 2.0;
mohrsCircles[0].second = (principals[0] + principals[2]) / 2.0;
mohrsCircles[0].first = ( principals[0] - principals[2] ) / 2.0;
mohrsCircles[0].second = ( principals[0] + principals[2] ) / 2.0;
mohrsCircles[1].first = (principals[1] - principals[2]) / 2.0;
mohrsCircles[1].second = (principals[1] + principals[2]) / 2.0;
mohrsCircles[1].first = ( principals[1] - principals[2] ) / 2.0;
mohrsCircles[1].second = ( principals[1] + principals[2] ) / 2.0;
mohrsCircles[2].first = (principals[0] - principals[1]) / 2.0;
mohrsCircles[2].second = (principals[0] + principals[1]) / 2.0;
mohrsCircles[2].first = ( principals[0] - principals[1] ) / 2.0;
mohrsCircles[2].second = ( principals[0] + principals[1] ) / 2.0;
for (size_t i = 0; i < 3; i++)
for ( size_t i = 0; i < 3; i++ )
{
QwtPlotShapeItem* plotItem = new QwtPlotShapeItem("Circle");
QwtPlotShapeItem* plotItem = new QwtPlotShapeItem( "Circle" );
QPainterPath* circleDrawing = new QPainterPath();
QPointF center(mohrsCircles[i].second, 0);
circleDrawing->addEllipse(center, mohrsCircles[i].first, mohrsCircles[i].first);
QPointF center( mohrsCircles[i].second, 0 );
circleDrawing->addEllipse( center, mohrsCircles[i].first, mohrsCircles[i].first );
plotItem->setPen(QColor(mohrsCirclesInfo.color.r(), mohrsCirclesInfo.color.g(), mohrsCirclesInfo.color.b()));
plotItem->setShape(*circleDrawing);
plotItem->setRenderHint(QwtPlotItem::RenderAntialiased, true);
plotItem->setPen( QColor( mohrsCirclesInfo.color.r(), mohrsCirclesInfo.color.g(), mohrsCirclesInfo.color.b() ) );
plotItem->setShape( *circleDrawing );
plotItem->setRenderHint( QwtPlotItem::RenderAntialiased, true );
if (i == 0)
if ( i == 0 )
{
QString textBuilder;
textBuilder.append(QString("<b>FOS</b>: %1, ").arg(QString::number(mohrsCirclesInfo.factorOfSafety, 'f', 2)));
textBuilder.append(
QString( "<b>FOS</b>: %1, " ).arg( QString::number( mohrsCirclesInfo.factorOfSafety, 'f', 2 ) ) );
textBuilder.append(QString("<b>Element Id</b>: %1, <b>ijk</b>[%2, %3, %4],")
.arg(mohrsCirclesInfo.elmIndex)
.arg(mohrsCirclesInfo.i)
.arg(mohrsCirclesInfo.j)
.arg(mohrsCirclesInfo.k));
textBuilder.append( QString( "<b>Element Id</b>: %1, <b>ijk</b>[%2, %3, %4]," )
.arg( mohrsCirclesInfo.elmIndex )
.arg( mohrsCirclesInfo.i )
.arg( mohrsCirclesInfo.j )
.arg( mohrsCirclesInfo.k ) );
textBuilder.append(QString("<b>&sigma;<sub>1</sub></b>: %1, ").arg(principals[0]));
textBuilder.append(QString("<b>&sigma;<sub>2</sub></b>: %1, ").arg(principals[1]));
textBuilder.append(QString("<b>&sigma;<sub>3</sub></b>: %1").arg(principals[2]));
textBuilder.append( QString( "<b>&sigma;<sub>1</sub></b>: %1, " ).arg( principals[0] ) );
textBuilder.append( QString( "<b>&sigma;<sub>2</sub></b>: %1, " ).arg( principals[1] ) );
textBuilder.append( QString( "<b>&sigma;<sub>3</sub></b>: %1" ).arg( principals[2] ) );
plotItem->setTitle(textBuilder);
plotItem->setItemAttribute(QwtPlotItem::Legend);
plotItem->setTitle( textBuilder );
plotItem->setItemAttribute( QwtPlotItem::Legend );
}
plotItem->attach(this);
plotItem->attach( this );
m_circlePlotItems.push_back(plotItem);
m_circlePlotItems.push_back( plotItem );
}
}
@@ -241,7 +243,7 @@ void RiuMohrsCirclePlot::addMohrCircles(const MohrsCirclesInfo& mohrsCirclesInfo
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::deleteCircles()
{
for (size_t i = 0; i < m_circlePlotItems.size(); i++)
for ( size_t i = 0; i < m_circlePlotItems.size(); i++ )
{
m_circlePlotItems[i]->detach();
delete m_circlePlotItems[i];
@@ -249,7 +251,7 @@ void RiuMohrsCirclePlot::deleteCircles()
m_circlePlotItems.clear();
for (size_t i = 0; i < m_transparentCurves.size(); i++)
for ( size_t i = 0; i < m_transparentCurves.size(); i++ )
{
m_transparentCurves[i]->detach();
delete m_transparentCurves[i];
@@ -261,14 +263,14 @@ void RiuMohrsCirclePlot::deleteCircles()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::addEnvelopeCurve(const cvf::Vec3f& principals, RimGeoMechView* view)
void RiuMohrsCirclePlot::addEnvelopeCurve( const cvf::Vec3f& principals, RimGeoMechView* view )
{
if (!view) return;
if ( !view ) return;
double cohesion = view->geoMechCase()->cohesion();
double frictionAngle = view->geoMechCase()->frictionAngleDeg();
if (cohesion == HUGE_VAL || frictionAngle == HUGE_VAL || frictionAngle >= 90)
if ( cohesion == HUGE_VAL || frictionAngle == HUGE_VAL || frictionAngle >= 90 )
{
return;
}
@@ -276,9 +278,9 @@ void RiuMohrsCirclePlot::addEnvelopeCurve(const cvf::Vec3f& principals, RimGeoMe
double xVals[2];
double yVals[2];
double tanFrictionAngle = cvf::Math::abs(cvf::Math::tan(cvf::Math::toRadians(frictionAngle)));
double tanFrictionAngle = cvf::Math::abs( cvf::Math::tan( cvf::Math::toRadians( frictionAngle ) ) );
if (tanFrictionAngle == 0 || tanFrictionAngle == HUGE_VAL)
if ( tanFrictionAngle == 0 || tanFrictionAngle == HUGE_VAL )
{
return;
}
@@ -289,12 +291,12 @@ void RiuMohrsCirclePlot::addEnvelopeCurve(const cvf::Vec3f& principals, RimGeoMe
xVals[1] = principals[0];
yVals[0] = 0;
yVals[1] = (cohesion / x) * (x + principals[0]);
yVals[1] = ( cohesion / x ) * ( x + principals[0] );
// If envelope for the view already exists, check if a "larger" envelope should be created
if (m_envolopePlotItems.find(view) != m_envolopePlotItems.end())
if ( m_envolopePlotItems.find( view ) != m_envolopePlotItems.end() )
{
if (yVals[1] <= m_envolopePlotItems[view]->maxYValue())
if ( yVals[1] <= m_envolopePlotItems[view]->maxYValue() )
{
return;
}
@@ -302,26 +304,26 @@ void RiuMohrsCirclePlot::addEnvelopeCurve(const cvf::Vec3f& principals, RimGeoMe
{
m_envolopePlotItems[view]->detach();
delete m_envolopePlotItems[view];
m_envolopePlotItems.erase(view);
m_envolopePlotItems.erase( view );
}
}
QwtPlotCurve* qwtCurve = new QwtPlotCurve();
qwtCurve->setSamples(xVals, yVals, 2);
qwtCurve->setSamples( xVals, yVals, 2 );
qwtCurve->setStyle(QwtPlotCurve::Lines);
qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
qwtCurve->setStyle( QwtPlotCurve::Lines );
qwtCurve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
const QPen curvePen(envelopeColor(view));
qwtCurve->setPen(curvePen);
const QPen curvePen( envelopeColor( view ) );
qwtCurve->setPen( curvePen );
qwtCurve->setTitle(QString("<b>Envelope for %1</b>, (<b>S<sub>0</sub></b>: %2, <b>&Phi;</b>: %3)")
.arg(view->geoMechCase()->caseUserDescription)
.arg(cohesion)
.arg(frictionAngle));
qwtCurve->setTitle( QString( "<b>Envelope for %1</b>, (<b>S<sub>0</sub></b>: %2, <b>&Phi;</b>: %3)" )
.arg( view->geoMechCase()->caseUserDescription )
.arg( cohesion )
.arg( frictionAngle ) );
qwtCurve->attach(this);
qwtCurve->attach( this );
m_envolopePlotItems[view] = qwtCurve;
}
@@ -331,7 +333,7 @@ void RiuMohrsCirclePlot::addEnvelopeCurve(const cvf::Vec3f& principals, RimGeoMe
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::deleteEnvelopes()
{
for (const std::pair<RimGeoMechView*, QwtPlotCurve*>& envelope : m_envolopePlotItems)
for ( const std::pair<RimGeoMechView*, QwtPlotCurve*>& envelope : m_envolopePlotItems )
{
envelope.second->detach();
delete envelope.second;
@@ -343,36 +345,39 @@ void RiuMohrsCirclePlot::deleteEnvelopes()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::queryData(RimGeoMechView* geoMechView, size_t gridIndex, size_t elmIndex, const cvf::Color3ub& color)
void RiuMohrsCirclePlot::queryData( RimGeoMechView* geoMechView,
size_t gridIndex,
size_t elmIndex,
const cvf::Color3ub& color )
{
CVF_ASSERT(geoMechView);
CVF_ASSERT( geoMechView );
m_sourceGeoMechViewOfLastPlot = geoMechView;
RigFemPart* femPart = geoMechView->femParts()->part(gridIndex);
if (femPart->elementType(elmIndex) != HEX8P) return;
RigFemPart* femPart = geoMechView->femParts()->part( gridIndex );
if ( femPart->elementType( elmIndex ) != HEX8P ) return;
int frameIdx = geoMechView->currentTimeStep();
RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults();
RigFemResultAddress address(RigFemResultPosEnum::RIG_ELEMENT_NODAL, "SE", "");
RigFemResultAddress address( RigFemResultPosEnum::RIG_ELEMENT_NODAL, "SE", "" );
// TODO: All tensors are calculated every time this function is called. FIX
std::vector<caf::Ten3f> vertexTensors = resultCollection->tensors(address, 0, frameIdx);
if (vertexTensors.empty())
std::vector<caf::Ten3f> vertexTensors = resultCollection->tensors( address, 0, frameIdx );
if ( vertexTensors.empty() )
{
return;
}
// Calculate average tensor in element
caf::Ten3f tensorSumOfElmNodes = vertexTensors[femPart->elementNodeResultIdx((int)elmIndex, 0)];
for (int i = 1; i < 8; i++)
caf::Ten3f tensorSumOfElmNodes = vertexTensors[femPart->elementNodeResultIdx( (int)elmIndex, 0 )];
for ( int i = 1; i < 8; i++ )
{
tensorSumOfElmNodes = tensorSumOfElmNodes + vertexTensors[femPart->elementNodeResultIdx((int)elmIndex, i)];
tensorSumOfElmNodes = tensorSumOfElmNodes + vertexTensors[femPart->elementNodeResultIdx( (int)elmIndex, i )];
}
caf::Ten3f elmTensor = tensorSumOfElmNodes * (1.0 / 8.0);
caf::Ten3f elmTensor = tensorSumOfElmNodes * ( 1.0 / 8.0 );
cvf::Vec3f principals = elmTensor.calculatePrincipals(nullptr);
cvf::Vec3f principals = elmTensor.calculatePrincipals( nullptr );
if (!isValidPrincipals(principals))
if ( !isValidPrincipals( principals ) )
{
return;
}
@@ -381,15 +386,22 @@ void RiuMohrsCirclePlot::queryData(RimGeoMechView* geoMechView, size_t gridIndex
double frictionAngleDeg = geoMechView->geoMechCase()->frictionAngleDeg();
size_t i, j, k;
bool validIndex = femPart->getOrCreateStructGrid()->ijkFromCellIndex(elmIndex, &i, &j, &k);
CVF_ASSERT(validIndex);
if (validIndex)
{
MohrsCirclesInfo mohrsCircle(
principals, gridIndex, elmIndex, i, j, k, geoMechView, calculateFOS(principals, frictionAngleDeg, cohesion), color);
bool validIndex = femPart->getOrCreateStructGrid()->ijkFromCellIndex( elmIndex, &i, &j, &k );
addMohrsCirclesInfo(mohrsCircle);
CVF_ASSERT( validIndex );
if ( validIndex )
{
MohrsCirclesInfo mohrsCircle( principals,
gridIndex,
elmIndex,
i,
j,
k,
geoMechView,
calculateFOS( principals, frictionAngleDeg, cohesion ),
color );
addMohrsCirclesInfo( mohrsCircle );
}
}
@@ -406,12 +418,12 @@ void RiuMohrsCirclePlot::updatePlot()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::addMohrsCirclesInfo(const MohrsCirclesInfo& mohrsCircleInfo)
void RiuMohrsCirclePlot::addMohrsCirclesInfo( const MohrsCirclesInfo& mohrsCircleInfo )
{
m_mohrsCiclesInfos.push_back(mohrsCircleInfo);
m_mohrsCiclesInfos.push_back( mohrsCircleInfo );
addEnvelopeCurve(mohrsCircleInfo.principals, mohrsCircleInfo.view);
addMohrCircles(mohrsCircleInfo);
addEnvelopeCurve( mohrsCircleInfo.principals, mohrsCircleInfo.view );
addMohrCircles( mohrsCircleInfo );
updateTransparentCurvesOnPrincipals();
}
@@ -420,7 +432,7 @@ void RiuMohrsCirclePlot::addMohrsCirclesInfo(const MohrsCirclesInfo& mohrsCircle
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::updateTransparentCurvesOnPrincipals()
{
for (size_t i = 0; i < m_transparentCurves.size(); i++)
for ( size_t i = 0; i < m_transparentCurves.size(); i++ )
{
m_transparentCurves[i]->detach();
delete m_transparentCurves[i];
@@ -428,23 +440,23 @@ void RiuMohrsCirclePlot::updateTransparentCurvesOnPrincipals()
m_transparentCurves.clear();
for (const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos)
for ( const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos )
{
QwtPlotCurve* transparentCurve = new QwtPlotCurve();
QVector<QPointF> qVectorPoints;
qVectorPoints.push_back(QPointF(mohrCircleInfo.principals[0], 0));
qVectorPoints.push_back(QPointF(mohrCircleInfo.principals[1], 0));
qVectorPoints.push_back(QPointF(mohrCircleInfo.principals[2], 0));
qVectorPoints.push_back( QPointF( mohrCircleInfo.principals[0], 0 ) );
qVectorPoints.push_back( QPointF( mohrCircleInfo.principals[1], 0 ) );
qVectorPoints.push_back( QPointF( mohrCircleInfo.principals[2], 0 ) );
transparentCurve->setSamples(qVectorPoints);
transparentCurve->setYAxis(QwtPlot::yLeft);
transparentCurve->setStyle(QwtPlotCurve::NoCurve);
transparentCurve->setLegendAttribute(QwtPlotCurve::LegendNoAttribute);
transparentCurve->setSamples( qVectorPoints );
transparentCurve->setYAxis( QwtPlot::yLeft );
transparentCurve->setStyle( QwtPlotCurve::NoCurve );
transparentCurve->setLegendAttribute( QwtPlotCurve::LegendNoAttribute );
transparentCurve->attach(this);
m_transparentCurves.push_back(transparentCurve);
transparentCurve->attach( this );
m_transparentCurves.push_back( transparentCurve );
}
}
@@ -455,9 +467,9 @@ double RiuMohrsCirclePlot::largestCircleRadiusInPlot() const
{
double currentLargestDiameter = -HUGE_VAL;
for (const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos)
for ( const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos )
{
if (mohrCircleInfo.principals[0] > currentLargestDiameter)
if ( mohrCircleInfo.principals[0] > currentLargestDiameter )
{
currentLargestDiameter = mohrCircleInfo.principals[0] - mohrCircleInfo.principals[2];
}
@@ -473,9 +485,9 @@ double RiuMohrsCirclePlot::smallestPrincipal() const
{
double currentSmallestPrincipal = HUGE_VAL;
for (const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos)
for ( const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos )
{
if (mohrCircleInfo.principals[2] < currentSmallestPrincipal)
if ( mohrCircleInfo.principals[2] < currentSmallestPrincipal )
{
currentSmallestPrincipal = mohrCircleInfo.principals[2];
}
@@ -491,9 +503,9 @@ double RiuMohrsCirclePlot::largestPrincipal() const
{
double currentLargestPrincipal = -HUGE_VAL;
for (const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos)
for ( const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos )
{
if (mohrCircleInfo.principals[0] > currentLargestPrincipal)
if ( mohrCircleInfo.principals[0] > currentLargestPrincipal )
{
currentLargestPrincipal = mohrCircleInfo.principals[0];
}
@@ -505,26 +517,26 @@ double RiuMohrsCirclePlot::largestPrincipal() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuMohrsCirclePlot::isValidPrincipals(const cvf::Vec3f& principals)
bool RiuMohrsCirclePlot::isValidPrincipals( const cvf::Vec3f& principals )
{
float p1 = principals[0];
float p2 = principals[1];
float p3 = principals[2];
// Inf
if (p1 == HUGE_VAL || p2 == HUGE_VAL || p3 == HUGE_VAL)
if ( p1 == HUGE_VAL || p2 == HUGE_VAL || p3 == HUGE_VAL )
{
return false;
}
// Nan
if ((p1 != p1) || (p2 != p2) || p3 != p3)
if ( ( p1 != p1 ) || ( p2 != p2 ) || p3 != p3 )
{
return false;
}
// Principal rules:
if ((p1 < p2) || (p2 < p3))
if ( ( p1 < p2 ) || ( p2 < p3 ) )
{
return false;
}
@@ -535,20 +547,20 @@ bool RiuMohrsCirclePlot::isValidPrincipals(const cvf::Vec3f& principals)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float RiuMohrsCirclePlot::calculateFOS(const cvf::Vec3f& principals, double frictionAngle, double cohesion)
float RiuMohrsCirclePlot::calculateFOS( const cvf::Vec3f& principals, double frictionAngle, double cohesion )
{
if (cvf::Math::cos(frictionAngle) == 0)
if ( cvf::Math::cos( frictionAngle ) == 0 )
{
return std::nan("");
return std::nan( "" );
}
float se1 = principals[0];
float se3 = principals[2];
float tanFricAng = cvf::Math::tan(cvf::Math::toRadians(frictionAngle));
float tanFricAng = cvf::Math::tan( cvf::Math::toRadians( frictionAngle ) );
float cohPrTanFricAngle = 1.0f * cohesion / tanFricAng;
float dsm = RigFemPartResultsCollection::dsm(se1, se3, tanFricAng, cohPrTanFricAngle);
float dsm = RigFemPartResultsCollection::dsm( se1, se3, tanFricAng, cohPrTanFricAngle );
return 1.0f / dsm;
}
@@ -556,13 +568,14 @@ float RiuMohrsCirclePlot::calculateFOS(const cvf::Vec3f& principals, double fric
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QColor RiuMohrsCirclePlot::envelopeColor(RimGeoMechView* view)
QColor RiuMohrsCirclePlot::envelopeColor( RimGeoMechView* view )
{
if (m_envolopeColors.find(view) == m_envolopeColors.end())
if ( m_envolopeColors.find( view ) == m_envolopeColors.end() )
{
cvf::Color3ub cvfColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3ub(m_envolopeColors.size());
cvf::Color3ub cvfColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3ub(
m_envolopeColors.size() );
QColor color(cvfColor.r(), cvfColor.g(), cvfColor.b());
QColor color( cvfColor.r(), cvfColor.g(), cvfColor.b() );
m_envolopeColors[view] = color;
}
@@ -586,64 +599,64 @@ void RiuMohrsCirclePlot::deletePlotItems()
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::scheduleUpdateAxisScale()
{
if (!m_scheduleUpdateAxisScaleTimer)
if ( !m_scheduleUpdateAxisScaleTimer )
{
m_scheduleUpdateAxisScaleTimer = new QTimer(this);
connect(m_scheduleUpdateAxisScaleTimer, SIGNAL(timeout()), this, SLOT(setAxesScaleAndReplot()));
m_scheduleUpdateAxisScaleTimer = new QTimer( this );
connect( m_scheduleUpdateAxisScaleTimer, SIGNAL( timeout() ), this, SLOT( setAxesScaleAndReplot() ) );
}
if (!m_scheduleUpdateAxisScaleTimer->isActive())
if ( !m_scheduleUpdateAxisScaleTimer->isActive() )
{
m_scheduleUpdateAxisScaleTimer->setSingleShot(true);
m_scheduleUpdateAxisScaleTimer->start(100);
m_scheduleUpdateAxisScaleTimer->setSingleShot( true );
m_scheduleUpdateAxisScaleTimer->start( 100 );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::resizeEvent(QResizeEvent* e)
void RiuMohrsCirclePlot::resizeEvent( QResizeEvent* e )
{
setAxesScaleAndReplot();
// Update axis scale is called one more time because setAxesScaleAndReplot does not work the first
// time if the user does a very quick resizing of the window
scheduleUpdateAxisScale();
QwtPlot::resizeEvent(e);
QwtPlot::resizeEvent( e );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::idealAxesEndPoints(double* xMin, double* xMax, double* yMax) const
void RiuMohrsCirclePlot::idealAxesEndPoints( double* xMin, double* xMax, double* yMax ) const
{
*xMin = HUGE_VAL;
*xMax = -HUGE_VAL;
*yMax = -HUGE_VAL;
double maxYEnvelope = -HUGE_VAL;
for (const std::pair<RimGeoMechView*, QwtPlotCurve*>& envelope : m_envolopePlotItems)
for ( const std::pair<RimGeoMechView*, QwtPlotCurve*>& envelope : m_envolopePlotItems )
{
double tempMax = envelope.second->maxYValue();
if (tempMax > maxYEnvelope)
if ( tempMax > maxYEnvelope )
{
maxYEnvelope = tempMax;
}
}
*yMax = std::max(maxYEnvelope, 1.2 * largestCircleRadiusInPlot());
*yMax = std::max( maxYEnvelope, 1.2 * largestCircleRadiusInPlot() );
double minXEvelope = HUGE_VAL;
for (const std::pair<RimGeoMechView*, QwtPlotCurve*>& envelope : m_envolopePlotItems)
for ( const std::pair<RimGeoMechView*, QwtPlotCurve*>& envelope : m_envolopePlotItems )
{
double tempMin = envelope.second->minXValue();
if (tempMin < minXEvelope)
if ( tempMin < minXEvelope )
{
minXEvelope = tempMin;
}
}
if (minXEvelope < 0)
if ( minXEvelope < 0 )
{
*xMin = minXEvelope;
}
@@ -662,9 +675,9 @@ void RiuMohrsCirclePlot::setAxesScaleAndReplot()
{
// yMin is always 0
double xMin, xMax, yMax;
idealAxesEndPoints(&xMin, &xMax, &yMax);
idealAxesEndPoints( &xMin, &xMax, &yMax );
if (xMax == -HUGE_VAL || xMin == HUGE_VAL || yMax == -HUGE_VAL)
if ( xMax == -HUGE_VAL || xMin == HUGE_VAL || yMax == -HUGE_VAL )
{
return;
}
@@ -678,24 +691,24 @@ void RiuMohrsCirclePlot::setAxesScaleAndReplot()
double xMaxDisplayed = xMax;
double yMaxDisplayed = yMax;
double canvasWidthOverHeightRatio = (1.0 * canvasWidth) / (1.0 * canvasHeight);
double canvasWidthOverHeightRatio = ( 1.0 * canvasWidth ) / ( 1.0 * canvasHeight );
// widthToKeepAspectRatio increases when canvas height is increased
double widthToKeepAspectRatio = minPlotHeight * canvasWidthOverHeightRatio;
// heightToKeepAspectRatio increases when canvas width is increased
double heightToKeepAspectRatio = minPlotWidth / canvasWidthOverHeightRatio;
if (widthToKeepAspectRatio > minPlotWidth)
if ( widthToKeepAspectRatio > minPlotWidth )
{
xMaxDisplayed = widthToKeepAspectRatio + xMin;
}
else if (heightToKeepAspectRatio > minPlotHeight)
else if ( heightToKeepAspectRatio > minPlotHeight )
{
yMaxDisplayed = heightToKeepAspectRatio;
}
this->setAxisScale(QwtPlot::yLeft, 0, yMaxDisplayed);
this->setAxisScale(QwtPlot::xBottom, xMin, xMaxDisplayed);
this->setAxisScale( QwtPlot::yLeft, 0, yMaxDisplayed );
this->setAxisScale( QwtPlot::xBottom, xMin, xMaxDisplayed );
this->replot();
}

View File

@@ -46,35 +46,37 @@ class RiuMohrsCirclePlot : public RiuDockedQwtPlot
Q_OBJECT
public:
RiuMohrsCirclePlot(QWidget* parent);
RiuMohrsCirclePlot( QWidget* parent );
~RiuMohrsCirclePlot() override;
void appendSelection(const RiuSelectionItem* selectionItem);
void appendSelection( const RiuSelectionItem* selectionItem );
void clearPlot();
void updateOnTimeStepChanged(Rim3dView* changedView);
void updateOnTimeStepChanged( Rim3dView* changedView );
private:
struct MohrsCirclesInfo
{
MohrsCirclesInfo(cvf::Vec3f principals,
size_t gridIndex,
size_t elmIndex,
size_t i,
size_t j,
size_t k,
RimGeoMechView* view,
double factorOfSafety,
cvf::Color3ub color)
: principals(principals)
, gridIndex(gridIndex)
, elmIndex(elmIndex)
, i(i)
, j(j)
, k(k)
, view(view)
, factorOfSafety(factorOfSafety)
, color(color) {}
MohrsCirclesInfo( cvf::Vec3f principals,
size_t gridIndex,
size_t elmIndex,
size_t i,
size_t j,
size_t k,
RimGeoMechView* view,
double factorOfSafety,
cvf::Color3ub color )
: principals( principals )
, gridIndex( gridIndex )
, elmIndex( elmIndex )
, i( i )
, j( j )
, k( k )
, view( view )
, factorOfSafety( factorOfSafety )
, color( color )
{
}
cvf::Vec3f principals;
size_t gridIndex;
@@ -88,20 +90,20 @@ private:
private:
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
void resizeEvent(QResizeEvent* e) override;
void resizeEvent( QResizeEvent* e ) override;
void idealAxesEndPoints(double* xMin, double* xMax, double* yMax) const;
void idealAxesEndPoints( double* xMin, double* xMax, double* yMax ) const;
void addMohrCircles(const MohrsCirclesInfo& mohrsCirclesInfo);
void addMohrCircles( const MohrsCirclesInfo& mohrsCirclesInfo );
void deleteCircles();
void addEnvelopeCurve(const cvf::Vec3f& principals, RimGeoMechView* view);
void addEnvelopeCurve( const cvf::Vec3f& principals, RimGeoMechView* view );
void deleteEnvelopes();
void queryData(RimGeoMechView* geoMechView, size_t gridIndex, size_t elmIndex, const cvf::Color3ub& color);
void queryData( RimGeoMechView* geoMechView, size_t gridIndex, size_t elmIndex, const cvf::Color3ub& color );
void updatePlot();
void addMohrsCirclesInfo(const MohrsCirclesInfo& mohrsCircleInfo);
void addMohrsCirclesInfo( const MohrsCirclesInfo& mohrsCircleInfo );
void updateTransparentCurvesOnPrincipals();
@@ -109,11 +111,11 @@ private:
double smallestPrincipal() const;
double largestPrincipal() const;
static bool isValidPrincipals(const cvf::Vec3f& principals);
static bool isValidPrincipals( const cvf::Vec3f& principals );
static float calculateFOS(const cvf::Vec3f& principals, double frictionAngle, double cohesion);
static float calculateFOS( const cvf::Vec3f& principals, double frictionAngle, double cohesion );
QColor envelopeColor(RimGeoMechView* view);
QColor envelopeColor( RimGeoMechView* view );
void deletePlotItems();

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -29,42 +29,42 @@
#include <QFileSystemModel>
#include <QStringListModel>
class FileListModel: public QStringListModel
class FileListModel : public QStringListModel
{
public:
explicit FileListModel(QObject* parent = nullptr)
: QStringListModel(parent)
, m_isItemsEditable(false)
explicit FileListModel( QObject* parent = nullptr )
: QStringListModel( parent )
, m_isItemsEditable( false )
{
}
Qt::ItemFlags flags (const QModelIndex& index) const override
Qt::ItemFlags flags( const QModelIndex& index ) const override
{
if (m_isItemsEditable)
if ( m_isItemsEditable )
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;
else
return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
}
QVariant data ( const QModelIndex & index, int role ) const override
QVariant data( const QModelIndex& index, int role ) const override
{
if (role == Qt::DecorationRole)
if ( role == Qt::DecorationRole )
{
QFileInfo fileInfo(stringList()[index.row()]);
QFileInfo fileInfo( stringList()[index.row()] );
QFileIconProvider iconProv;
return QVariant(iconProv.icon(fileInfo));
return QVariant( iconProv.icon( fileInfo ) );
}
else
{
return QStringListModel::data(index, role);
return QStringListModel::data( index, role );
}
}
void removeFileNames(const QModelIndexList& indexes)
void removeFileNames( const QModelIndexList& indexes )
{
for (int i = indexes.size() - 1; i >= 0; i--)
for ( int i = indexes.size() - 1; i >= 0; i-- )
{
removeRow(indexes[i].row(), indexes[i].parent());
removeRow( indexes[i].row(), indexes[i].parent() );
}
}
@@ -72,27 +72,24 @@ private:
bool m_isItemsEditable;
};
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuMultiCaseImportDialog::RiuMultiCaseImportDialog(QWidget *parent /*= 0*/)
: QDialog(parent, RiuTools::defaultDialogFlags())
RiuMultiCaseImportDialog::RiuMultiCaseImportDialog( QWidget* parent /*= 0*/ )
: QDialog( parent, RiuTools::defaultDialogFlags() )
{
ui = new Ui::RiuMultiCaseImportDialog;
ui->setupUi(this);
m_searchFolders = new FileListModel(this);
ui->m_searchFolderList->setModel(m_searchFolders);
ui->setupUi( this );
m_eclipseGridFiles = new FileListModel(this);
ui->m_eclipseCasesList->setModel(m_eclipseGridFiles);
m_searchFolders = new FileListModel( this );
ui->m_searchFolderList->setModel( m_searchFolders );
m_eclipseGridFiles = new FileListModel( this );
ui->m_eclipseCasesList->setModel( m_eclipseGridFiles );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuMultiCaseImportDialog::~RiuMultiCaseImportDialog()
{
@@ -100,141 +97,143 @@ RiuMultiCaseImportDialog::~RiuMultiCaseImportDialog()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuMultiCaseImportDialog::on_m_addSearchFolderButton_clicked()
{
QString selectedFolder = QFileDialog::getExistingDirectory(this, "Select an Eclipse case search folder", RiaApplication::instance()->lastUsedDialogDirectory("MULTICASEIMPORT"));
QStringList folderNames = m_searchFolders->stringList();
QString selectedFolder = QFileDialog::getExistingDirectory( this,
"Select an Eclipse case search folder",
RiaApplication::instance()->lastUsedDialogDirectory(
"MULTICASEIMPORT" ) );
QStringList folderNames = m_searchFolders->stringList();
if (!folderNames.contains(selectedFolder))
if ( !folderNames.contains( selectedFolder ) )
{
folderNames.push_back(selectedFolder);
m_searchFolders->setStringList(folderNames);
folderNames.push_back( selectedFolder );
m_searchFolders->setStringList( folderNames );
updateGridFileList();
}
RiaApplication::instance()->setLastUsedDialogDirectory("MULTICASEIMPORT", selectedFolder);
RiaApplication::instance()->setLastUsedDialogDirectory( "MULTICASEIMPORT", selectedFolder );
QPushButton* okButton = ui->m_dialogButtons->button(QDialogButtonBox::Ok);
if (okButton)
QPushButton* okButton = ui->m_dialogButtons->button( QDialogButtonBox::Ok );
if ( okButton )
{
okButton->setFocus(Qt::OtherFocusReason);
okButton->setFocus( Qt::OtherFocusReason );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuMultiCaseImportDialog::on_m_removeSearchFolderButton_clicked()
{
QModelIndexList selection = ui->m_searchFolderList->selectionModel()->selectedIndexes();
QStringList folderNames = m_searchFolders->stringList();
QModelIndexList selection = ui->m_searchFolderList->selectionModel()->selectedIndexes();
QStringList folderNames = m_searchFolders->stringList();
QStringList searchFoldersToRemove;
for (int i = 0; i < selection.size(); ++i)
for ( int i = 0; i < selection.size(); ++i )
{
searchFoldersToRemove.push_back(folderNames[selection[i].row()]);
searchFoldersToRemove.push_back( folderNames[selection[i].row()] );
}
for (int i = 0; i < searchFoldersToRemove.size(); ++i)
for ( int i = 0; i < searchFoldersToRemove.size(); ++i )
{
folderNames.removeOne(searchFoldersToRemove[i]);
folderNames.removeOne( searchFoldersToRemove[i] );
}
m_searchFolders->setStringList(folderNames);
m_searchFolders->setStringList( folderNames );
if (selection.size())
if ( selection.size() )
{
updateGridFileList();
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuMultiCaseImportDialog::updateGridFileList()
{
QStringList folderNames = m_searchFolders->stringList();
QStringList folderNames = m_searchFolders->stringList();
QStringList gridFileNames;
// Filter the search folders to remove subfolders of existing roots'
QStringList searchFoldersToRemove;
for (int i = 0; i < folderNames.size(); ++i)
for (int j = 0; j < folderNames.size(); ++j)
for ( int i = 0; i < folderNames.size(); ++i )
for ( int j = 0; j < folderNames.size(); ++j )
{
if ( i != j)
if ( i != j )
{
if (folderNames[i].startsWith(folderNames[j]))
if ( folderNames[i].startsWith( folderNames[j] ) )
{
// Remove folderNames[i]
searchFoldersToRemove.push_back(folderNames[i]);
searchFoldersToRemove.push_back( folderNames[i] );
}
}
}
// Remove the subfolders when adding a root
for (int i = 0; i < searchFoldersToRemove.size(); ++i)
for ( int i = 0; i < searchFoldersToRemove.size(); ++i )
{
folderNames.removeOne(searchFoldersToRemove[i]);
folderNames.removeOne( searchFoldersToRemove[i] );
}
for (int i = 0; i < folderNames.size(); i++)
for ( int i = 0; i < folderNames.size(); i++ )
{
QString folderName = folderNames[i];
appendEGRIDFilesRecursively(folderName, gridFileNames);
}
appendEGRIDFilesRecursively( folderName, gridFileNames );
}
m_eclipseGridFiles->setStringList(gridFileNames);
m_eclipseGridFiles->setStringList( gridFileNames );
}
void RiuMultiCaseImportDialog::appendEGRIDFilesRecursively(const QString& folderName, QStringList& gridFileNames)
void RiuMultiCaseImportDialog::appendEGRIDFilesRecursively( const QString& folderName, QStringList& gridFileNames )
{
{
QDir baseDir(folderName);
baseDir.setFilter(QDir::Files);
QDir baseDir( folderName );
baseDir.setFilter( QDir::Files );
QStringList nameFilters;
nameFilters << "*.egrid" << ".EGRID";
baseDir.setNameFilters(nameFilters);
nameFilters << "*.egrid"
<< ".EGRID";
baseDir.setNameFilters( nameFilters );
QStringList fileNames = baseDir.entryList();
for (int i = 0; i < fileNames.size(); ++i)
for ( int i = 0; i < fileNames.size(); ++i )
{
QString fileName = fileNames[i];
QString absoluteFolderName = baseDir.absoluteFilePath(fileName);
QString absoluteFolderName = baseDir.absoluteFilePath( fileName );
gridFileNames.append(absoluteFolderName);
gridFileNames.append( absoluteFolderName );
}
}
{
QDir baseDir(folderName);
baseDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
QDir baseDir( folderName );
baseDir.setFilter( QDir::Dirs | QDir::NoDotAndDotDot );
QStringList subFolders = baseDir.entryList();
for (int i = 0; i < subFolders.size(); ++i)
for ( int i = 0; i < subFolders.size(); ++i )
{
QString subFolderName = subFolders[i];
QString absoluteFolderName = baseDir.absoluteFilePath(subFolderName);
appendEGRIDFilesRecursively(absoluteFolderName, gridFileNames);
QString absoluteFolderName = baseDir.absoluteFilePath( subFolderName );
appendEGRIDFilesRecursively( absoluteFolderName, gridFileNames );
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QStringList RiuMultiCaseImportDialog::eclipseCaseFileNames() const
{
@@ -242,16 +241,16 @@ QStringList RiuMultiCaseImportDialog::eclipseCaseFileNames() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuMultiCaseImportDialog::on_m_removeEclipseCaseButton_clicked()
{
QModelIndexList selection = ui->m_eclipseCasesList->selectionModel()->selectedIndexes();
if (selection.size())
if ( selection.size() )
{
FileListModel* dataModel = static_cast<FileListModel*>(ui->m_eclipseCasesList->model());
Q_ASSERT(dataModel);
FileListModel* dataModel = static_cast<FileListModel*>( ui->m_eclipseCasesList->model() );
Q_ASSERT( dataModel );
dataModel->removeFileNames(selection);
dataModel->removeFileNames( selection );
}
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -20,37 +20,39 @@
#include <QDialog>
namespace Ui {
class RiuMultiCaseImportDialog;
namespace Ui
{
class RiuMultiCaseImportDialog;
};
class FileListModel;
//==================================================================================================
//
//
//
//
//==================================================================================================
class RiuMultiCaseImportDialog: public QDialog
class RiuMultiCaseImportDialog : public QDialog
{
Q_OBJECT
public:
explicit RiuMultiCaseImportDialog(QWidget *parent = nullptr);
explicit RiuMultiCaseImportDialog( QWidget* parent = nullptr );
~RiuMultiCaseImportDialog() override;
QStringList eclipseCaseFileNames() const;
QStringList eclipseCaseFileNames() const;
protected slots:
void on_m_addSearchFolderButton_clicked();
void on_m_removeSearchFolderButton_clicked();
void on_m_removeEclipseCaseButton_clicked();
private:
void updateGridFileList();
static void appendEGRIDFilesRecursively(const QString& folderName, QStringList& gridFileNames);
void updateGridFileList();
static void appendEGRIDFilesRecursively( const QString& folderName, QStringList& gridFileNames );
Ui::RiuMultiCaseImportDialog* ui;
FileListModel *m_searchFolders;
FileListModel *m_eclipseGridFiles;
FileListModel* m_searchFolders;
FileListModel* m_eclipseGridFiles;
};

View File

@@ -1,137 +1,131 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiuNightchartsWidget.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuNightchartsWidget::RiuNightchartsWidget(QWidget* parent) :
QWidget(parent)
RiuNightchartsWidget::RiuNightchartsWidget( QWidget* parent )
: QWidget( parent )
{
m_showLegend = true;
m_showPie = true;
m_showPie = true;
updateSizePolicy();
clear();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuNightchartsWidget::setType(Nightcharts::type t)
void RiuNightchartsWidget::setType( Nightcharts::type t )
{
m_chart.setType(t);
m_chart.setType( t );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuNightchartsWidget::showLegend(bool doShow)
void RiuNightchartsWidget::showLegend( bool doShow )
{
m_showLegend = doShow;
updateSizePolicy();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuNightchartsWidget::showPie(bool doShow)
void RiuNightchartsWidget::showPie( bool doShow )
{
m_showPie = doShow;
updateSizePolicy();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuNightchartsWidget::updateSizePolicy()
{
if (m_showPie && m_showLegend)
if ( m_showPie && m_showLegend )
{
this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
this->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
}
else if (m_showPie && !m_showLegend )
else if ( m_showPie && !m_showLegend )
{
this->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
this->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum );
}
else if (!m_showPie && m_showLegend )
else if ( !m_showPie && m_showLegend )
{
this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
this->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
}
else
{
this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
this->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuNightchartsWidget::clear()
{
m_chart = Nightcharts();
m_chart.setType(Nightcharts::Pie);
m_chart.setLegendType(Nightcharts::Vertical);
m_chart.setShadows(false);
m_chart.setType( Nightcharts::Pie );
m_chart.setLegendType( Nightcharts::Vertical );
m_chart.setShadows( false );
m_marginLeft = 10;
m_marginTop = 10;
m_marginLeft = 10;
m_marginTop = 10;
m_maxNameWidth = 0;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QSize RiuNightchartsWidget::sizeHint() const
{
int widthHint = 0;
int widthHint = 0;
int heightHint = 0;
if ( m_showLegend )
{
int lineHeight = this->fontMetrics().height();
int lineCount = m_chart.pieceCount();
int lineCount = m_chart.pieceCount();
int exactLegendHeight = (lineCount + lineCount-1) * lineHeight;
int exactLegendHeight = ( lineCount + lineCount - 1 ) * lineHeight;
widthHint = m_maxNameWidth + 5 + lineHeight;
heightHint = exactLegendHeight;
widthHint = m_maxNameWidth + 5 + lineHeight;
heightHint = exactLegendHeight;
}
if (m_showPie)
if ( m_showPie )
{
int maxPieSize = 350;
widthHint = widthHint + maxPieSize;
heightHint = heightHint > maxPieSize ? heightHint : maxPieSize;
widthHint = widthHint + maxPieSize;
heightHint = heightHint > maxPieSize ? heightHint : maxPieSize;
}
if ( m_showPie || m_showLegend )
{
widthHint += 2*m_marginLeft;
heightHint += 2*m_marginTop;
return QSize(widthHint, heightHint);
widthHint += 2 * m_marginLeft;
heightHint += 2 * m_marginTop;
return QSize( widthHint, heightHint );
}
else
{
@@ -140,53 +134,53 @@ QSize RiuNightchartsWidget::sizeHint() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuNightchartsWidget::paintEvent(QPaintEvent* e)
void RiuNightchartsWidget::paintEvent( QPaintEvent* e )
{
QWidget::paintEvent(e);
QWidget::paintEvent( e );
if(!m_chart.pieceCount()) return ;
if ( !m_chart.pieceCount() ) return;
QPainter painter;
painter.begin(this);
int legendWidth = 170;
painter.begin( this );
int legendWidth = 170;
int legendMargin = 20;
if (!m_showLegend)
if ( !m_showLegend )
{
legendWidth = 0;
legendWidth = 0;
legendMargin = 0;
}
int w = (this->width() - 2* m_marginLeft - legendWidth - legendMargin);
int h = (this->height() - 2* m_marginTop );
int w = ( this->width() - 2 * m_marginLeft - legendWidth - legendMargin );
int h = ( this->height() - 2 * m_marginTop );
int size = ( w < h ) ? w : h;
if ( m_showPie )
{
m_chart.setCords(m_marginLeft, m_marginTop, size, size);
m_chart.setLegendCords(m_marginLeft + size + legendMargin, m_marginTop);
m_chart.setCords( m_marginLeft, m_marginTop, size, size );
m_chart.setLegendCords( m_marginLeft + size + legendMargin, m_marginTop );
}
else
{
m_chart.setLegendCords(m_marginLeft, m_marginTop);
m_chart.setLegendCords( m_marginLeft, m_marginTop );
}
if (m_showPie) m_chart.draw(&painter);
if ( m_showPie ) m_chart.draw( &painter );
if ( m_showLegend) m_chart.drawLegend(&painter);
if ( m_showLegend ) m_chart.drawLegend( &painter );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuNightchartsWidget::addItem(const QString& name, const QColor& color, float value)
void RiuNightchartsWidget::addItem( const QString& name, const QColor& color, float value )
{
m_chart.addPiece(name, color, value);
int textWidth = this->fontMetrics().width(name + " (00 %)");
m_chart.addPiece( name, color, value );
int textWidth = this->fontMetrics().width( name + " (00 %)" );
m_maxNameWidth = textWidth > m_maxNameWidth ? textWidth: m_maxNameWidth;
m_maxNameWidth = textWidth > m_maxNameWidth ? textWidth : m_maxNameWidth;
}

View File

@@ -1,50 +1,47 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "nightcharts.h"
#include "cafPdmPointer.h"
#include <QWidget>
#include <QPaintEvent>
#include <QWidget>
class RiuNightchartsWidget : public QWidget
{
Q_OBJECT
public:
explicit RiuNightchartsWidget(QWidget* parent = nullptr);
explicit RiuNightchartsWidget( QWidget* parent = nullptr );
void addItem(const QString& name, const QColor& color, float value);
void setType(Nightcharts::type type);
void showLegend(bool doShow);
void showPie(bool doShow);
void addItem( const QString& name, const QColor& color, float value );
void setType( Nightcharts::type type );
void showLegend( bool doShow );
void showPie( bool doShow );
void clear();
QSize sizeHint() const override;
protected:
void paintEvent(QPaintEvent* e) override;
void paintEvent( QPaintEvent* e ) override;
private:
void updateSizePolicy();
@@ -56,4 +53,3 @@ private:
bool m_showPie;
int m_maxNameWidth;
};

View File

@@ -1,64 +1,64 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiuPickItemInfo.h"
#include "cvfHitItem.h"
#include "cvfPart.h"
#include "cvfDrawableGeo.h"
#include "cvfTransform.h"
#include "cvfHitItem.h"
#include "cvfHitItemCollection.h"
#include "cvfPart.h"
#include "cvfTransform.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuPickItemInfo RiuPickItemInfo::extractPickItemInfo(const cvf::HitItem* hitItem)
RiuPickItemInfo RiuPickItemInfo::extractPickItemInfo( const cvf::HitItem* hitItem )
{
RiuPickItemInfo pickInfo;
pickInfo.m_pickedPart = hitItem->part();
pickInfo.m_pickedPart = hitItem->part();
pickInfo.m_globalPickedPoint = hitItem->intersectionPoint();
if ( pickInfo.m_pickedPart ) pickInfo.m_sourceInfo = pickInfo.m_pickedPart->sourceInfo();
const cvf::HitDetailDrawableGeo* detail = dynamic_cast<const cvf::HitDetailDrawableGeo*>(hitItem->detail());
const cvf::HitDetailDrawableGeo* detail = dynamic_cast<const cvf::HitDetailDrawableGeo*>( hitItem->detail() );
if ( detail ) pickInfo.m_faceIdx = detail->faceIndex();
pickInfo.m_localPickedPoint = pickInfo.m_globalPickedPoint;
const cvf::Transform* xf = pickInfo.m_pickedPart->transform();
const cvf::Transform* xf = pickInfo.m_pickedPart->transform();
if ( xf )
{
pickInfo.m_localPickedPoint.transformPoint(xf->worldTransform().getInverted());
pickInfo.m_localPickedPoint.transformPoint( xf->worldTransform().getInverted() );
}
return pickInfo;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<RiuPickItemInfo> RiuPickItemInfo::convertToPickItemInfos( const cvf::HitItemCollection &hitItems, const cvf::Vec3d& globalRayOrigin)
std::vector<RiuPickItemInfo> RiuPickItemInfo::convertToPickItemInfos( const cvf::HitItemCollection& hitItems,
const cvf::Vec3d& globalRayOrigin )
{
std::vector<RiuPickItemInfo> pickItemInfos;
pickItemInfos.reserve(hitItems.count());
pickItemInfos.reserve( hitItems.count() );
for ( size_t i = 0; i < hitItems.count(); i++ )
{
pickItemInfos.emplace_back(RiuPickItemInfo(hitItems.item(i), globalRayOrigin));
pickItemInfos.emplace_back( RiuPickItemInfo( hitItems.item( i ), globalRayOrigin ) );
}
return pickItemInfos;
}

View File

@@ -1,72 +1,93 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfVector3.h"
#include <vector>
namespace cvf
{
class Part;
class Object;
class HitItem;
class HitItemCollection;
class Ray;
}
class Part;
class Object;
class HitItem;
class HitItemCollection;
class Ray;
} // namespace cvf
class RiuPickItemInfo
{
public:
RiuPickItemInfo()
: m_distanceAlongRay(std::numeric_limits<double>::infinity())
, m_pickedPart(nullptr)
, m_globalPickedPoint (cvf::Vec3d::UNDEFINED)
, m_localPickedPoint (cvf::Vec3d::UNDEFINED)
, m_globalRayOrigin(cvf::Vec3d::UNDEFINED)
, m_sourceInfo (nullptr)
, m_faceIdx (-1)
{}
explicit RiuPickItemInfo(const cvf::HitItem* hitItem, const cvf::Vec3d& globalRayOrigin)
: m_pickedPart(nullptr)
, m_globalPickedPoint (cvf::Vec3d::UNDEFINED)
, m_localPickedPoint (cvf::Vec3d::UNDEFINED)
, m_globalRayOrigin(cvf::Vec3d::UNDEFINED)
, m_sourceInfo (nullptr)
, m_faceIdx (-1)
RiuPickItemInfo()
: m_distanceAlongRay( std::numeric_limits<double>::infinity() )
, m_pickedPart( nullptr )
, m_globalPickedPoint( cvf::Vec3d::UNDEFINED )
, m_localPickedPoint( cvf::Vec3d::UNDEFINED )
, m_globalRayOrigin( cvf::Vec3d::UNDEFINED )
, m_sourceInfo( nullptr )
, m_faceIdx( -1 )
{
*this = extractPickItemInfo(hitItem);
}
explicit RiuPickItemInfo( const cvf::HitItem* hitItem, const cvf::Vec3d& globalRayOrigin )
: m_pickedPart( nullptr )
, m_globalPickedPoint( cvf::Vec3d::UNDEFINED )
, m_localPickedPoint( cvf::Vec3d::UNDEFINED )
, m_globalRayOrigin( cvf::Vec3d::UNDEFINED )
, m_sourceInfo( nullptr )
, m_faceIdx( -1 )
{
*this = extractPickItemInfo( hitItem );
m_globalRayOrigin = globalRayOrigin;
}
const cvf::Part* pickedPart() const { return m_pickedPart;}
cvf::Vec3d globalPickedPoint() const { return m_globalPickedPoint;}
cvf::Vec3d localPickedPoint() const { return m_localPickedPoint;}
const cvf::Object* sourceInfo() const { return m_sourceInfo;}
cvf::uint faceIdx() const { return m_faceIdx;}
double distanceAlongRay() const { return m_distanceAlongRay;}
cvf::Vec3d globalRayOrigin() const { return m_globalRayOrigin;}
const cvf::Part* pickedPart() const
{
return m_pickedPart;
}
cvf::Vec3d globalPickedPoint() const
{
return m_globalPickedPoint;
}
cvf::Vec3d localPickedPoint() const
{
return m_localPickedPoint;
}
const cvf::Object* sourceInfo() const
{
return m_sourceInfo;
}
cvf::uint faceIdx() const
{
return m_faceIdx;
}
double distanceAlongRay() const
{
return m_distanceAlongRay;
}
cvf::Vec3d globalRayOrigin() const
{
return m_globalRayOrigin;
}
static RiuPickItemInfo extractPickItemInfo(const cvf::HitItem* hitItem);
static std::vector<RiuPickItemInfo> convertToPickItemInfos(const cvf::HitItemCollection &hitItems, const cvf::Vec3d& globalRayOrigin);
static RiuPickItemInfo extractPickItemInfo( const cvf::HitItem* hitItem );
static std::vector<RiuPickItemInfo> convertToPickItemInfos( const cvf::HitItemCollection& hitItems,
const cvf::Vec3d& globalRayOrigin );
private:
double m_distanceAlongRay;
@@ -77,5 +98,3 @@ private:
const cvf::Object* m_sourceInfo;
cvf::uint m_faceIdx;
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -20,11 +20,11 @@
#include <QString>
#include "qwt_plot.h"
#include "cvfMath.h"
#include "qwt_plot.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuPlotAnnotationTool::~RiuPlotAnnotationTool()
{
@@ -32,90 +32,95 @@ RiuPlotAnnotationTool::~RiuPlotAnnotationTool()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::attachFormationNames(QwtPlot* plot, const std::vector<QString>& names, const std::vector<std::pair<double, double>> yPositions, bool showNames)
void RiuPlotAnnotationTool::attachFormationNames( QwtPlot* plot,
const std::vector<QString>& names,
const std::vector<std::pair<double, double>> yPositions,
bool showNames )
{
detachAllAnnotations();
if (names.size() != yPositions.size()) return;
if ( names.size() != yPositions.size() ) return;
m_plot = plot;
double delta = 0.5;
for (size_t i = 0; i < names.size(); i++)
for ( size_t i = 0; i < names.size(); i++ )
{
QwtPlotMarker* line(new QwtPlotMarker());
QwtPlotMarker* line( new QwtPlotMarker() );
QString name;
if (showNames)
if ( showNames )
{
name = names[i];
if (names[i].toLower().indexOf("top") == -1)
if ( names[i].toLower().indexOf( "top" ) == -1 )
{
name += " Top";
}
}
RiuPlotAnnotationTool::horizontalDashedLine(line, name, yPositions[i].first);
RiuPlotAnnotationTool::horizontalDashedLine( line, name, yPositions[i].first );
line->attach(m_plot);
m_markers.push_back(std::move(line));
line->attach( m_plot );
m_markers.push_back( std::move( line ) );
if ((i != names.size() - 1) && cvf::Math::abs(yPositions[i].second - yPositions[i+1].first) > delta)
if ( ( i != names.size() - 1 ) && cvf::Math::abs( yPositions[i].second - yPositions[i + 1].first ) > delta )
{
QwtPlotMarker* bottomLine(new QwtPlotMarker());
RiuPlotAnnotationTool::horizontalDashedLine(bottomLine, QString(), yPositions[i].second);
QwtPlotMarker* bottomLine( new QwtPlotMarker() );
RiuPlotAnnotationTool::horizontalDashedLine( bottomLine, QString(), yPositions[i].second );
bottomLine->attach(m_plot);
m_markers.push_back(std::move(bottomLine));
bottomLine->attach( m_plot );
m_markers.push_back( std::move( bottomLine ) );
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::attachWellPicks(QwtPlot* plot, const std::vector<QString>& names, const std::vector<double> yPositions)
void RiuPlotAnnotationTool::attachWellPicks( QwtPlot* plot,
const std::vector<QString>& names,
const std::vector<double> yPositions )
{
detachAllAnnotations();
if (names.size() != yPositions.size()) return;
if ( names.size() != yPositions.size() ) return;
m_plot = plot;
for (size_t i = 0; i < names.size(); i++)
for ( size_t i = 0; i < names.size(); i++ )
{
QwtPlotMarker* line(new QwtPlotMarker());
RiuPlotAnnotationTool::horizontalDashedLine(line, names[i], yPositions[i]);
line->attach(m_plot);
m_markers.push_back(std::move(line));
QwtPlotMarker* line( new QwtPlotMarker() );
RiuPlotAnnotationTool::horizontalDashedLine( line, names[i], yPositions[i] );
line->attach( m_plot );
m_markers.push_back( std::move( line ) );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::attachAnnotationLine(QwtPlot* plot,
const QColor& color,
const QString& annotationText,
const double yPosition)
void RiuPlotAnnotationTool::attachAnnotationLine( QwtPlot* plot,
const QColor& color,
const QString& annotationText,
const double yPosition )
{
m_plot = plot;
QwtPlotMarker* line(new QwtPlotMarker());
RiuPlotAnnotationTool::horizontalDashedLineWithColor(line, color, annotationText, yPosition);
line->attach(m_plot);
m_markers.push_back(std::move(line));
QwtPlotMarker* line( new QwtPlotMarker() );
RiuPlotAnnotationTool::horizontalDashedLineWithColor( line, color, annotationText, yPosition );
line->attach( m_plot );
m_markers.push_back( std::move( line ) );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::detachAllAnnotations()
{
if (m_plot)
if ( m_plot )
{
for (size_t i = 0; i < m_markers.size(); i++)
for ( size_t i = 0; i < m_markers.size(); i++ )
{
m_markers[i]->detach();
delete m_markers[i];
@@ -125,27 +130,29 @@ void RiuPlotAnnotationTool::detachAllAnnotations()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::horizontalDashedLine(QwtPlotMarker* line, const QString& name, double yValue)
void RiuPlotAnnotationTool::horizontalDashedLine( QwtPlotMarker* line, const QString& name, double yValue )
{
horizontalDashedLineWithColor(line, QColor(0, 0, 100), name, yValue);
horizontalDashedLineWithColor( line, QColor( 0, 0, 100 ), name, yValue );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuPlotAnnotationTool::horizontalDashedLineWithColor(QwtPlotMarker* line, const QColor& color, const QString& name, double yValue)
void RiuPlotAnnotationTool::horizontalDashedLineWithColor( QwtPlotMarker* line,
const QColor& color,
const QString& name,
double yValue )
{
QPen curvePen;
curvePen.setStyle(Qt::DashLine);
curvePen.setColor(color);
curvePen.setWidth(1);
curvePen.setStyle( Qt::DashLine );
curvePen.setColor( color );
curvePen.setWidth( 1 );
line->setLineStyle(QwtPlotMarker::HLine);
line->setLinePen(curvePen);
line->setYValue(yValue);
line->setLabel(name);
line->setLabelAlignment(Qt::AlignRight | Qt::AlignBottom);
line->setLineStyle( QwtPlotMarker::HLine );
line->setLinePen( curvePen );
line->setYValue( yValue );
line->setLabel( name );
line->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -31,21 +31,25 @@ class QwtPlot;
class RiuPlotAnnotationTool
{
public:
RiuPlotAnnotationTool() {};
RiuPlotAnnotationTool(){};
~RiuPlotAnnotationTool();
void attachFormationNames(QwtPlot* plot, const std::vector<QString>& names, const std::vector<std::pair<double, double>> yPositions, bool showNames = true);
void attachWellPicks(QwtPlot* plot, const std::vector<QString>& names, const std::vector<double> yPositions);
void attachAnnotationLine(QwtPlot* plot, const QColor& color, const QString& annotationText, const double yPosition);
void attachFormationNames( QwtPlot* plot,
const std::vector<QString>& names,
const std::vector<std::pair<double, double>> yPositions,
bool showNames = true );
void attachWellPicks( QwtPlot* plot, const std::vector<QString>& names, const std::vector<double> yPositions );
void attachAnnotationLine( QwtPlot* plot, const QColor& color, const QString& annotationText, const double yPosition );
void detachAllAnnotations();
private:
static void horizontalDashedLine(QwtPlotMarker* line, const QString& name, double yValue);
static void horizontalDashedLineWithColor(QwtPlotMarker* line, const QColor& color, const QString& name, double yValue);
static void horizontalDashedLine( QwtPlotMarker* line, const QString& name, double yValue );
static void
horizontalDashedLineWithColor( QwtPlotMarker* line, const QColor& color, const QString& name, double yValue );
private:
QPointer<QwtPlot> m_plot;
QPointer<QwtPlot> m_plot;
std::vector<QwtPlotMarker*> m_markers;
};

View File

@@ -62,21 +62,21 @@
///
//--------------------------------------------------------------------------------------------------
RiuPlotMainWindow::RiuPlotMainWindow()
: m_activePlotViewWindow(nullptr)
, m_windowMenu(nullptr)
: m_activePlotViewWindow( nullptr )
, m_windowMenu( nullptr )
{
m_mdiArea = new RiuMdiArea;
connect(m_mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), SLOT(slotSubWindowActivated(QMdiSubWindow*)));
setCentralWidget(m_mdiArea);
connect( m_mdiArea, SIGNAL( subWindowActivated( QMdiSubWindow* ) ), SLOT( slotSubWindowActivated( QMdiSubWindow* ) ) );
setCentralWidget( m_mdiArea );
createMenus();
createToolBars();
createDockPanels();
// Store the layout so we can offer reset option
m_initialDockAndToolbarLayout = saveState(0);
m_initialDockAndToolbarLayout = saveState( 0 );
m_dragDropInterface = std::unique_ptr<caf::PdmUiDragDropInterface>(new RiuDragDrop());
m_dragDropInterface = std::unique_ptr<caf::PdmUiDragDropInterface>( new RiuDragDrop() );
// Enabling the line below will activate the undo stack
// When enableUndoCommandSystem is set false, all commands are executed and deleted immediately
@@ -96,41 +96,41 @@ QString RiuPlotMainWindow::mainWindowName()
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::initializeGuiNewProjectLoaded()
{
setPdmRoot(RiaApplication::instance()->project());
setPdmRoot( RiaApplication::instance()->project() );
restoreTreeViewState();
if (m_pdmUiPropertyView && m_pdmUiPropertyView->currentObject())
if ( m_pdmUiPropertyView && m_pdmUiPropertyView->currentObject() )
{
m_pdmUiPropertyView->currentObject()->uiCapability()->updateConnectedEditors();
}
{
auto* obj = RiaSummaryTools::summaryCaseMainCollection();
if (obj)
if ( obj )
{
setExpanded(obj);
setExpanded( obj );
}
}
{
auto* obj = RiaSummaryTools::summaryPlotCollection();
if (obj)
if ( obj )
{
setExpanded(obj);
setExpanded( obj );
}
}
if (subWindowsAreTiled())
if ( subWindowsAreTiled() )
{
tileSubWindows();
}
if (m_activePlotViewWindow && m_activePlotViewWindow->viewWidget())
if ( m_activePlotViewWindow && m_activePlotViewWindow->viewWidget() )
{
if (m_activePlotViewWindow->mdiWindowGeometry().isMaximized)
if ( m_activePlotViewWindow->mdiWindowGeometry().isMaximized )
{
auto subWin = findMdiSubWindow(m_activePlotViewWindow->viewWidget());
if (subWin)
auto subWin = findMdiSubWindow( m_activePlotViewWindow->viewWidget() );
if ( subWin )
{
subWin->showMaximized();
}
@@ -145,11 +145,11 @@ void RiuPlotMainWindow::initializeGuiNewProjectLoaded()
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::cleanupGuiBeforeProjectClose()
{
setPdmRoot(nullptr);
setPdmRoot( nullptr );
if (m_pdmUiPropertyView)
if ( m_pdmUiPropertyView )
{
m_pdmUiPropertyView->showProperties(nullptr);
m_pdmUiPropertyView->showProperties( nullptr );
}
cleanUpTemporaryWidgets();
@@ -157,7 +157,7 @@ void RiuPlotMainWindow::cleanupGuiBeforeProjectClose()
m_wellLogPlotToolBarEditor->clear();
m_summaryPlotToolBarEditor->clear();
setWindowTitle("Plots - ResInsight");
setWindowTitle( "Plots - ResInsight" );
}
//--------------------------------------------------------------------------------------------------
@@ -165,7 +165,7 @@ void RiuPlotMainWindow::cleanupGuiBeforeProjectClose()
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::cleanUpTemporaryWidgets()
{
for (QWidget* w : m_temporaryWidgets)
for ( QWidget* w : m_temporaryWidgets )
{
w->close();
w->deleteLater();
@@ -177,20 +177,20 @@ void RiuPlotMainWindow::cleanUpTemporaryWidgets()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::closeEvent(QCloseEvent* event)
void RiuPlotMainWindow::closeEvent( QCloseEvent* event )
{
this->saveWinGeoAndDockToolBarLayout();
RiaGuiApplication* app = RiaGuiApplication::instance();
if (app->isMain3dWindowVisible())
if ( app->isMain3dWindowVisible() )
{
event->ignore();
this->hide();
return;
}
if (!app->askUserToSaveModifiedProject())
if ( !app->askUserToSaveModifiedProject() )
{
event->ignore();
return;
@@ -209,101 +209,101 @@ void RiuPlotMainWindow::createMenus()
caf::CmdFeatureManager* cmdFeatureMgr = caf::CmdFeatureManager::instance();
// File menu
QMenu* fileMenu = new RiuToolTipMenu(menuBar());
fileMenu->setTitle("&File");
QMenu* fileMenu = new RiuToolTipMenu( menuBar() );
fileMenu->setTitle( "&File" );
menuBar()->addMenu(fileMenu);
menuBar()->addMenu( fileMenu );
fileMenu->addAction(cmdFeatureMgr->action("RicOpenProjectFeature"));
fileMenu->addAction(cmdFeatureMgr->action("RicOpenLastUsedFileFeature"));
fileMenu->addAction( cmdFeatureMgr->action( "RicOpenProjectFeature" ) );
fileMenu->addAction( cmdFeatureMgr->action( "RicOpenLastUsedFileFeature" ) );
fileMenu->addSeparator();
QMenu* importMenu = fileMenu->addMenu("&Import");
QMenu* importMenu = fileMenu->addMenu( "&Import" );
QMenu* importEclipseMenu = importMenu->addMenu(QIcon(":/Case48x48.png"), "Eclipse Cases");
importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature"));
importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature"));
importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature"));
importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature"));
importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature"));
QMenu* importEclipseMenu = importMenu->addMenu( QIcon( ":/Case48x48.png" ), "Eclipse Cases" );
importEclipseMenu->addAction( cmdFeatureMgr->action( "RicImportEclipseCaseFeature" ) );
importEclipseMenu->addAction( cmdFeatureMgr->action( "RicImportEclipseCasesFeature" ) );
importEclipseMenu->addAction( cmdFeatureMgr->action( "RicImportInputEclipseCaseFeature" ) );
importEclipseMenu->addAction( cmdFeatureMgr->action( "RicCreateGridCaseGroupFeature" ) );
importEclipseMenu->addAction( cmdFeatureMgr->action( "RicCreateGridCaseGroupFromFilesFeature" ) );
#ifdef USE_ODB_API
importMenu->addSeparator();
QMenu* importGeoMechMenu = importMenu->addMenu(QIcon(":/GeoMechCase48x48.png"), "Geo Mechanical Cases");
importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature"));
importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature"));
QMenu* importGeoMechMenu = importMenu->addMenu( QIcon( ":/GeoMechCase48x48.png" ), "Geo Mechanical Cases" );
importGeoMechMenu->addAction( cmdFeatureMgr->action( "RicImportGeoMechCaseFeature" ) );
importGeoMechMenu->addAction( cmdFeatureMgr->action( "RicImportElementPropertyFeature" ) );
#endif
importMenu->addSeparator();
QMenu* importSummaryMenu = importMenu->addMenu(QIcon(":/SummaryCase48x48.png"), "Summary Cases");
importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature"));
importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature"));
importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryGroupFeature"));
importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature"));
QMenu* importSummaryMenu = importMenu->addMenu( QIcon( ":/SummaryCase48x48.png" ), "Summary Cases" );
importSummaryMenu->addAction( cmdFeatureMgr->action( "RicImportSummaryCaseFeature" ) );
importSummaryMenu->addAction( cmdFeatureMgr->action( "RicImportSummaryCasesFeature" ) );
importSummaryMenu->addAction( cmdFeatureMgr->action( "RicImportSummaryGroupFeature" ) );
importSummaryMenu->addAction( cmdFeatureMgr->action( "RicImportEnsembleFeature" ) );
importMenu->addSeparator();
QMenu* importWellMenu = importMenu->addMenu(QIcon(":/Well.png"), "Well Data");
importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature"));
importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature"));
importWellMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature"));
importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature"));
QMenu* importWellMenu = importMenu->addMenu( QIcon( ":/Well.png" ), "Well Data" );
importWellMenu->addAction( cmdFeatureMgr->action( "RicWellPathsImportFileFeature" ) );
importWellMenu->addAction( cmdFeatureMgr->action( "RicWellPathsImportSsihubFeature" ) );
importWellMenu->addAction( cmdFeatureMgr->action( "RicWellLogsImportFileFeature" ) );
importWellMenu->addAction( cmdFeatureMgr->action( "RicWellPathFormationsImportFileFeature" ) );
importMenu->addSeparator();
importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature"));
importMenu->addAction(cmdFeatureMgr->action("RicImportObservedFmuDataInMenuFeature"));
importMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature"));
importMenu->addAction( cmdFeatureMgr->action( "RicImportObservedDataInMenuFeature" ) );
importMenu->addAction( cmdFeatureMgr->action( "RicImportObservedFmuDataInMenuFeature" ) );
importMenu->addAction( cmdFeatureMgr->action( "RicImportFormationNamesFeature" ) );
QMenu* exportMenu = fileMenu->addMenu("&Export");
exportMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToFileFeature"));
exportMenu->addAction(cmdFeatureMgr->action("RicSnapshotAllPlotsToFileFeature"));
exportMenu->addAction(cmdFeatureMgr->action("RicSaveEclipseInputActiveVisibleCellsFeature"));
QMenu* exportMenu = fileMenu->addMenu( "&Export" );
exportMenu->addAction( cmdFeatureMgr->action( "RicSnapshotViewToFileFeature" ) );
exportMenu->addAction( cmdFeatureMgr->action( "RicSnapshotAllPlotsToFileFeature" ) );
exportMenu->addAction( cmdFeatureMgr->action( "RicSaveEclipseInputActiveVisibleCellsFeature" ) );
fileMenu->addSeparator();
fileMenu->addAction(cmdFeatureMgr->action("RicSaveProjectFeature"));
fileMenu->addAction(cmdFeatureMgr->action("RicSaveProjectAsFeature"));
fileMenu->addAction( cmdFeatureMgr->action( "RicSaveProjectFeature" ) );
fileMenu->addAction( cmdFeatureMgr->action( "RicSaveProjectAsFeature" ) );
std::vector<QAction*> recentFileActions = RiaGuiApplication::instance()->recentFileActions();
for (auto act : recentFileActions)
for ( auto act : recentFileActions )
{
fileMenu->addAction(act);
fileMenu->addAction( act );
}
fileMenu->addSeparator();
fileMenu->addAction(cmdFeatureMgr->action("RicCloseProjectFeature"));
fileMenu->addAction( cmdFeatureMgr->action( "RicCloseProjectFeature" ) );
fileMenu->addSeparator();
fileMenu->addAction(cmdFeatureMgr->action("RicExitApplicationFeature"));
fileMenu->addAction( cmdFeatureMgr->action( "RicExitApplicationFeature" ) );
// Edit menu
QMenu* editMenu = menuBar()->addMenu("&Edit");
editMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToClipboardFeature"));
editMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToFileFeature"));
QMenu* editMenu = menuBar()->addMenu( "&Edit" );
editMenu->addAction( cmdFeatureMgr->action( "RicSnapshotViewToClipboardFeature" ) );
editMenu->addAction( cmdFeatureMgr->action( "RicSnapshotViewToFileFeature" ) );
editMenu->addSeparator();
editMenu->addAction(cmdFeatureMgr->action("RicEditPreferencesFeature"));
editMenu->addAction( cmdFeatureMgr->action( "RicEditPreferencesFeature" ) );
// View menu
QMenu* viewMenu = menuBar()->addMenu("&View");
viewMenu->addAction(cmdFeatureMgr->action("RicViewZoomAllFeature"));
QMenu* viewMenu = menuBar()->addMenu( "&View" );
viewMenu->addAction( cmdFeatureMgr->action( "RicViewZoomAllFeature" ) );
// Windows menu
m_windowMenu = menuBar()->addMenu("&Windows");
connect(m_windowMenu, SIGNAL(aboutToShow()), SLOT(slotBuildWindowActions()));
m_windowMenu = menuBar()->addMenu( "&Windows" );
connect( m_windowMenu, SIGNAL( aboutToShow() ), SLOT( slotBuildWindowActions() ) );
// Help menu
QMenu* helpMenu = menuBar()->addMenu("&Help");
helpMenu->addAction(cmdFeatureMgr->action("RicHelpAboutFeature"));
helpMenu->addAction(cmdFeatureMgr->action("RicHelpCommandLineFeature"));
QMenu* helpMenu = menuBar()->addMenu( "&Help" );
helpMenu->addAction( cmdFeatureMgr->action( "RicHelpAboutFeature" ) );
helpMenu->addAction( cmdFeatureMgr->action( "RicHelpCommandLineFeature" ) );
helpMenu->addSeparator();
helpMenu->addAction(cmdFeatureMgr->action("RicHelpOpenUsersGuideFeature"));
helpMenu->addAction( cmdFeatureMgr->action( "RicHelpOpenUsersGuideFeature" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RiuPlotMainWindow::toolbarCommandIds(const QString& toolbarName)
QStringList RiuPlotMainWindow::toolbarCommandIds( const QString& toolbarName )
{
QStringList commandIds;
if (toolbarName.isEmpty() || toolbarName == "Standard")
if ( toolbarName.isEmpty() || toolbarName == "Standard" )
{
commandIds << "RicImportGeneralDataFeature";
commandIds << "RicImportSummaryCaseFeature";
@@ -312,21 +312,21 @@ QStringList RiuPlotMainWindow::toolbarCommandIds(const QString& toolbarName)
commandIds << "RicSaveProjectFeature";
}
if (toolbarName.isEmpty() || toolbarName == "Window Management")
if ( toolbarName.isEmpty() || toolbarName == "Window Management" )
{
commandIds << "RicShowMainWindowFeature";
commandIds << "RicTilePlotWindowsFeature";
commandIds << "RicShowSummaryCurveCalculatorFeature";
}
if (toolbarName.isEmpty() || toolbarName == "View Snapshots")
if ( toolbarName.isEmpty() || toolbarName == "View Snapshots" )
{
commandIds << "RicSnapshotViewToClipboardFeature";
commandIds << "RicSnapshotViewToFileFeature";
commandIds << "RicSnapshotAllPlotsToFileFeature";
}
if (toolbarName.isEmpty() || toolbarName == "View")
if ( toolbarName.isEmpty() || toolbarName == "View" )
{
commandIds << "RicViewZoomAllFeature";
}
@@ -340,7 +340,7 @@ QStringList RiuPlotMainWindow::toolbarCommandIds(const QString& toolbarName)
void RiuPlotMainWindow::createToolBars()
{
caf::CmdFeatureManager* cmdFeatureMgr = caf::CmdFeatureManager::instance();
CVF_ASSERT(cmdFeatureMgr);
CVF_ASSERT( cmdFeatureMgr );
QStringList toolbarNames;
toolbarNames << "Standard"
@@ -348,22 +348,22 @@ void RiuPlotMainWindow::createToolBars()
<< "View Snapshots"
<< "View";
for (QString toolbarName : toolbarNames)
for ( QString toolbarName : toolbarNames )
{
QToolBar* toolbar = addToolBar(toolbarName);
toolbar->setObjectName(toolbar->windowTitle());
QToolBar* toolbar = addToolBar( toolbarName );
toolbar->setObjectName( toolbar->windowTitle() );
QStringList toolbarCommands = toolbarCommandIds(toolbarName);
for (QString s : toolbarCommands)
QStringList toolbarCommands = toolbarCommandIds( toolbarName );
for ( QString s : toolbarCommands )
{
toolbar->addAction(cmdFeatureMgr->action(s));
toolbar->addAction( cmdFeatureMgr->action( s ) );
}
}
m_wellLogPlotToolBarEditor = new caf::PdmUiToolBarEditor("Well Log Plot", this);
m_wellLogPlotToolBarEditor = new caf::PdmUiToolBarEditor( "Well Log Plot", this );
m_wellLogPlotToolBarEditor->hide();
m_summaryPlotToolBarEditor = new caf::PdmUiToolBarEditor("Summary Plot", this);
m_summaryPlotToolBarEditor = new caf::PdmUiToolBarEditor( "Summary Plot", this );
m_summaryPlotToolBarEditor->hide();
}
@@ -374,8 +374,8 @@ void RiuPlotMainWindow::refreshToolbars()
{
QStringList allToolbarCommandNames = toolbarCommandIds();
caf::CmdFeatureManager::instance()->refreshEnabledState(allToolbarCommandNames);
caf::CmdFeatureManager::instance()->refreshCheckedState(allToolbarCommandNames);
caf::CmdFeatureManager::instance()->refreshEnabledState( allToolbarCommandNames );
caf::CmdFeatureManager::instance()->refreshCheckedState( allToolbarCommandNames );
}
//--------------------------------------------------------------------------------------------------
@@ -384,60 +384,60 @@ void RiuPlotMainWindow::refreshToolbars()
void RiuPlotMainWindow::createDockPanels()
{
{
QDockWidget* dockWidget = new QDockWidget("Plot Project Tree", this);
dockWidget->setObjectName(RiuDockWidgetTools::plotMainWindowProjectTreeName());
dockWidget->setAllowedAreas(Qt::AllDockWidgetAreas);
QDockWidget* dockWidget = new QDockWidget( "Plot Project Tree", this );
dockWidget->setObjectName( RiuDockWidgetTools::plotMainWindowProjectTreeName() );
dockWidget->setAllowedAreas( Qt::AllDockWidgetAreas );
m_projectTreeView = new caf::PdmUiTreeView(this);
m_projectTreeView->enableSelectionManagerUpdating(true);
m_projectTreeView = new caf::PdmUiTreeView( this );
m_projectTreeView->enableSelectionManagerUpdating( true );
RiaApplication* app = RiaApplication::instance();
m_projectTreeView->enableAppendOfClassNameToUiItemText(app->preferences()->appendClassNameToUiText());
m_projectTreeView->enableAppendOfClassNameToUiItemText( app->preferences()->appendClassNameToUiText() );
dockWidget->setWidget(m_projectTreeView);
dockWidget->setWidget( m_projectTreeView );
m_projectTreeView->treeView()->setHeaderHidden(true);
m_projectTreeView->treeView()->setSelectionMode(QAbstractItemView::ExtendedSelection);
m_projectTreeView->treeView()->setHeaderHidden( true );
m_projectTreeView->treeView()->setSelectionMode( QAbstractItemView::ExtendedSelection );
// Drag and drop configuration
m_projectTreeView->treeView()->setDragEnabled(true);
m_projectTreeView->treeView()->viewport()->setAcceptDrops(true);
m_projectTreeView->treeView()->setDropIndicatorShown(true);
m_projectTreeView->treeView()->setDragDropMode(QAbstractItemView::DragDrop);
m_projectTreeView->treeView()->setDragEnabled( true );
m_projectTreeView->treeView()->viewport()->setAcceptDrops( true );
m_projectTreeView->treeView()->setDropIndicatorShown( true );
m_projectTreeView->treeView()->setDragDropMode( QAbstractItemView::DragDrop );
// Install event filter used to handle key press events
RiuTreeViewEventFilter* treeViewEventFilter = new RiuTreeViewEventFilter(this);
m_projectTreeView->treeView()->installEventFilter(treeViewEventFilter);
RiuTreeViewEventFilter* treeViewEventFilter = new RiuTreeViewEventFilter( this );
m_projectTreeView->treeView()->installEventFilter( treeViewEventFilter );
addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
addDockWidget( Qt::LeftDockWidgetArea, dockWidget );
connect(m_projectTreeView, SIGNAL(selectionChanged()), this, SLOT(selectedObjectsChanged()));
m_projectTreeView->treeView()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_projectTreeView->treeView(),
SIGNAL(customContextMenuRequested(const QPoint&)),
SLOT(customMenuRequested(const QPoint&)));
connect( m_projectTreeView, SIGNAL( selectionChanged() ), this, SLOT( selectedObjectsChanged() ) );
m_projectTreeView->treeView()->setContextMenuPolicy( Qt::CustomContextMenu );
connect( m_projectTreeView->treeView(),
SIGNAL( customContextMenuRequested( const QPoint& ) ),
SLOT( customMenuRequested( const QPoint& ) ) );
m_projectTreeView->setUiConfigurationName("PlotWindow");
m_projectTreeView->setUiConfigurationName( "PlotWindow" );
}
{
QDockWidget* dockWidget = new QDockWidget("Property Editor", this);
dockWidget->setObjectName(RiuDockWidgetTools::plotMainWindowPropertyEditorName());
dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
QDockWidget* dockWidget = new QDockWidget( "Property Editor", this );
dockWidget->setObjectName( RiuDockWidgetTools::plotMainWindowPropertyEditorName() );
dockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
m_pdmUiPropertyView = new caf::PdmUiPropertyView(dockWidget);
dockWidget->setWidget(m_pdmUiPropertyView);
m_pdmUiPropertyView = new caf::PdmUiPropertyView( dockWidget );
dockWidget->setWidget( m_pdmUiPropertyView );
addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
addDockWidget( Qt::LeftDockWidgetArea, dockWidget );
}
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
setCorner( Qt::BottomLeftCorner, Qt::LeftDockWidgetArea );
setCorner( Qt::BottomRightCorner, Qt::BottomDockWidgetArea );
QList<QDockWidget*> dockWidgets = findChildren<QDockWidget*>();
for (QDockWidget* dock : dockWidgets)
for ( QDockWidget* dock : dockWidgets )
{
connect(dock->toggleViewAction(), SIGNAL(triggered()), SLOT(slotDockWidgetToggleViewActionTriggered()));
connect( dock->toggleViewAction(), SIGNAL( triggered() ), SLOT( slotDockWidgetToggleViewActionTriggered() ) );
}
}
@@ -445,13 +445,13 @@ void RiuPlotMainWindow::createDockPanels()
///
//--------------------------------------------------------------------------------------------------
QMdiSubWindow* RiuPlotMainWindow::findMdiSubWindow(QWidget* viewer)
QMdiSubWindow* RiuPlotMainWindow::findMdiSubWindow( QWidget* viewer )
{
QList<QMdiSubWindow*> subws = m_mdiArea->subWindowList();
int i;
for (i = 0; i < subws.size(); ++i)
for ( i = 0; i < subws.size(); ++i )
{
if (subws[i]->widget() == viewer)
if ( subws[i]->widget() == viewer )
{
return subws[i];
}
@@ -463,25 +463,25 @@ QMdiSubWindow* RiuPlotMainWindow::findMdiSubWindow(QWidget* viewer)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<QMdiSubWindow*> RiuPlotMainWindow::subWindowList(QMdiArea::WindowOrder order)
QList<QMdiSubWindow*> RiuPlotMainWindow::subWindowList( QMdiArea::WindowOrder order )
{
return m_mdiArea->subWindowList(order);
return m_mdiArea->subWindowList( order );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::setWidthOfMdiWindow(QWidget* mdiWindowWidget, int newWidth)
void RiuPlotMainWindow::setWidthOfMdiWindow( QWidget* mdiWindowWidget, int newWidth )
{
QMdiSubWindow* mdiWindow = findMdiSubWindow(mdiWindowWidget);
if (mdiWindow)
QMdiSubWindow* mdiWindow = findMdiSubWindow( mdiWindowWidget );
if ( mdiWindow )
{
QSize subWindowSize = mdiWindow->size();
subWindowSize.setWidth(std::max(newWidth, 100));
mdiWindow->resize(subWindowSize);
subWindowSize.setWidth( std::max( newWidth, 100 ) );
mdiWindow->resize( subWindowSize );
if (mdiWindow->isMaximized())
if ( mdiWindow->isMaximized() )
{
// Set window temporarily to normal state and back to maximized
// to redo layout so the whole window canvas is filled
@@ -499,11 +499,11 @@ void RiuPlotMainWindow::setWidthOfMdiWindow(QWidget* mdiWindowWidget, int newWid
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::addToTemporaryWidgets(QWidget* widget)
void RiuPlotMainWindow::addToTemporaryWidgets( QWidget* widget )
{
CVF_ASSERT(widget);
CVF_ASSERT( widget );
m_temporaryWidgets.push_back(widget);
m_temporaryWidgets.push_back( widget );
}
//--------------------------------------------------------------------------------------------------
@@ -511,13 +511,13 @@ void RiuPlotMainWindow::addToTemporaryWidgets(QWidget* widget)
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::updateWellLogPlotToolBar()
{
RimWellLogPlot* wellLogPlot = dynamic_cast<RimWellLogPlot*>(m_activePlotViewWindow.p());
if (wellLogPlot)
RimWellLogPlot* wellLogPlot = dynamic_cast<RimWellLogPlot*>( m_activePlotViewWindow.p() );
if ( wellLogPlot )
{
std::vector<caf::PdmFieldHandle*> toolBarFields;
toolBarFields = wellLogPlot->commonDataSource()->fieldsToShowInToolbar();
m_wellLogPlotToolBarEditor->setFields(toolBarFields);
m_wellLogPlotToolBarEditor->setFields( toolBarFields );
m_wellLogPlotToolBarEditor->updateUi();
m_wellLogPlotToolBarEditor->show();
@@ -535,23 +535,23 @@ void RiuPlotMainWindow::updateWellLogPlotToolBar()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::updateSummaryPlotToolBar(bool forceUpdateUi)
void RiuPlotMainWindow::updateSummaryPlotToolBar( bool forceUpdateUi )
{
RimSummaryPlot* summaryPlot = dynamic_cast<RimSummaryPlot*>(m_activePlotViewWindow.p());
if (summaryPlot)
RimSummaryPlot* summaryPlot = dynamic_cast<RimSummaryPlot*>( m_activePlotViewWindow.p() );
if ( summaryPlot )
{
std::vector<caf::PdmFieldHandle*> toolBarFields;
RimEnsembleCurveSetCollection* ensembleCurveSetColl = nullptr;
caf::PdmObjectHandle* selectedObj =
dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
if (selectedObj)
caf::PdmObjectHandle* selectedObj = dynamic_cast<caf::PdmObjectHandle*>(
caf::SelectionManager::instance()->selectedItem() );
if ( selectedObj )
{
selectedObj->firstAncestorOrThisOfType(ensembleCurveSetColl);
selectedObj->firstAncestorOrThisOfType( ensembleCurveSetColl );
}
if (ensembleCurveSetColl)
if ( ensembleCurveSetColl )
{
toolBarFields = ensembleCurveSetColl->fieldsToShowInToolbar();
}
@@ -560,11 +560,11 @@ void RiuPlotMainWindow::updateSummaryPlotToolBar(bool forceUpdateUi)
toolBarFields = summaryPlot->summaryCurveCollection()->fieldsToShowInToolbar();
}
if (!m_summaryPlotToolBarEditor->isEditorDataValid(toolBarFields))
if ( !m_summaryPlotToolBarEditor->isEditorDataValid( toolBarFields ) )
{
m_summaryPlotToolBarEditor->setFields(toolBarFields);
m_summaryPlotToolBarEditor->setFields( toolBarFields );
}
else if (forceUpdateUi)
else if ( forceUpdateUi )
{
m_summaryPlotToolBarEditor->updateUi();
}
@@ -586,40 +586,40 @@ void RiuPlotMainWindow::updateSummaryPlotToolBar(bool forceUpdateUi)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::removeViewer(QWidget* viewer)
void RiuPlotMainWindow::removeViewer( QWidget* viewer )
{
removeViewerFromMdiArea(m_mdiArea, viewer);
removeViewerFromMdiArea( m_mdiArea, viewer );
refreshToolbars();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry)
void RiuPlotMainWindow::addViewer( QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry )
{
QSize subWindowSize;
QPoint subWindowPos(-1, -1);
QPoint subWindowPos( -1, -1 );
if (windowsGeometry.isValid())
if ( windowsGeometry.isValid() )
{
subWindowPos = QPoint(windowsGeometry.x, windowsGeometry.y);
subWindowSize = QSize(windowsGeometry.width, windowsGeometry.height);
subWindowPos = QPoint( windowsGeometry.x, windowsGeometry.y );
subWindowSize = QSize( windowsGeometry.width, windowsGeometry.height );
}
else
{
RiuWellLogPlot* wellLogPlot = dynamic_cast<RiuWellLogPlot*>(viewer);
if (wellLogPlot)
RiuWellLogPlot* wellLogPlot = dynamic_cast<RiuWellLogPlot*>( viewer );
if ( wellLogPlot )
{
QSize preferredSize = wellLogPlot->preferredSize();
subWindowSize = QSize(preferredSize.width(), m_mdiArea->height());
subWindowSize = QSize( preferredSize.width(), m_mdiArea->height() );
}
else
{
subWindowSize = QSize(400, 400);
subWindowSize = QSize( 400, 400 );
}
}
addViewerToMdiArea(m_mdiArea, viewer, subWindowPos, subWindowSize);
addViewerToMdiArea( m_mdiArea, viewer, subWindowPos, subWindowSize );
refreshToolbars();
}
@@ -627,31 +627,31 @@ void RiuPlotMainWindow::addViewer(QWidget* viewer, const RimMdiWindowGeometry& w
//--------------------------------------------------------------------------------------------------
/// This method needs to handle memory deallocation !!!
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::setPdmRoot(caf::PdmObject* pdmRoot)
void RiuPlotMainWindow::setPdmRoot( caf::PdmObject* pdmRoot )
{
m_projectTreeView->setPdmItem(pdmRoot);
m_projectTreeView->setPdmItem( pdmRoot );
// For debug only : m_projectTreeView->treeView()->expandAll();
m_projectTreeView->setDragDropInterface(m_dragDropInterface.get());
m_projectTreeView->setDragDropInterface( m_dragDropInterface.get() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow)
void RiuPlotMainWindow::slotSubWindowActivated( QMdiSubWindow* subWindow )
{
if (!subWindow) return;
if (blockSlotSubWindowActivated()) return;
if ( !subWindow ) return;
if ( blockSlotSubWindowActivated() ) return;
RimProject* proj = RiaApplication::instance()->project();
if (!proj) return;
if ( !proj ) return;
// Select in Project Tree
RimViewWindow* viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget(subWindow->widget());
RimViewWindow* viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget( subWindow->widget() );
if (viewWindow && viewWindow != m_activePlotViewWindow)
if ( viewWindow && viewWindow != m_activePlotViewWindow )
{
selectAsCurrentItem(viewWindow);
selectAsCurrentItem( viewWindow );
m_activePlotViewWindow = viewWindow;
}
@@ -662,10 +662,10 @@ void RiuPlotMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::setActiveViewer(QWidget* viewer)
void RiuPlotMainWindow::setActiveViewer( QWidget* viewer )
{
QMdiSubWindow* swin = findMdiSubWindow(viewer);
if (swin) m_mdiArea->setActiveSubWindow(swin);
QMdiSubWindow* swin = findMdiSubWindow( viewer );
if ( swin ) m_mdiArea->setActiveSubWindow( swin );
}
//--------------------------------------------------------------------------------------------------
@@ -677,26 +677,26 @@ void RiuPlotMainWindow::slotBuildWindowActions()
{
caf::CmdFeatureManager* cmdFeatureMgr = caf::CmdFeatureManager::instance();
m_windowMenu->addAction(cmdFeatureMgr->action("RicShowMainWindowFeature"));
m_windowMenu->addAction( cmdFeatureMgr->action( "RicShowMainWindowFeature" ) );
m_windowMenu->addSeparator();
}
QList<QDockWidget*> dockWidgets = findChildren<QDockWidget*>();
for (QDockWidget* dock : dockWidgets)
for ( QDockWidget* dock : dockWidgets )
{
m_windowMenu->addAction(dock->toggleViewAction());
m_windowMenu->addAction( dock->toggleViewAction() );
}
m_windowMenu->addSeparator();
QAction* cascadeWindowsAction = new QAction("Cascade Windows", this);
connect(cascadeWindowsAction, SIGNAL(triggered()), m_mdiArea, SLOT(cascadeSubWindows()));
QAction* cascadeWindowsAction = new QAction( "Cascade Windows", this );
connect( cascadeWindowsAction, SIGNAL( triggered() ), m_mdiArea, SLOT( cascadeSubWindows() ) );
QAction* closeAllSubWindowsAction = new QAction("Close All Windows", this);
connect(closeAllSubWindowsAction, SIGNAL(triggered()), m_mdiArea, SLOT(closeAllSubWindows()));
QAction* closeAllSubWindowsAction = new QAction( "Close All Windows", this );
connect( closeAllSubWindowsAction, SIGNAL( triggered() ), m_mdiArea, SLOT( closeAllSubWindows() ) );
m_windowMenu->addAction(caf::CmdFeatureManager::instance()->action("RicTilePlotWindowsFeature"));
m_windowMenu->addAction(cascadeWindowsAction);
m_windowMenu->addAction(closeAllSubWindowsAction);
m_windowMenu->addAction( caf::CmdFeatureManager::instance()->action( "RicTilePlotWindowsFeature" ) );
m_windowMenu->addAction( cascadeWindowsAction );
m_windowMenu->addAction( closeAllSubWindowsAction );
}
//--------------------------------------------------------------------------------------------------
@@ -705,60 +705,60 @@ void RiuPlotMainWindow::slotBuildWindowActions()
void RiuPlotMainWindow::selectedObjectsChanged()
{
std::vector<caf::PdmUiItem*> uiItems;
m_projectTreeView->selectedUiItems(uiItems);
m_projectTreeView->selectedUiItems( uiItems );
caf::PdmObjectHandle* firstSelectedObject = nullptr;
if (uiItems.size() == 1)
if ( uiItems.size() == 1 )
{
firstSelectedObject = dynamic_cast<caf::PdmObjectHandle*>(uiItems[0]);
firstSelectedObject = dynamic_cast<caf::PdmObjectHandle*>( uiItems[0] );
}
m_pdmUiPropertyView->showProperties(firstSelectedObject);
m_pdmUiPropertyView->showProperties( firstSelectedObject );
if (firstSelectedObject)
if ( firstSelectedObject )
{
RimSummaryPlot* summaryPlot = nullptr;
firstSelectedObject->firstAncestorOrThisOfType(summaryPlot);
if (summaryPlot)
firstSelectedObject->firstAncestorOrThisOfType( summaryPlot );
if ( summaryPlot )
{
updateSummaryPlotToolBar();
}
}
if (uiItems.size() == 1 && m_allowActiveViewChangeFromSelection)
if ( uiItems.size() == 1 && m_allowActiveViewChangeFromSelection )
{
// Find the reservoir view or the Plot that the selected item is within
if (!firstSelectedObject)
if ( !firstSelectedObject )
{
caf::PdmFieldHandle* selectedField = dynamic_cast<caf::PdmFieldHandle*>(uiItems[0]);
if (selectedField) firstSelectedObject = selectedField->ownerObject();
caf::PdmFieldHandle* selectedField = dynamic_cast<caf::PdmFieldHandle*>( uiItems[0] );
if ( selectedField ) firstSelectedObject = selectedField->ownerObject();
}
if (!firstSelectedObject) return;
if ( !firstSelectedObject ) return;
RimViewWindow* selectedWindow = dynamic_cast<RimViewWindow*>(firstSelectedObject);
if (!selectedWindow)
RimViewWindow* selectedWindow = dynamic_cast<RimViewWindow*>( firstSelectedObject );
if ( !selectedWindow )
{
firstSelectedObject->firstAncestorOrThisOfType(selectedWindow);
firstSelectedObject->firstAncestorOrThisOfType( selectedWindow );
}
// If we cant find the view window as an MDI sub window, we search higher in the
// project tree to find a possible parent view window that has.
if (selectedWindow && !findMdiSubWindow(selectedWindow->viewWidget()))
if ( selectedWindow && !findMdiSubWindow( selectedWindow->viewWidget() ) )
{
if (selectedWindow->parentField() && selectedWindow->parentField()->ownerObject())
if ( selectedWindow->parentField() && selectedWindow->parentField()->ownerObject() )
{
selectedWindow->parentField()->ownerObject()->firstAncestorOrThisOfType(selectedWindow);
selectedWindow->parentField()->ownerObject()->firstAncestorOrThisOfType( selectedWindow );
}
}
if (selectedWindow)
if ( selectedWindow )
{
if (selectedWindow->viewWidget())
if ( selectedWindow->viewWidget() )
{
setActiveViewer(selectedWindow->viewWidget());
setActiveViewer( selectedWindow->viewWidget() );
}
// The only way to get to this code is by selection change initiated from the project tree view
// As we are activating an MDI-window, the focus is given to this MDI-window
@@ -773,21 +773,21 @@ void RiuPlotMainWindow::selectedObjectsChanged()
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::restoreTreeViewState()
{
if (m_projectTreeView)
if ( m_projectTreeView )
{
QString stateString = RiaApplication::instance()->project()->plotWindowTreeViewState;
if (!stateString.isEmpty())
if ( !stateString.isEmpty() )
{
m_projectTreeView->treeView()->collapseAll();
caf::QTreeViewStateSerializer::applyTreeViewStateFromString(m_projectTreeView->treeView(), stateString);
caf::QTreeViewStateSerializer::applyTreeViewStateFromString( m_projectTreeView->treeView(), stateString );
}
QString currentIndexString = RiaApplication::instance()->project()->plotWindowCurrentModelIndexPath;
if (!currentIndexString.isEmpty())
if ( !currentIndexString.isEmpty() )
{
QModelIndex mi = caf::QTreeViewStateSerializer::getModelIndexFromString(m_projectTreeView->treeView()->model(),
currentIndexString);
m_projectTreeView->treeView()->setCurrentIndex(mi);
QModelIndex mi = caf::QTreeViewStateSerializer::getModelIndexFromString( m_projectTreeView->treeView()->model(),
currentIndexString );
m_projectTreeView->treeView()->setCurrentIndex( mi );
}
}
}
@@ -797,27 +797,27 @@ void RiuPlotMainWindow::restoreTreeViewState()
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::setDefaultWindowSize()
{
resize(1000, 810);
resize( 1000, 810 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::customMenuRequested(const QPoint& pos)
void RiuPlotMainWindow::customMenuRequested( const QPoint& pos )
{
QMenu menu;
RiaApplication* app = RiaApplication::instance();
app->project()->actionsBasedOnSelection(menu);
app->project()->actionsBasedOnSelection( menu );
// Qt doc: QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the viewport().
// Since we might get this signal from different treeViews, we need to map the position accordingly.
QObject* senderObj = this->sender();
QTreeView* treeView = dynamic_cast<QTreeView*>(senderObj);
if (treeView)
QTreeView* treeView = dynamic_cast<QTreeView*>( senderObj );
if ( treeView )
{
QPoint globalPos = treeView->viewport()->mapToGlobal(pos);
menu.exec(globalPos);
QPoint globalPos = treeView->viewport()->mapToGlobal( pos );
menu.exec( globalPos );
}
}
@@ -829,42 +829,42 @@ void RiuPlotMainWindow::tileSubWindows()
QMdiArea::WindowOrder currentActivationOrder = m_mdiArea->activationOrder();
std::list<QMdiSubWindow*> windowList;
for (QMdiSubWindow* subWindow : m_mdiArea->subWindowList(currentActivationOrder))
for ( QMdiSubWindow* subWindow : m_mdiArea->subWindowList( currentActivationOrder ) )
{
windowList.push_back(subWindow);
windowList.push_back( subWindow );
}
// Perform stable sort of list so we first sort by window position but retain activation order
// for windows with the same position. Needs to be sorted in decreasing order for workaround below.
windowList.sort([](const QMdiSubWindow* lhs, const QMdiSubWindow* rhs) {
windowList.sort( []( const QMdiSubWindow* lhs, const QMdiSubWindow* rhs ) {
return lhs->frameGeometry().topLeft().rx() > rhs->frameGeometry().topLeft().rx();
});
} );
// Based on workaround described here
// https://forum.qt.io/topic/50053/qmdiarea-tilesubwindows-always-places-widgets-in-activationhistoryorder-in-subwindowview-mode
QMdiSubWindow* a = m_mdiArea->activeSubWindow();
// Force activation order so they end up in the order of the loop.
m_mdiArea->setActivationOrder(QMdiArea::ActivationHistoryOrder);
for (QMdiSubWindow* subWindow : windowList)
m_mdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder );
for ( QMdiSubWindow* subWindow : windowList )
{
m_mdiArea->setActiveSubWindow(subWindow);
m_mdiArea->setActiveSubWindow( subWindow );
}
m_mdiArea->tileSubWindows();
// Set back the original activation order to avoid messing with the standard ordering
m_mdiArea->setActivationOrder(currentActivationOrder);
m_mdiArea->setActiveSubWindow(a);
m_mdiArea->setActivationOrder( currentActivationOrder );
m_mdiArea->setActiveSubWindow( a );
storeSubWindowTiling(true);
storeSubWindowTiling( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::storeSubWindowTiling(bool tiled)
void RiuPlotMainWindow::storeSubWindowTiling( bool tiled )
{
RiaApplication::instance()->project()->setSubWindowsTiledInPlotWindow(tiled);
RiaApplication::instance()->project()->setSubWindowsTiledInPlotWindow( tiled );
refreshToolbars();
}
@@ -875,12 +875,12 @@ void RiuPlotMainWindow::clearWindowTiling()
{
QMdiArea::WindowOrder currentActivationOrder = m_mdiArea->activationOrder();
for (QMdiSubWindow* subWindow : m_mdiArea->subWindowList(currentActivationOrder))
for ( QMdiSubWindow* subWindow : m_mdiArea->subWindowList( currentActivationOrder ) )
{
subWindow->hide();
subWindow->showNormal();
}
storeSubWindowTiling(false);
storeSubWindowTiling( false );
}
//--------------------------------------------------------------------------------------------------
@@ -888,7 +888,7 @@ void RiuPlotMainWindow::clearWindowTiling()
//--------------------------------------------------------------------------------------------------
bool RiuPlotMainWindow::subWindowsAreTiled() const
{
if (RiaApplication::instance()->project())
if ( RiaApplication::instance()->project() )
{
return RiaApplication::instance()->project()->subWindowsTiledPlotWindow();
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -21,8 +21,8 @@
#include "RiuMainWindowBase.h"
#include "RiuMdiArea.h"
#include "cafPdmUiDragDropInterface.h"
#include "cafPdmPointer.h"
#include "cafPdmUiDragDropInterface.h"
#include <memory>
@@ -35,16 +35,16 @@ class RimViewWindow;
namespace caf
{
class PdmUiTreeView;
class PdmObject;
class PdmUiPropertyView;
class PdmUiItem;
class PdmUiToolBarEditor;
}
class PdmUiTreeView;
class PdmObject;
class PdmUiPropertyView;
class PdmUiItem;
class PdmUiToolBarEditor;
} // namespace caf
//==================================================================================================
//
//
//
//
//==================================================================================================
class RiuPlotMainWindow : public RiuMainWindowBase
@@ -53,74 +53,74 @@ class RiuPlotMainWindow : public RiuMainWindowBase
public:
RiuPlotMainWindow();
QString mainWindowName() override;
void initializeGuiNewProjectLoaded();
void cleanupGuiBeforeProjectClose();
void cleanUpTemporaryWidgets();
void removeViewer( QWidget* viewer ) override;
void addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry) override;
void setActiveViewer(QWidget* subWindow) override;
QString mainWindowName() override;
void setDefaultWindowSize();
void initializeGuiNewProjectLoaded();
void cleanupGuiBeforeProjectClose();
void cleanUpTemporaryWidgets();
void tileSubWindows() override;
void storeSubWindowTiling(bool tiled) override;
void clearWindowTiling() override;
bool subWindowsAreTiled() const override;
void removeViewer( QWidget* viewer ) override;
void addViewer( QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry ) override;
void setActiveViewer( QWidget* subWindow ) override;
bool isAnyMdiSubWindowVisible();
QMdiSubWindow* findMdiSubWindow(QWidget* viewer) override;
QList<QMdiSubWindow*> subWindowList(QMdiArea::WindowOrder order);
void setDefaultWindowSize();
void setWidthOfMdiWindow(QWidget* mdiWindowWidget, int newWidth);
void addToTemporaryWidgets(QWidget* widget);
void tileSubWindows() override;
void storeSubWindowTiling( bool tiled ) override;
void clearWindowTiling() override;
bool subWindowsAreTiled() const override;
void updateWellLogPlotToolBar();
void updateSummaryPlotToolBar(bool forceUpdateUi = false);
bool isAnyMdiSubWindowVisible();
QMdiSubWindow* findMdiSubWindow( QWidget* viewer ) override;
QList<QMdiSubWindow*> subWindowList( QMdiArea::WindowOrder order );
void setWidthOfMdiWindow( QWidget* mdiWindowWidget, int newWidth );
void addToTemporaryWidgets( QWidget* widget );
void updateWellLogPlotToolBar();
void updateSummaryPlotToolBar( bool forceUpdateUi = false );
protected:
void closeEvent(QCloseEvent* event) override;
void closeEvent( QCloseEvent* event ) override;
private:
void setPdmRoot(caf::PdmObject* pdmRoot);
void setPdmRoot( caf::PdmObject* pdmRoot );
void createMenus();
void createToolBars();
void createDockPanels();
void createMenus();
void createToolBars();
void createDockPanels();
void restoreTreeViewState();
void restoreTreeViewState();
void refreshToolbars();
static QStringList toolbarCommandIds(const QString& toolbarName = "");
void refreshToolbars();
static QStringList toolbarCommandIds( const QString& toolbarName = "" );
private slots:
friend class RiuMdiSubWindow;
void slotBuildWindowActions();
void slotBuildWindowActions();
void slotSubWindowActivated(QMdiSubWindow* subWindow);
void slotSubWindowActivated( QMdiSubWindow* subWindow );
void selectedObjectsChanged();
void customMenuRequested(const QPoint& pos);
void selectedObjectsChanged();
void customMenuRequested( const QPoint& pos );
private:
QByteArray m_initialDockAndToolbarLayout; // Initial dock window and toolbar layout, used to reset GUI
QByteArray m_initialDockAndToolbarLayout; // Initial dock window and toolbar layout, used to reset GUI
RiuMdiArea* m_mdiArea;
caf::PdmPointer<RimViewWindow> m_activePlotViewWindow;
RiuMdiArea* m_mdiArea;
caf::PdmPointer<RimViewWindow> m_activePlotViewWindow;
QMenu* m_windowMenu;
QMenu* m_windowMenu;
caf::PdmUiToolBarEditor* m_wellLogPlotToolBarEditor;
caf::PdmUiToolBarEditor* m_summaryPlotToolBarEditor;
caf::PdmUiToolBarEditor* m_wellLogPlotToolBarEditor;
caf::PdmUiToolBarEditor* m_summaryPlotToolBarEditor;
std::unique_ptr<caf::PdmUiDragDropInterface> m_dragDropInterface;
caf::PdmUiPropertyView* m_pdmUiPropertyView;
std::vector<QWidget*> m_temporaryWidgets;
caf::PdmUiPropertyView* m_pdmUiPropertyView;
std::vector<QWidget*> m_temporaryWidgets;
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -21,70 +21,68 @@
#include "RiuPlotMainWindow.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::showPlotMainWindow()
{
if (RiaGuiApplication::isRunning())
if ( RiaGuiApplication::isRunning() )
{
RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow();
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::setActiveViewer(QWidget* subWindow)
void RiuPlotMainWindowTools::setActiveViewer( QWidget* subWindow )
{
if (RiaGuiApplication::isRunning())
if ( RiaGuiApplication::isRunning() )
{
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
if (mpw) mpw->setActiveViewer(subWindow);
if ( mpw ) mpw->setActiveViewer( subWindow );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::setExpanded(const caf::PdmUiItem* uiItem, bool expanded /*= true*/)
void RiuPlotMainWindowTools::setExpanded( const caf::PdmUiItem* uiItem, bool expanded /*= true*/ )
{
if (RiaGuiApplication::isRunning())
if ( RiaGuiApplication::isRunning() )
{
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
if (mpw) mpw->setExpanded(uiItem, expanded);
if ( mpw ) mpw->setExpanded( uiItem, expanded );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange /*= true*/)
void RiuPlotMainWindowTools::selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange /*= true*/ )
{
if (RiaGuiApplication::isRunning())
if ( RiaGuiApplication::isRunning() )
{
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
if (mpw) mpw->selectAsCurrentItem(object, allowActiveViewChange);
if ( mpw ) mpw->selectAsCurrentItem( object, allowActiveViewChange );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindowTools::refreshToolbars()
{
if (RiaGuiApplication::isRunning())
if ( RiaGuiApplication::isRunning() )
{
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
if (mpw)
if ( mpw )
{
mpw->updateSummaryPlotToolBar();
mpw->updateWellLogPlotToolBar();
}
}
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -20,19 +20,18 @@
class QWidget;
namespace caf
namespace caf
{
class PdmUiItem;
class PdmObject;
}
class PdmUiItem;
class PdmObject;
} // namespace caf
class RiuPlotMainWindowTools
{
public:
static void showPlotMainWindow();
static void setActiveViewer(QWidget* subWindow) ;
static void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true);
static void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true);
static void refreshToolbars();
static void showPlotMainWindow();
static void setActiveViewer( QWidget* subWindow );
static void setExpanded( const caf::PdmUiItem* uiItem, bool expanded = true );
static void selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange = true );
static void refreshToolbars();
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -23,45 +23,43 @@
#include <QMouseEvent>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuPlotObjectPicker::RiuPlotObjectPicker(QWidget* widget, caf::PdmObject* associatedObject) :
QObject(widget),
m_associatedObject(associatedObject)
RiuPlotObjectPicker::RiuPlotObjectPicker( QWidget* widget, caf::PdmObject* associatedObject )
: QObject( widget )
, m_associatedObject( associatedObject )
{
widget->installEventFilter(this);
widget->installEventFilter( this );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuPlotObjectPicker::eventFilter(QObject* watchedObject, QEvent* event)
bool RiuPlotObjectPicker::eventFilter( QObject* watchedObject, QEvent* event )
{
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
if (mainPlotWindow && m_associatedObject.notNull())
if ( mainPlotWindow && m_associatedObject.notNull() )
{
if (event->type() == QEvent::MouseButtonPress)
if ( event->type() == QEvent::MouseButtonPress )
{
QMouseEvent* me = static_cast<QMouseEvent*>(event);
if (me->button() == Qt::RightButton)
QMouseEvent* me = static_cast<QMouseEvent*>( event );
if ( me->button() == Qt::RightButton )
{
mainPlotWindow->selectAsCurrentItem(m_associatedObject);
mainPlotWindow->selectAsCurrentItem( m_associatedObject );
}
}
else if (event->type() == QEvent::MouseButtonRelease)
else if ( event->type() == QEvent::MouseButtonRelease )
{
QMouseEvent* me = static_cast<QMouseEvent*>(event);
if (me->button() == Qt::LeftButton)
QMouseEvent* me = static_cast<QMouseEvent*>( event );
if ( me->button() == Qt::LeftButton )
{
mainPlotWindow->selectAsCurrentItem(m_associatedObject);
mainPlotWindow->selectAsCurrentItem( m_associatedObject );
return true;
}
}
}
// standard event processing
return QObject::eventFilter(watchedObject, event);
return QObject::eventFilter( watchedObject, event );
}

View File

@@ -1,48 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmPointer.h"
#include <QObject>
namespace caf {
class PdmObject;
namespace caf
{
class PdmObject;
}
class QEvent;
class QWidget;
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
class RiuPlotObjectPicker : public QObject
{
public:
explicit RiuPlotObjectPicker(QWidget* widget, caf::PdmObject* associatedObject);
explicit RiuPlotObjectPicker( QWidget* widget, caf::PdmObject* associatedObject );
protected:
bool eventFilter(QObject* watched, QEvent* event) override;
bool eventFilter( QObject* watched, QEvent* event ) override;
private:
caf::PdmPointer<caf::PdmObject> m_associatedObject;
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -22,189 +22,184 @@
#include "cafUiProcess.h"
#include <QWidget>
#include <QLabel>
#include <QDockWidget>
#include <QHBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QPlainTextEdit>
#include <QPushButton>
#include <QWidget>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuProcessMonitor::RiuProcessMonitor(QDockWidget* pParent)
: QWidget(pParent)
RiuProcessMonitor::RiuProcessMonitor( QDockWidget* pParent )
: QWidget( pParent )
{
m_monitoredProcess = nullptr;
QLabel* pLabel = new QLabel("Status:", this);
pLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
m_labelStatus = new QLabel(this);
QLabel* pLabel = new QLabel( "Status:", this );
pLabel->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum );
m_labelStatus = new QLabel( this );
QHBoxLayout* pTopLayout = new QHBoxLayout;
pTopLayout->addWidget(pLabel);
pTopLayout->addWidget(m_labelStatus);
pTopLayout->addWidget( pLabel );
pTopLayout->addWidget( m_labelStatus );
pTopLayout->addStretch();
QPushButton* clearPushButton = new QPushButton("Clear", this);
pTopLayout->addWidget(clearPushButton);
connect(clearPushButton, SIGNAL(clicked()), this, SLOT(slotClearTextEdit()) );
QPushButton* clearPushButton = new QPushButton( "Clear", this );
pTopLayout->addWidget( clearPushButton );
connect( clearPushButton, SIGNAL( clicked() ), this, SLOT( slotClearTextEdit() ) );
m_terminatePushButton = new QPushButton("Stop", this);
pTopLayout->addWidget(m_terminatePushButton);
connect(m_terminatePushButton, SIGNAL(clicked()), this, SLOT(slotTerminateProcess()) );
m_terminatePushButton->setEnabled(false);
m_terminatePushButton = new QPushButton( "Stop", this );
pTopLayout->addWidget( m_terminatePushButton );
connect( m_terminatePushButton, SIGNAL( clicked() ), this, SLOT( slotTerminateProcess() ) );
m_terminatePushButton->setEnabled( false );
m_textEdit = new QPlainTextEdit(this);
m_textEdit->setReadOnly(true);
m_textEdit->setLineWrapMode(QPlainTextEdit::NoWrap);
m_textEdit = new QPlainTextEdit( this );
m_textEdit->setReadOnly( true );
m_textEdit->setLineWrapMode( QPlainTextEdit::NoWrap );
QVBoxLayout* pLayout = new QVBoxLayout();
pLayout->addLayout(pTopLayout);
pLayout->addWidget(m_textEdit);
pLayout->addLayout( pTopLayout );
pLayout->addWidget( m_textEdit );
pLayout->setContentsMargins(0, 0, 0, 0);
pLayout->setContentsMargins( 0, 0, 0, 0 );
setLayout(pLayout);
setLayout( pLayout );
setStatusMsg("N/A", caf::PROCESS_STATE_NORMAL);
setStatusMsg( "N/A", caf::PROCESS_STATE_NORMAL );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuProcessMonitor::~RiuProcessMonitor() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuProcessMonitor::~RiuProcessMonitor()
void RiuProcessMonitor::startMonitorWorkProcess( caf::UiProcess* pProcess )
{
setStatusMsg( "N/A", caf::PROCESS_STATE_NORMAL );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuProcessMonitor::startMonitorWorkProcess(caf::UiProcess* pProcess)
{
setStatusMsg("N/A", caf::PROCESS_STATE_NORMAL);
if (m_monitoredProcess == pProcess) return;
if ( m_monitoredProcess == pProcess ) return;
m_monitoredProcess = pProcess;
if (!m_monitoredProcess) return;
if ( !m_monitoredProcess ) return;
connect(m_monitoredProcess, SIGNAL(signalStatusMsg(const QString&, int)), SLOT(slotShowProcStatusMsg(const QString&, int)));
connect(m_monitoredProcess, SIGNAL(readyReadStandardError()), SLOT(slotProcReadyReadStdErr()));
connect(m_monitoredProcess, SIGNAL(readyReadStandardOutput()), SLOT(slotProcReadyReadStdOut()));
connect( m_monitoredProcess,
SIGNAL( signalStatusMsg( const QString&, int ) ),
SLOT( slotShowProcStatusMsg( const QString&, int ) ) );
connect( m_monitoredProcess, SIGNAL( readyReadStandardError() ), SLOT( slotProcReadyReadStdErr() ) );
connect( m_monitoredProcess, SIGNAL( readyReadStandardOutput() ), SLOT( slotProcReadyReadStdOut() ) );
m_terminatePushButton->setEnabled(true);
m_terminatePushButton->setEnabled( true );
QString timeStamp = QTime::currentTime().toString("hh:mm:ss");
addStringToLog(timeStamp + " Process starting\n");
QString timeStamp = QTime::currentTime().toString( "hh:mm:ss" );
addStringToLog( timeStamp + " Process starting\n" );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuProcessMonitor::stopMonitorWorkProcess()
{
m_monitoredProcess = nullptr;
m_terminatePushButton->setEnabled(false);
m_terminatePushButton->setEnabled( false );
setStatusMsg("N/A", caf::PROCESS_STATE_NORMAL);
setStatusMsg( "N/A", caf::PROCESS_STATE_NORMAL );
QString timeStamp = QTime::currentTime().toString("hh:mm:ss");
addStringToLog(timeStamp + " Process finished\n\n");
QString timeStamp = QTime::currentTime().toString( "hh:mm:ss" );
addStringToLog( timeStamp + " Process finished\n\n" );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuProcessMonitor::setStatusMsg(const QString& sStatusMsg, int iStatusMsgType)
void RiuProcessMonitor::setStatusMsg( const QString& sStatusMsg, int iStatusMsgType )
{
if (!m_labelStatus) return;
if ( !m_labelStatus ) return;
QString sMsg;
switch (iStatusMsgType)
switch ( iStatusMsgType )
{
case caf::PROCESS_STATE_RUNNING: sMsg = "<font color='green'>" + sStatusMsg + "</font>"; break;
case caf::PROCESS_STATE_ERROR: sMsg = "<font color='red'>" + sStatusMsg + "</font>"; break;
default: sMsg = sStatusMsg;
case caf::PROCESS_STATE_RUNNING:
sMsg = "<font color='green'>" + sStatusMsg + "</font>";
break;
case caf::PROCESS_STATE_ERROR:
sMsg = "<font color='red'>" + sStatusMsg + "</font>";
break;
default:
sMsg = sStatusMsg;
}
m_labelStatus->setText(sMsg);
m_labelStatus->setText( sMsg );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuProcessMonitor::addStringToLog(const QString& sTxt)
void RiuProcessMonitor::addStringToLog( const QString& sTxt )
{
m_textEdit->moveCursor(QTextCursor::End);
m_textEdit->insertPlainText(sTxt);
m_textEdit->moveCursor( QTextCursor::End );
m_textEdit->insertPlainText( sTxt );
m_textEdit->ensureCursorVisible();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuProcessMonitor::slotShowProcStatusMsg(const QString& sMsg, int iStatusMsgType)
void RiuProcessMonitor::slotShowProcStatusMsg( const QString& sMsg, int iStatusMsgType )
{
setStatusMsg(sMsg, iStatusMsgType);
setStatusMsg( sMsg, iStatusMsgType );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuProcessMonitor::slotProcReadyReadStdOut()
{
if (!m_monitoredProcess) return;
if ( !m_monitoredProcess ) return;
QByteArray dataArray = m_monitoredProcess->readAllStandardOutput();
dataArray.replace("\r", "");
dataArray.replace( "\r", "" );
addStringToLog(dataArray.data());
addStringToLog( dataArray.data() );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuProcessMonitor::slotProcReadyReadStdErr()
{
if (!m_monitoredProcess) return;
if ( !m_monitoredProcess ) return;
QByteArray dataArray = m_monitoredProcess->readAllStandardError();
dataArray.replace("\r", "");
dataArray.replace( "\r", "" );
addStringToLog(dataArray.data());
addStringToLog( dataArray.data() );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuProcessMonitor::slotTerminateProcess()
{
addStringToLog("Process terminated by user\n");
addStringToLog( "Process terminated by user\n" );
RiaApplication* app = RiaApplication::instance();
app->terminateProcess();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuProcessMonitor::slotClearTextEdit()
{
m_textEdit->clear();
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -27,43 +27,41 @@ class QPushButton;
namespace caf
{
class UiProcess;
class UiProcess;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
class RiuProcessMonitor : public QWidget
{
Q_OBJECT
private:
QLabel* m_labelStatus; // Shows current status string
QPlainTextEdit* m_textEdit; // Showing the textual output from the process
QLabel* m_labelStatus; // Shows current status string
QPlainTextEdit* m_textEdit; // Showing the textual output from the process
QPushButton* m_terminatePushButton;
caf::UiProcess* m_monitoredProcess; // Pointer to the process we're monitoring. Needed to fetch text
caf::UiProcess* m_monitoredProcess; // Pointer to the process we're monitoring. Needed to fetch text
public:
explicit RiuProcessMonitor(QDockWidget* pParent);
explicit RiuProcessMonitor( QDockWidget* pParent );
~RiuProcessMonitor() override;
void startMonitorWorkProcess(caf::UiProcess* process);
void stopMonitorWorkProcess();
void startMonitorWorkProcess( caf::UiProcess* process );
void stopMonitorWorkProcess();
void addStringToLog(const QString& text);
void addStringToLog( const QString& text );
public slots:
void slotClearTextEdit();
void slotClearTextEdit();
private:
void setStatusMsg(const QString& status, int messageType);
void setStatusMsg( const QString& status, int messageType );
private slots:
void slotShowProcStatusMsg(const QString& message, int messageType);
void slotProcReadyReadStdOut();
void slotProcReadyReadStdErr();
void slotTerminateProcess();
void slotShowProcStatusMsg( const QString& message, int messageType );
void slotProcReadyReadStdOut();
void slotProcReadyReadStdErr();
void slotTerminateProcess();
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -31,75 +31,81 @@
#include <QVBoxLayout>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuProjectAndPropertyView::RiuProjectAndPropertyView(QWidget* parent, Qt::WindowFlags f)
: QWidget(parent, f)
RiuProjectAndPropertyView::RiuProjectAndPropertyView( QWidget* parent, Qt::WindowFlags f )
: QWidget( parent, f )
{
// Tree View
m_projectTreeView = new caf::PdmUiTreeView;
m_projectTreeView->treeView()->setHeaderHidden(true);
m_projectTreeView->treeView()->setSelectionMode(QAbstractItemView::ExtendedSelection);
m_projectTreeView->enableSelectionManagerUpdating(true);
m_projectTreeView->treeView()->setHeaderHidden( true );
m_projectTreeView->treeView()->setSelectionMode( QAbstractItemView::ExtendedSelection );
m_projectTreeView->enableSelectionManagerUpdating( true );
// Install event filter used to handle key press events
RiuTreeViewEventFilter* treeViewEventFilter = new RiuTreeViewEventFilter(this);
m_projectTreeView->treeView()->installEventFilter(treeViewEventFilter);
RiuTreeViewEventFilter* treeViewEventFilter = new RiuTreeViewEventFilter( this );
m_projectTreeView->treeView()->installEventFilter( treeViewEventFilter );
// Drag and drop configuration
m_projectTreeView->treeView()->setDragEnabled(true);
m_projectTreeView->treeView()->viewport()->setAcceptDrops(true);
m_projectTreeView->treeView()->setDropIndicatorShown(true);
m_projectTreeView->treeView()->setDragDropMode(QAbstractItemView::DragDrop);
m_projectTreeView->treeView()->setDragEnabled( true );
m_projectTreeView->treeView()->viewport()->setAcceptDrops( true );
m_projectTreeView->treeView()->setDropIndicatorShown( true );
m_projectTreeView->treeView()->setDragDropMode( QAbstractItemView::DragDrop );
m_projectTreeView->treeView()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_projectTreeView->treeView(), SIGNAL(customContextMenuRequested(const QPoint&)), RiuMainWindow::instance(), SLOT(customMenuRequested(const QPoint&)));
m_projectTreeView->treeView()->setContextMenuPolicy( Qt::CustomContextMenu );
connect( m_projectTreeView->treeView(),
SIGNAL( customContextMenuRequested( const QPoint& ) ),
RiuMainWindow::instance(),
SLOT( customMenuRequested( const QPoint& ) ) );
// Property view
m_propertyView = new caf::PdmUiPropertyView;
connect(m_projectTreeView, SIGNAL(selectedObjectChanged(caf::PdmObjectHandle*)), m_propertyView, SLOT(showProperties(caf::PdmObjectHandle*)));
connect( m_projectTreeView,
SIGNAL( selectedObjectChanged( caf::PdmObjectHandle* ) ),
m_propertyView,
SLOT( showProperties( caf::PdmObjectHandle* ) ) );
QWidget* propertyEditorWithHeader = new QWidget;
{
QLabel* propertyHeader = new QLabel;
propertyHeader->setText("Property Editor");
propertyHeader->setStyleSheet("QLabel { background-color: #CCCCCC }");
propertyHeader->setFixedHeight(20);
propertyHeader->setText( "Property Editor" );
propertyHeader->setStyleSheet( "QLabel { background-color: #CCCCCC }" );
propertyHeader->setFixedHeight( 20 );
QVBoxLayout* layout = new QVBoxLayout;
layout->setMargin(0);
layout->addWidget(propertyHeader);
layout->addWidget(m_propertyView);
layout->setMargin( 0 );
layout->addWidget( propertyHeader );
layout->addWidget( m_propertyView );
propertyEditorWithHeader->setLayout(layout);
propertyEditorWithHeader->setMinimumHeight(150);
propertyEditorWithHeader->setLayout( layout );
propertyEditorWithHeader->setMinimumHeight( 150 );
}
QSplitter* splitter = new QSplitter(Qt::Vertical);
splitter->addWidget(m_projectTreeView);
splitter->addWidget(propertyEditorWithHeader);
QSplitter* splitter = new QSplitter( Qt::Vertical );
splitter->addWidget( m_projectTreeView );
splitter->addWidget( propertyEditorWithHeader );
QVBoxLayout* layout = new QVBoxLayout;
layout->setMargin(0);
layout->addWidget(splitter);
layout->setMargin( 0 );
layout->addWidget( splitter );
setLayout(layout);
setLayout( layout );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuProjectAndPropertyView::setPdmItem(caf::PdmUiItem* object)
void RiuProjectAndPropertyView::setPdmItem( caf::PdmUiItem* object )
{
m_propertyView->showProperties(nullptr);
m_projectTreeView->setPdmItem(object);
m_propertyView->showProperties( nullptr );
m_projectTreeView->setPdmItem( object );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuProjectAndPropertyView::showProperties(caf::PdmObjectHandle* object)
void RiuProjectAndPropertyView::showProperties( caf::PdmObjectHandle* object )
{
m_propertyView->showProperties(object);
m_propertyView->showProperties( object );
}

View File

@@ -2,41 +2,41 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QWidget>
namespace caf {
class PdmUiItem;
class PdmUiTreeView;
class PdmUiPropertyView;
class PdmObjectHandle;
}
namespace caf
{
class PdmUiItem;
class PdmUiTreeView;
class PdmUiPropertyView;
class PdmObjectHandle;
} // namespace caf
//--------------------------------------------------------------------------------------------------
class RiuProjectAndPropertyView : public QWidget
{
public:
RiuProjectAndPropertyView(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr);
RiuProjectAndPropertyView( QWidget* parent = nullptr, Qt::WindowFlags f = nullptr );
void setPdmItem(caf::PdmUiItem* object);
void showProperties(caf::PdmObjectHandle* object);
void setPdmItem( caf::PdmUiItem* object );
void showProperties( caf::PdmObjectHandle* object );
private:
caf::PdmUiTreeView* m_projectTreeView;

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -22,63 +22,65 @@
#include "cafPdmUiPropertyView.h"
#include <QBoxLayout>
#include <QDebug>
#include <QDialogButtonBox>
#include <QStringList>
#include <QTabWidget>
#include <QWidget>
#include <QDebug>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuPropertyViewTabWidget::RiuPropertyViewTabWidget(QWidget* parent, caf::PdmObject* object, const QString& windowTitle, const QStringList& uiConfigNameForTabs)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
RiuPropertyViewTabWidget::RiuPropertyViewTabWidget( QWidget* parent,
caf::PdmObject* object,
const QString& windowTitle,
const QStringList& uiConfigNameForTabs )
: QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
{
setWindowTitle(windowTitle);
setWindowTitle( windowTitle );
QTabWidget* tabWidget = new QTabWidget;
for (int i = 0; i < uiConfigNameForTabs.size(); i++)
for ( int i = 0; i < uiConfigNameForTabs.size(); i++ )
{
QHBoxLayout* widgetLayout = new QHBoxLayout;
widgetLayout->setContentsMargins(0, 0, 0, 0);
widgetLayout->setContentsMargins( 0, 0, 0, 0 );
QWidget* containerWidget = new QWidget;
containerWidget->setLayout(widgetLayout);
containerWidget->setLayout( widgetLayout );
caf::PdmUiPropertyView* pdmUiPropertyView = new caf::PdmUiPropertyView();
pdmUiPropertyView->setUiConfigurationName(uiConfigNameForTabs[i]);
pdmUiPropertyView->setUiConfigurationName( uiConfigNameForTabs[i] );
widgetLayout->addWidget(pdmUiPropertyView);
widgetLayout->addWidget( pdmUiPropertyView );
tabWidget->addTab(containerWidget, uiConfigNameForTabs[i]);
pdmUiPropertyView->showProperties(object);
tabWidget->addTab( containerWidget, uiConfigNameForTabs[i] );
pdmUiPropertyView->showProperties( object );
m_pageWidgets.push_back(pdmUiPropertyView);
m_pageWidgets.push_back( pdmUiPropertyView );
}
QVBoxLayout* dialogLayout = new QVBoxLayout;
setLayout(dialogLayout);
setLayout( dialogLayout );
dialogLayout->addWidget(tabWidget);
dialogLayout->addWidget( tabWidget );
// Buttons
m_dialogButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(m_dialogButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(m_dialogButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
dialogLayout->addWidget(m_dialogButtonBox);
m_dialogButtonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
connect( m_dialogButtonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
connect( m_dialogButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
dialogLayout->addWidget( m_dialogButtonBox );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuPropertyViewTabWidget::~RiuPropertyViewTabWidget()
{
for (auto w : m_pageWidgets)
for ( auto w : m_pageWidgets )
{
w->showProperties(nullptr);
w->showProperties( nullptr );
}
}
@@ -87,35 +89,34 @@ RiuPropertyViewTabWidget::~RiuPropertyViewTabWidget()
//--------------------------------------------------------------------------------------------------
QSize RiuPropertyViewTabWidget::minimumSizeHint() const
{
QSize maxSizeHint(0, 0);
QSize maxSizeHint( 0, 0 );
for (auto w : m_pageWidgets)
for ( auto w : m_pageWidgets )
{
QSize pageSize = w->minimumSizeHint();
pageSize += QSize(0, 100);
pageSize += QSize( 0, 100 );
maxSizeHint = maxSizeHint.expandedTo(pageSize);
maxSizeHint = maxSizeHint.expandedTo( pageSize );
}
return maxSizeHint;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QSize RiuPropertyViewTabWidget::sizeHint() const
{
QSize maxSizeHint(0, 0);
QSize maxSizeHint( 0, 0 );
for (auto w : m_pageWidgets)
for ( auto w : m_pageWidgets )
{
//qDebug() << "tab size hint" << w->sizeHint();
// qDebug() << "tab size hint" << w->sizeHint();
QSize pageSize = w->sizeHint();
pageSize += QSize(0, 100);
pageSize += QSize( 0, 100 );
maxSizeHint = maxSizeHint.expandedTo(pageSize);
maxSizeHint = maxSizeHint.expandedTo( pageSize );
}
return maxSizeHint;

View File

@@ -1,30 +1,30 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QDialog>
namespace caf {
class PdmObject;
class PdmUiPropertyView;
}
namespace caf
{
class PdmObject;
class PdmUiPropertyView;
} // namespace caf
class QDialogButtonBox;
class QWidget;
@@ -34,12 +34,16 @@ class QStringList;
class RiuPropertyViewTabWidget : public QDialog
{
public:
RiuPropertyViewTabWidget(QWidget* parent, caf::PdmObject* object, const QString& windowTitle, const QStringList& uiConfigNameForTabs);
RiuPropertyViewTabWidget( QWidget* parent,
caf::PdmObject* object,
const QString& windowTitle,
const QStringList& uiConfigNameForTabs );
~RiuPropertyViewTabWidget() override;
QSize minimumSizeHint() const override;
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
QSize sizeHint() const override;
QDialogButtonBox* dialogButtonBox();
private:
std::vector<caf::PdmUiPropertyView*> m_pageWidgets;
QDialogButtonBox* m_dialogButtonBox;

File diff suppressed because it is too large Load Diff

View File

@@ -1,28 +1,28 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RigFlowDiagSolverInterface.h"
#include "RiaEclipseUnitTools.h"
#include "RigFlowDiagSolverInterface.h"
#include <QWidget>
#include <QPointer>
#include <QWidget>
#include <cmath>
#include <memory>
@@ -40,9 +40,6 @@ class QwtPlot;
class QwtPlotMarker;
class QwtPlotCurve;
// Interface for providing our custom picker with a tracker text
class RiuPvtTrackerTextProvider
{
@@ -50,7 +47,6 @@ public:
virtual QString trackerText() const = 0;
};
//==================================================================================================
//
//
@@ -61,35 +57,40 @@ class RiuPvtPlotWidget : public QWidget, public RiuPvtTrackerTextProvider
Q_OBJECT
public:
RiuPvtPlotWidget(RiuPvtPlotPanel* parent);
RiuPvtPlotWidget( RiuPvtPlotPanel* parent );
void plotCurves(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& curveArr, double pressure, double pointMarkerYValue, QString pointMarkerLabel, QString plotTitle, QString yAxisTitle);
void applyFontSizes(bool replot);
void plotCurves( RiaEclipseUnitTools::UnitSystem unitSystem,
const std::vector<RigFlowDiagSolverInterface::PvtCurve>& curveArr,
double pressure,
double pointMarkerYValue,
QString pointMarkerLabel,
QString plotTitle,
QString yAxisTitle );
void applyFontSizes( bool replot );
private:
static void setPlotDefaults(QwtPlot* plot);
const QwtPlotCurve* closestCurveSample(const QPoint& cursorPosition, int* closestSampleIndex) const;
size_t indexOfQwtCurve(const QwtPlotCurve* qwtCurve) const;
void updateTrackerPlotMarkerAndLabelFromPicker();
static void setPlotDefaults( QwtPlot* plot );
const QwtPlotCurve* closestCurveSample( const QPoint& cursorPosition, int* closestSampleIndex ) const;
size_t indexOfQwtCurve( const QwtPlotCurve* qwtCurve ) const;
void updateTrackerPlotMarkerAndLabelFromPicker();
QString trackerText() const override;
private slots:
void slotPickerActivated(bool);
void slotPickerPointChanged(const QPoint& pt);
private slots:
void slotPickerActivated( bool );
void slotPickerPointChanged( const QPoint& pt );
private:
QPointer<RiuDockedQwtPlot> m_qwtPlot;
QPointer<RiuDockedQwtPlot> m_qwtPlot;
std::vector<RigFlowDiagSolverInterface::PvtCurve> m_pvtCurveArr; // Array of source Pvt curves currently being plotted
std::vector<const QwtPlotCurve*> m_qwtCurveArr; // Array of corresponding qwt curves used for mapping to Pvt curve when doing tracking
std::vector<RigFlowDiagSolverInterface::PvtCurve> m_pvtCurveArr; // Array of source Pvt curves currently being plotted
std::vector<const QwtPlotCurve*>
m_qwtCurveArr; // Array of corresponding qwt curves used for mapping to Pvt curve when doing tracking
QPointer<RiuPvtQwtPicker> m_qwtPicker;
QString m_trackerLabel;
QwtPlotMarker* m_trackerPlotMarker;
QPointer<RiuPvtQwtPicker> m_qwtPicker;
QString m_trackerLabel;
QwtPlotMarker* m_trackerPlotMarker;
};
//==================================================================================================
//
//
@@ -103,8 +104,8 @@ public:
struct CellValues
{
double pressure = HUGE_VAL;
double rs = HUGE_VAL;
double rv = HUGE_VAL;
double rs = HUGE_VAL;
double rv = HUGE_VAL;
};
struct FvfDynProps
@@ -120,37 +121,42 @@ public:
};
public:
RiuPvtPlotPanel(QDockWidget* parent);
RiuPvtPlotPanel( QDockWidget* parent );
~RiuPvtPlotPanel() override;
void setPlotData(RiaEclipseUnitTools::UnitSystem unitSystem, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& fvfCurveArr, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& viscosityCurveArr, FvfDynProps fvfDynProps, ViscosityDynProps viscosityDynProps, CellValues cellValues, QString cellReferenceText);
void clearPlot();
RiuPvtPlotUpdater* plotUpdater();
void applyFontSizes(bool replot);
void setPlotData( RiaEclipseUnitTools::UnitSystem unitSystem,
const std::vector<RigFlowDiagSolverInterface::PvtCurve>& fvfCurveArr,
const std::vector<RigFlowDiagSolverInterface::PvtCurve>& viscosityCurveArr,
FvfDynProps fvfDynProps,
ViscosityDynProps viscosityDynProps,
CellValues cellValues,
QString cellReferenceText );
void clearPlot();
RiuPvtPlotUpdater* plotUpdater();
void applyFontSizes( bool replot );
private:
void plotUiSelectedCurves();
static QString unitLabelFromCurveIdent(RiaEclipseUnitTools::UnitSystem unitSystem, RigFlowDiagSolverInterface::PvtCurve::Ident curveIdent);
void plotUiSelectedCurves();
static QString unitLabelFromCurveIdent( RiaEclipseUnitTools::UnitSystem unitSystem,
RigFlowDiagSolverInterface::PvtCurve::Ident curveIdent );
private slots:
void slotPhaseComboCurrentIndexChanged(int);
void slotPhaseComboCurrentIndexChanged( int );
private:
RiaEclipseUnitTools::UnitSystem m_unitSystem;
std::vector<RigFlowDiagSolverInterface::PvtCurve> m_allFvfCurvesArr;
std::vector<RigFlowDiagSolverInterface::PvtCurve> m_allViscosityCurvesArr;
FvfDynProps m_fvfDynProps;
ViscosityDynProps m_viscosityDynProps;
CellValues m_cellValues;
QString m_cellReferenceText;
RiaEclipseUnitTools::UnitSystem m_unitSystem;
std::vector<RigFlowDiagSolverInterface::PvtCurve> m_allFvfCurvesArr;
std::vector<RigFlowDiagSolverInterface::PvtCurve> m_allViscosityCurvesArr;
FvfDynProps m_fvfDynProps;
ViscosityDynProps m_viscosityDynProps;
CellValues m_cellValues;
QString m_cellReferenceText;
QComboBox* m_phaseComboBox;
QLabel* m_titleLabel;
QComboBox* m_phaseComboBox;
QLabel* m_titleLabel;
RiuPvtPlotWidget* m_fvfPlot;
RiuPvtPlotWidget* m_viscosityPlot;
RiuPvtPlotWidget* m_fvfPlot;
RiuPvtPlotWidget* m_viscosityPlot;
std::unique_ptr<RiuPvtPlotUpdater> m_plotUpdater;
std::unique_ptr<RiuPvtPlotUpdater> m_plotUpdater;
};

View File

@@ -1,129 +1,130 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiuPvtPlotUpdater.h"
#include "Riu3dSelectionManager.h"
#include "RiuPvtPlotPanel.h"
#include "RiuRelativePermeabilityPlotUpdater.h"
#include "Riu3dSelectionManager.h"
#include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
#include "RigGridBase.h"
#include "RigActiveCellInfo.h"
#include "RigResultAccessor.h"
#include "RigResultAccessorFactory.h"
#include "RigCaseCellResultsData.h"
#include "Rim3dView.h"
#include "RimEclipseView.h"
#include "RimEclipseResultCase.h"
#include "Rim2dIntersectionView.h"
#include "Rim3dView.h"
#include "RimEclipseResultCase.h"
#include "RimEclipseView.h"
#include "RimIntersection.h"
//#include "cvfTrace.h"
#include <cmath>
//==================================================================================================
///
/// \class RiuPvtPlotUpdater
///
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuPvtPlotUpdater::RiuPvtPlotUpdater(RiuPvtPlotPanel* targetPlotPanel)
: m_targetPlotPanel(targetPlotPanel),
m_sourceEclipseViewOfLastPlot(nullptr)
RiuPvtPlotUpdater::RiuPvtPlotUpdater( RiuPvtPlotPanel* targetPlotPanel )
: m_targetPlotPanel( targetPlotPanel )
, m_sourceEclipseViewOfLastPlot( nullptr )
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotUpdater::updateOnSelectionChanged(const RiuSelectionItem* selectionItem)
void RiuPvtPlotUpdater::updateOnSelectionChanged( const RiuSelectionItem* selectionItem )
{
if (!m_targetPlotPanel)
if ( !m_targetPlotPanel )
{
return;
}
m_sourceEclipseViewOfLastPlot = nullptr;
bool mustClearPlot = true;
bool mustClearPlot = true;
RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast<RiuEclipseSelectionItem*>(const_cast<RiuSelectionItem*>(selectionItem));
RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast<RiuEclipseSelectionItem*>(
const_cast<RiuSelectionItem*>( selectionItem ) );
RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : nullptr;
if (!eclipseSelectionItem && !eclipseView)
if ( !eclipseSelectionItem && !eclipseView )
{
const Riu2dIntersectionSelectionItem* intersectionSelItem = dynamic_cast<const Riu2dIntersectionSelectionItem*>(selectionItem);
if (intersectionSelItem && intersectionSelItem->eclipseSelectionItem())
const Riu2dIntersectionSelectionItem* intersectionSelItem = dynamic_cast<const Riu2dIntersectionSelectionItem*>(
selectionItem );
if ( intersectionSelItem && intersectionSelItem->eclipseSelectionItem() )
{
eclipseSelectionItem = intersectionSelItem->eclipseSelectionItem();
eclipseView = eclipseSelectionItem->m_view;
eclipseView = eclipseSelectionItem->m_view;
}
}
if (m_targetPlotPanel->isVisible() && eclipseSelectionItem && eclipseView)
if ( m_targetPlotPanel->isVisible() && eclipseSelectionItem && eclipseView )
{
const size_t gridIndex = eclipseSelectionItem->m_gridIndex;
const size_t gridIndex = eclipseSelectionItem->m_gridIndex;
const size_t gridLocalCellIndex = eclipseSelectionItem->m_gridLocalCellIndex;
if (queryDataAndUpdatePlot(*eclipseView, gridIndex, gridLocalCellIndex, m_targetPlotPanel))
if ( queryDataAndUpdatePlot( *eclipseView, gridIndex, gridLocalCellIndex, m_targetPlotPanel ) )
{
mustClearPlot = false;
mustClearPlot = false;
m_sourceEclipseViewOfLastPlot = eclipseView;
}
}
if (mustClearPlot)
if ( mustClearPlot )
{
m_targetPlotPanel->clearPlot();
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotUpdater::updateOnTimeStepChanged(Rim3dView* changedView)
void RiuPvtPlotUpdater::updateOnTimeStepChanged( Rim3dView* changedView )
{
if (!m_targetPlotPanel || !m_targetPlotPanel->isVisible())
if ( !m_targetPlotPanel || !m_targetPlotPanel->isVisible() )
{
return;
}
// Don't update the plot if the view that changed time step is different from the view that was the source of the current plot
const RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(changedView);
if (!eclipseView || eclipseView != m_sourceEclipseViewOfLastPlot)
const RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( changedView );
if ( !eclipseView || eclipseView != m_sourceEclipseViewOfLastPlot )
{
return;
}
// Fetch the current global selection and only continue if the selection's view matches the view with time step change
const RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast<const RiuEclipseSelectionItem*>(Riu3dSelectionManager::instance()->selectedItem());
if (eclipseSelectionItem && eclipseSelectionItem->m_view == eclipseView)
const RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast<const RiuEclipseSelectionItem*>(
Riu3dSelectionManager::instance()->selectedItem() );
if ( eclipseSelectionItem && eclipseSelectionItem->m_view == eclipseView )
{
const size_t gridIndex = eclipseSelectionItem->m_gridIndex;
const size_t gridIndex = eclipseSelectionItem->m_gridIndex;
const size_t gridLocalCellIndex = eclipseSelectionItem->m_gridLocalCellIndex;
if (!queryDataAndUpdatePlot(*eclipseView, gridIndex, gridLocalCellIndex, m_targetPlotPanel))
if ( !queryDataAndUpdatePlot( *eclipseView, gridIndex, gridLocalCellIndex, m_targetPlotPanel ) )
{
m_targetPlotPanel->clearPlot();
}
@@ -131,55 +132,103 @@ void RiuPvtPlotUpdater::updateOnTimeStepChanged(Rim3dView* changedView)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuPvtPlotUpdater::queryDataAndUpdatePlot(const RimEclipseView& eclipseView, size_t gridIndex, size_t gridLocalCellIndex, RiuPvtPlotPanel* plotPanel)
bool RiuPvtPlotUpdater::queryDataAndUpdatePlot( const RimEclipseView& eclipseView,
size_t gridIndex,
size_t gridLocalCellIndex,
RiuPvtPlotPanel* plotPanel )
{
CVF_ASSERT(plotPanel);
CVF_ASSERT( plotPanel );
RimEclipseResultCase* eclipseResultCase = dynamic_cast<RimEclipseResultCase*>(eclipseView.eclipseCase());
RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : nullptr;
if (eclipseResultCase && eclipseCaseData && eclipseResultCase->flowDiagSolverInterface())
RimEclipseResultCase* eclipseResultCase = dynamic_cast<RimEclipseResultCase*>( eclipseView.eclipseCase() );
RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : nullptr;
if ( eclipseResultCase && eclipseCaseData && eclipseResultCase->flowDiagSolverInterface() )
{
size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex(eclipseCaseData, gridIndex, gridLocalCellIndex);
if (activeCellIndex != cvf::UNDEFINED_SIZE_T)
size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex( eclipseCaseData, gridIndex, gridLocalCellIndex );
if ( activeCellIndex != cvf::UNDEFINED_SIZE_T )
{
//cvf::Trace::show("Update PVT plot for active cell index: %d", static_cast<int>(activeCellIndex));
// cvf::Trace::show("Update PVT plot for active cell index: %d", static_cast<int>(activeCellIndex));
std::vector<RigFlowDiagSolverInterface::PvtCurve> fvfCurveArr = eclipseResultCase->flowDiagSolverInterface()->calculatePvtCurves(RigFlowDiagSolverInterface::PVT_CT_FVF, activeCellIndex);
std::vector<RigFlowDiagSolverInterface::PvtCurve> viscosityCurveArr = eclipseResultCase->flowDiagSolverInterface()->calculatePvtCurves(RigFlowDiagSolverInterface::PVT_CT_VISCOSITY, activeCellIndex);
std::vector<RigFlowDiagSolverInterface::PvtCurve> fvfCurveArr =
eclipseResultCase->flowDiagSolverInterface()->calculatePvtCurves( RigFlowDiagSolverInterface::PVT_CT_FVF,
activeCellIndex );
std::vector<RigFlowDiagSolverInterface::PvtCurve> viscosityCurveArr =
eclipseResultCase->flowDiagSolverInterface()
->calculatePvtCurves( RigFlowDiagSolverInterface::PVT_CT_VISCOSITY, activeCellIndex );
const size_t timeStepIndex = static_cast<size_t>(eclipseView.currentTimeStep());
const size_t timeStepIndex = static_cast<size_t>( eclipseView.currentTimeStep() );
// The following calls will read results from file in preparation for the queries below
RigCaseCellResultsData* cellResultsData = eclipseCaseData->results(RiaDefines::MATRIX_MODEL);
cellResultsData->ensureKnownResultLoaded(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "RS"));
cellResultsData->ensureKnownResultLoaded(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "RV"));
cellResultsData->ensureKnownResultLoaded(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "PRESSURE"));
cellResultsData->ensureKnownResultLoaded(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "PVTNUM"));
RigCaseCellResultsData* cellResultsData = eclipseCaseData->results( RiaDefines::MATRIX_MODEL );
cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE, "RS" ) );
cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE, "RV" ) );
cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE, "PRESSURE" ) );
cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::STATIC_NATIVE, "PVTNUM" ) );
cvf::ref<RigResultAccessor> rsAccessor = RigResultAccessorFactory::createFromResultAddress(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "RS" ));
cvf::ref<RigResultAccessor> rvAccessor = RigResultAccessorFactory::createFromResultAddress(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "RV" ));
cvf::ref<RigResultAccessor> pressureAccessor = RigResultAccessorFactory::createFromResultAddress(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "PRESSURE" ));
cvf::ref<RigResultAccessor> pvtnumAccessor = RigResultAccessorFactory::createFromResultAddress(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, RigEclipseResultAddress(RiaDefines::STATIC_NATIVE , "PVTNUM" ));
cvf::ref<RigResultAccessor> rsAccessor =
RigResultAccessorFactory::createFromResultAddress( eclipseCaseData,
gridIndex,
RiaDefines::MATRIX_MODEL,
timeStepIndex,
RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE,
"RS" ) );
cvf::ref<RigResultAccessor> rvAccessor =
RigResultAccessorFactory::createFromResultAddress( eclipseCaseData,
gridIndex,
RiaDefines::MATRIX_MODEL,
timeStepIndex,
RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE,
"RV" ) );
cvf::ref<RigResultAccessor> pressureAccessor =
RigResultAccessorFactory::createFromResultAddress( eclipseCaseData,
gridIndex,
RiaDefines::MATRIX_MODEL,
timeStepIndex,
RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE,
"PRESSURE" ) );
cvf::ref<RigResultAccessor> pvtnumAccessor =
RigResultAccessorFactory::createFromResultAddress( eclipseCaseData,
gridIndex,
RiaDefines::MATRIX_MODEL,
timeStepIndex,
RigEclipseResultAddress( RiaDefines::STATIC_NATIVE,
"PVTNUM" ) );
RiuPvtPlotPanel::CellValues cellValues;
cellValues.rs = rsAccessor.notNull() ? rsAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
cellValues.rv = rvAccessor.notNull() ? rvAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
cellValues.pressure = pressureAccessor.notNull() ? pressureAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
const double cellPVTNUM = pvtnumAccessor.notNull() ? pvtnumAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
cellValues.rs = rsAccessor.notNull() ? rsAccessor->cellScalar( gridLocalCellIndex ) : HUGE_VAL;
cellValues.rv = rvAccessor.notNull() ? rvAccessor->cellScalar( gridLocalCellIndex ) : HUGE_VAL;
cellValues.pressure = pressureAccessor.notNull() ? pressureAccessor->cellScalar( gridLocalCellIndex )
: HUGE_VAL;
const double cellPVTNUM = pvtnumAccessor.notNull() ? pvtnumAccessor->cellScalar( gridLocalCellIndex )
: HUGE_VAL;
RiuPvtPlotPanel::FvfDynProps fvfDynProps;
eclipseResultCase->flowDiagSolverInterface()->calculatePvtDynamicPropertiesFvf(activeCellIndex, cellValues.pressure, cellValues.rs, cellValues.rv, &fvfDynProps.bo, &fvfDynProps.bg);
eclipseResultCase->flowDiagSolverInterface()->calculatePvtDynamicPropertiesFvf( activeCellIndex,
cellValues.pressure,
cellValues.rs,
cellValues.rv,
&fvfDynProps.bo,
&fvfDynProps.bg );
RiuPvtPlotPanel::ViscosityDynProps viscosityDynProps;
eclipseResultCase->flowDiagSolverInterface()->calculatePvtDynamicPropertiesViscosity(activeCellIndex, cellValues.pressure, cellValues.rs, cellValues.rv, &viscosityDynProps.mu_o, &viscosityDynProps.mu_g);
eclipseResultCase->flowDiagSolverInterface()->calculatePvtDynamicPropertiesViscosity( activeCellIndex,
cellValues.pressure,
cellValues.rs,
cellValues.rv,
&viscosityDynProps.mu_o,
&viscosityDynProps.mu_g );
QString cellRefText = constructCellReferenceText(eclipseCaseData, gridIndex, gridLocalCellIndex, cellPVTNUM);
QString cellRefText = constructCellReferenceText( eclipseCaseData, gridIndex, gridLocalCellIndex, cellPVTNUM );
plotPanel->setPlotData(eclipseCaseData->unitsType(), fvfCurveArr, viscosityCurveArr, fvfDynProps, viscosityDynProps, cellValues, cellRefText);
plotPanel->setPlotData( eclipseCaseData->unitsType(),
fvfCurveArr,
viscosityCurveArr,
fvfDynProps,
viscosityDynProps,
cellValues,
cellRefText );
return true;
}
@@ -188,20 +237,22 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot(const RimEclipseView& eclipseView
return false;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QString RiuPvtPlotUpdater::constructCellReferenceText(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex, double pvtnum)
QString RiuPvtPlotUpdater::constructCellReferenceText( const RigEclipseCaseData* eclipseCaseData,
size_t gridIndex,
size_t gridLocalCellIndex,
double pvtnum )
{
const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0;
const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : nullptr;
if (grid && gridLocalCellIndex < grid->cellCount())
const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0;
const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid( gridIndex ) : nullptr;
if ( grid && gridLocalCellIndex < grid->cellCount() )
{
size_t i = 0;
size_t j = 0;
size_t k = 0;
if (grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k))
if ( grid->ijkFromCellIndex( gridLocalCellIndex, &i, &j, &k ) )
{
// Adjust to 1-based Eclipse indexing
i++;
@@ -209,18 +260,18 @@ QString RiuPvtPlotUpdater::constructCellReferenceText(const RigEclipseCaseData*
k++;
QString retText;
if (gridIndex == 0)
if ( gridIndex == 0 )
{
retText = QString("Cell: [%1, %2, %3]").arg(i).arg(j).arg(k);
retText = QString( "Cell: [%1, %2, %3]" ).arg( i ).arg( j ).arg( k );
}
else
{
retText = QString("LGR %1, Cell: [%2, %3, %4]").arg(gridIndex).arg(i).arg(j).arg(k);
retText = QString( "LGR %1, Cell: [%2, %3, %4]" ).arg( gridIndex ).arg( i ).arg( j ).arg( k );
}
if (pvtnum != HUGE_VAL)
if ( pvtnum != HUGE_VAL )
{
retText += QString(" (PVTNUM=%1)").arg(pvtnum);
retText += QString( " (PVTNUM=%1)" ).arg( pvtnum );
}
return retText;
@@ -229,5 +280,3 @@ QString RiuPvtPlotUpdater::constructCellReferenceText(const RigEclipseCaseData*
return QString();
}

View File

@@ -1,25 +1,25 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
#include <QPointer>
#include <QString>
class RiuSelectionItem;
class RiuPvtPlotPanel;
@@ -27,7 +27,6 @@ class Rim3dView;
class RimEclipseView;
class RigEclipseCaseData;
//==================================================================================================
//
//
@@ -36,19 +35,22 @@ class RigEclipseCaseData;
class RiuPvtPlotUpdater
{
public:
RiuPvtPlotUpdater(RiuPvtPlotPanel* targetPlotPanel);
RiuPvtPlotUpdater( RiuPvtPlotPanel* targetPlotPanel );
void updateOnSelectionChanged(const RiuSelectionItem* selectionItem);
void updateOnTimeStepChanged(Rim3dView* changedView);
void updateOnSelectionChanged( const RiuSelectionItem* selectionItem );
void updateOnTimeStepChanged( Rim3dView* changedView );
private:
static bool queryDataAndUpdatePlot(const RimEclipseView& eclipseView, size_t gridIndex, size_t gridLocalCellIndex, RiuPvtPlotPanel* plotPanel);
static QString constructCellReferenceText(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex, double pvtnum);
static bool queryDataAndUpdatePlot( const RimEclipseView& eclipseView,
size_t gridIndex,
size_t gridLocalCellIndex,
RiuPvtPlotPanel* plotPanel );
static QString constructCellReferenceText( const RigEclipseCaseData* eclipseCaseData,
size_t gridIndex,
size_t gridLocalCellIndex,
double pvtnum );
private:
QPointer<RiuPvtPlotPanel> m_targetPlotPanel;
const Rim3dView* m_sourceEclipseViewOfLastPlot;
QPointer<RiuPvtPlotPanel> m_targetPlotPanel;
const Rim3dView* m_sourceEclipseViewOfLastPlot;
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -23,30 +23,34 @@
#include "qwt_plot_marker.h"
#include "qwt_symbol.h"
#include "qwt_plot_curve.h"
#include "qwt_date_scale_draw.h"
#include "qwt_plot_curve.h"
#include <cfloat> // For DBL_MAX
#include <QEvent>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuQwtCurvePointTracker::RiuQwtCurvePointTracker(QwtPlot* plot, bool isMainAxisHorizontal, IPlotCurveInfoTextProvider* curveInfoTextProvider)
: QwtPlotPicker(plot->canvas()), m_plot(plot), m_isMainAxisHorizontal(isMainAxisHorizontal), m_curveInfoTextProvider(curveInfoTextProvider)
RiuQwtCurvePointTracker::RiuQwtCurvePointTracker( QwtPlot* plot,
bool isMainAxisHorizontal,
IPlotCurveInfoTextProvider* curveInfoTextProvider )
: QwtPlotPicker( plot->canvas() )
, m_plot( plot )
, m_isMainAxisHorizontal( isMainAxisHorizontal )
, m_curveInfoTextProvider( curveInfoTextProvider )
{
this->setTrackerMode(QwtPicker::AlwaysOn);
this->setTrackerMode( QwtPicker::AlwaysOn );
m_plotMarker = new QwtPlotMarker;
// QwtPlotMarker takes ownership of the symbol, it is deleted in destructor of QwtPlotMarker
QwtSymbol* mySymbol = new QwtSymbol(QwtSymbol::Ellipse, Qt::NoBrush, QPen(Qt::black, 2.0), QSize(12, 12));
m_plotMarker->setSymbol(mySymbol);
QwtSymbol* mySymbol = new QwtSymbol( QwtSymbol::Ellipse, Qt::NoBrush, QPen( Qt::black, 2.0 ), QSize( 12, 12 ) );
m_plotMarker->setSymbol( mySymbol );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuQwtCurvePointTracker::~RiuQwtCurvePointTracker()
{
@@ -55,7 +59,7 @@ RiuQwtCurvePointTracker::~RiuQwtCurvePointTracker()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtCurvePointTracker::removeMarkerOnFocusLeave()
{
@@ -68,9 +72,9 @@ void RiuQwtCurvePointTracker::removeMarkerOnFocusLeave()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuQwtCurvePointTracker::eventFilter(QObject *watched, QEvent *event)
bool RiuQwtCurvePointTracker::eventFilter( QObject* watched, QEvent* event )
{
if ( event->type() == QEvent::Leave )
{
@@ -78,13 +82,13 @@ bool RiuQwtCurvePointTracker::eventFilter(QObject *watched, QEvent *event)
}
// pass the event on to the parent class
return QwtPlotPicker::eventFilter(watched, event);
return QwtPlotPicker::eventFilter( watched, event );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QwtText RiuQwtCurvePointTracker::trackerText(const QPoint& pos) const
QwtText RiuQwtCurvePointTracker::trackerText( const QPoint& pos ) const
{
QwtText txt;
@@ -96,55 +100,59 @@ QwtText RiuQwtCurvePointTracker::trackerText(const QPoint& pos) const
QString curveInfoText;
QString mainAxisValueString;
QString valueAxisValueString;
QPointF closestPoint = closestCurvePoint(pos, &curveInfoText, &valueAxisValueString, &mainAxisValueString, &relatedXAxis, &relatedYAxis);
QPointF closestPoint = closestCurvePoint( pos,
&curveInfoText,
&valueAxisValueString,
&mainAxisValueString,
&relatedXAxis,
&relatedYAxis );
if ( !closestPoint.isNull() )
{
QString str = !curveInfoText.isEmpty() ?
QString("%1: %2").arg(curveInfoText).arg(valueAxisValueString) :
valueAxisValueString;
QString str = !curveInfoText.isEmpty() ? QString( "%1: %2" ).arg( curveInfoText ).arg( valueAxisValueString )
: valueAxisValueString;
if ( !mainAxisValueString.isEmpty() )
{
str += QString(" (%1)").arg(mainAxisValueString);
str += QString( " (%1)" ).arg( mainAxisValueString );
}
txt.setText(str);
txt.setText( str );
}
updateClosestCurvePointMarker(closestPoint, relatedXAxis, relatedYAxis);
updateClosestCurvePointMarker( closestPoint, relatedXAxis, relatedYAxis );
}
return txt;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QPointF RiuQwtCurvePointTracker::closestCurvePoint(const QPoint& cursorPosition,
QString* curveInfoText,
QString* valueAxisValueString,
QString* mainAxisValueString,
QwtPlot::Axis* relatedXAxis,
QwtPlot::Axis* relatedYAxis) const
QPointF RiuQwtCurvePointTracker::closestCurvePoint( const QPoint& cursorPosition,
QString* curveInfoText,
QString* valueAxisValueString,
QString* mainAxisValueString,
QwtPlot::Axis* relatedXAxis,
QwtPlot::Axis* relatedYAxis ) const
{
QPointF samplePoint;
QwtPlotCurve* closestCurve = nullptr;
double distMin = DBL_MAX;
int closestPointSampleIndex = -1;
QwtPlotCurve* closestCurve = nullptr;
double distMin = DBL_MAX;
int closestPointSampleIndex = -1;
const QwtPlotItemList& itmList = m_plot->itemList();
for ( QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++ )
{
if ( (*it)->rtti() == QwtPlotItem::Rtti_PlotCurve )
if ( ( *it )->rtti() == QwtPlotItem::Rtti_PlotCurve )
{
QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>(*it);
double dist = DBL_MAX;
int candidateSampleIndex = candidateCurve->closestPoint(cursorPosition, &dist);
QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>( *it );
double dist = DBL_MAX;
int candidateSampleIndex = candidateCurve->closestPoint( cursorPosition, &dist );
if ( dist < distMin )
{
closestCurve = candidateCurve;
distMin = dist;
closestCurve = candidateCurve;
distMin = dist;
closestPointSampleIndex = candidateSampleIndex;
}
}
@@ -152,17 +160,17 @@ QPointF RiuQwtCurvePointTracker::closestCurvePoint(const QPoint& cursorPosition,
if ( closestCurve && distMin < 50 )
{
samplePoint = closestCurve->sample(closestPointSampleIndex);
samplePoint = closestCurve->sample( closestPointSampleIndex );
if ( relatedXAxis ) *relatedXAxis = static_cast<QwtPlot::Axis>(closestCurve->xAxis());
if ( relatedYAxis ) *relatedYAxis = static_cast<QwtPlot::Axis>(closestCurve->yAxis());
if ( relatedXAxis ) *relatedXAxis = static_cast<QwtPlot::Axis>( closestCurve->xAxis() );
if ( relatedYAxis ) *relatedYAxis = static_cast<QwtPlot::Axis>( closestCurve->yAxis() );
}
if ( mainAxisValueString )
{
const QwtScaleDraw* mainAxisScaleDraw = m_isMainAxisHorizontal ? m_plot->axisScaleDraw(*relatedXAxis): m_plot->axisScaleDraw(*relatedYAxis);
auto dateScaleDraw = dynamic_cast<const QwtDateScaleDraw*>(mainAxisScaleDraw) ;
const QwtScaleDraw* mainAxisScaleDraw = m_isMainAxisHorizontal ? m_plot->axisScaleDraw( *relatedXAxis )
: m_plot->axisScaleDraw( *relatedYAxis );
auto dateScaleDraw = dynamic_cast<const QwtDateScaleDraw*>( mainAxisScaleDraw );
qreal mainAxisSampleVal = 0.0;
if ( m_isMainAxisHorizontal )
@@ -170,27 +178,28 @@ QPointF RiuQwtCurvePointTracker::closestCurvePoint(const QPoint& cursorPosition,
else
mainAxisSampleVal = samplePoint.y();
if (curveInfoText && closestCurve && m_curveInfoTextProvider)
if ( curveInfoText && closestCurve && m_curveInfoTextProvider )
{
*curveInfoText = m_curveInfoTextProvider->curveInfoText(closestCurve);
*curveInfoText = m_curveInfoTextProvider->curveInfoText( closestCurve );
}
if ( dateScaleDraw )
{
QDateTime date = dateScaleDraw->toDateTime(mainAxisSampleVal);
QString dateString = RiaQDateTimeTools::toStringUsingApplicationLocale(date, "hh:mm dd.MMMM.yyyy");
QDateTime date = dateScaleDraw->toDateTime( mainAxisSampleVal );
QString dateString = RiaQDateTimeTools::toStringUsingApplicationLocale( date, "hh:mm dd.MMMM.yyyy" );
*mainAxisValueString = dateString;
}
else if ( mainAxisScaleDraw )
{
*mainAxisValueString = mainAxisScaleDraw->label(mainAxisSampleVal).text();
*mainAxisValueString = mainAxisScaleDraw->label( mainAxisSampleVal ).text();
}
}
if ( valueAxisValueString && closestCurve )
{
const QwtScaleDraw* valueAxisScaleDraw = m_isMainAxisHorizontal ? m_plot->axisScaleDraw(*relatedYAxis): m_plot->axisScaleDraw(*relatedXAxis);
const QwtScaleDraw* valueAxisScaleDraw = m_isMainAxisHorizontal ? m_plot->axisScaleDraw( *relatedYAxis )
: m_plot->axisScaleDraw( *relatedXAxis );
qreal valueAxisSampleVal = 0.0;
if ( m_isMainAxisHorizontal )
@@ -200,7 +209,7 @@ QPointF RiuQwtCurvePointTracker::closestCurvePoint(const QPoint& cursorPosition,
if ( valueAxisScaleDraw )
{
*valueAxisValueString = valueAxisScaleDraw->label(valueAxisSampleVal).text();
*valueAxisValueString = valueAxisScaleDraw->label( valueAxisSampleVal ).text();
}
}
@@ -208,9 +217,11 @@ QPointF RiuQwtCurvePointTracker::closestCurvePoint(const QPoint& cursorPosition,
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtCurvePointTracker::updateClosestCurvePointMarker(const QPointF& closestPoint, QwtPlot::Axis relatedXAxis, QwtPlot::Axis relatedYAxis) const
void RiuQwtCurvePointTracker::updateClosestCurvePointMarker( const QPointF& closestPoint,
QwtPlot::Axis relatedXAxis,
QwtPlot::Axis relatedYAxis ) const
{
bool replotRequired = false;
@@ -218,17 +229,17 @@ void RiuQwtCurvePointTracker::updateClosestCurvePointMarker(const QPointF& close
{
if ( !m_plotMarker->plot() )
{
m_plotMarker->attach(m_plot);
m_plotMarker->attach( m_plot );
replotRequired = true;
}
if ( m_plotMarker->value() != closestPoint )
{
m_plotMarker->setValue(closestPoint.x(), closestPoint.y());
m_plotMarker->setValue( closestPoint.x(), closestPoint.y() );
// Set the axes that the marker realtes to, to make the positioning correct
m_plotMarker->setAxes(relatedXAxis, relatedYAxis);
m_plotMarker->setAxes( relatedXAxis, relatedYAxis );
// TODO : Should use a color or other visual indicator to show what axis the curve relates to

View File

@@ -1,24 +1,24 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "qwt_plot_picker.h"
#include "qwt_plot.h"
#include "qwt_plot_picker.h"
#include <QPointer>
@@ -26,35 +26,35 @@ class QwtPlotMarker;
class QwtPlotCurve;
class IPlotCurveInfoTextProvider;
//--------------------------------------------------------------------------------------------------
/// Class to add mouse over-tracking of curve points with text marker
//--------------------------------------------------------------------------------------------------
class RiuQwtCurvePointTracker : public QwtPlotPicker
{
public:
explicit RiuQwtCurvePointTracker(QwtPlot* plot, bool isMainAxisHorizontal, IPlotCurveInfoTextProvider* curveInfoTextProvider = nullptr);
explicit RiuQwtCurvePointTracker( QwtPlot* plot,
bool isMainAxisHorizontal,
IPlotCurveInfoTextProvider* curveInfoTextProvider = nullptr );
~RiuQwtCurvePointTracker() override;
protected:
bool eventFilter( QObject*, QEvent* ) override;
void removeMarkerOnFocusLeave();
bool eventFilter(QObject *, QEvent *) override;
void removeMarkerOnFocusLeave();
QwtText trackerText( const QPoint& pos ) const override;
QPointF closestCurvePoint( const QPoint& cursorPosition,
QString* curveInfoText,
QString* valueAxisValueString,
QString* mainAxisValueString,
QwtPlot::Axis* relatedXAxis,
QwtPlot::Axis* relatedYAxis ) const;
void updateClosestCurvePointMarker( const QPointF& closestPoint,
QwtPlot::Axis relatedXAxis,
QwtPlot::Axis relatedYAxis ) const;
QwtText trackerText(const QPoint& pos) const override;
QPointF closestCurvePoint(const QPoint& cursorPosition,
QString* curveInfoText,
QString* valueAxisValueString,
QString* mainAxisValueString,
QwtPlot::Axis* relatedXAxis,
QwtPlot::Axis* relatedYAxis) const;
void updateClosestCurvePointMarker(const QPointF& closestPoint,
QwtPlot::Axis relatedXAxis,
QwtPlot::Axis relatedYAxis) const;
QPointer<QwtPlot> m_plot;
QwtPlotMarker* m_plotMarker;
bool m_isMainAxisHorizontal;
QPointer<QwtPlot> m_plot;
QwtPlotMarker* m_plotMarker;
bool m_isMainAxisHorizontal;
IPlotCurveInfoTextProvider* m_curveInfoTextProvider;
};
@@ -64,5 +64,5 @@ protected:
class IPlotCurveInfoTextProvider
{
public:
virtual QString curveInfoText(QwtPlotCurve* curve) = 0;
virtual QString curveInfoText( QwtPlotCurve* curve ) = 0;
};

View File

@@ -1,33 +1,35 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiuQwtLinearScaleEngine.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QwtScaleDiv RiuQwtLinearScaleEngine::divideScaleWithExplicitIntervals(double x1, double x2, double majorStepInterval, double minorStepInterval)
QwtScaleDiv RiuQwtLinearScaleEngine::divideScaleWithExplicitIntervals( double x1,
double x2,
double majorStepInterval,
double minorStepInterval )
{
QwtInterval interval(x1, x2);
QwtInterval roundedInterval = this->align(interval, majorStepInterval);
QList<double> majorTicks = this->buildMajorTicks(roundedInterval, majorStepInterval);
QList<double> minorTicks = this->buildMajorTicks(roundedInterval, minorStepInterval);
QwtInterval interval( x1, x2 );
QwtInterval roundedInterval = this->align( interval, majorStepInterval );
QList<double> majorTicks = this->buildMajorTicks( roundedInterval, majorStepInterval );
QList<double> minorTicks = this->buildMajorTicks( roundedInterval, minorStepInterval );
return QwtScaleDiv(x1, x2, minorTicks, minorTicks, majorTicks);
return QwtScaleDiv( x1, x2, minorTicks, minorTicks, majorTicks );
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -22,11 +22,12 @@
//==================================================================================================
//
//
//
//
//==================================================================================================
class RiuQwtLinearScaleEngine : public QwtLinearScaleEngine
{
public:
QwtScaleDiv divideScaleWithExplicitIntervals(double x1, double x2, double majorStepInterval, double minorStepInterval);
QwtScaleDiv
divideScaleWithExplicitIntervals( double x1, double x2, double majorStepInterval, double minorStepInterval );
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -22,7 +22,7 @@
#include "RimProject.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuQwtCurvePointTracker.h"
#include "RiuQwtPlotTools.h"
#include "RiuQwtPlotWheelZoomer.h"
@@ -49,66 +49,66 @@
#include <cfloat>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlot::RiuQwtPlot(RimViewWindow* viewWindow, QWidget* parent) : QwtPlot(parent)
RiuQwtPlot::RiuQwtPlot( RimViewWindow* viewWindow, QWidget* parent )
: QwtPlot( parent )
{
Q_ASSERT(viewWindow);
Q_ASSERT( viewWindow );
m_ownerViewWindow = viewWindow;
// LeftButton for the zooming
m_zoomerLeft = new RiuQwtPlotZoomer(canvas());
m_zoomerLeft->setRubberBandPen(QColor(Qt::black));
m_zoomerLeft->setTrackerMode(QwtPicker::AlwaysOff);
m_zoomerLeft->setTrackerPen(QColor(Qt::black));
m_zoomerLeft->initMousePattern(1);
m_zoomerLeft = new RiuQwtPlotZoomer( canvas() );
m_zoomerLeft->setRubberBandPen( QColor( Qt::black ) );
m_zoomerLeft->setTrackerMode( QwtPicker::AlwaysOff );
m_zoomerLeft->setTrackerPen( QColor( Qt::black ) );
m_zoomerLeft->initMousePattern( 1 );
// Attach a zoomer for the right axis
m_zoomerRight = new RiuQwtPlotZoomer(canvas());
m_zoomerRight->setAxis(xTop, yRight);
m_zoomerRight->setTrackerMode(QwtPicker::AlwaysOff);
m_zoomerRight->initMousePattern(1);
m_zoomerRight = new RiuQwtPlotZoomer( canvas() );
m_zoomerRight->setAxis( xTop, yRight );
m_zoomerRight->setTrackerMode( QwtPicker::AlwaysOff );
m_zoomerRight->initMousePattern( 1 );
// MidButton for the panning
QwtPlotPanner* panner = new QwtPlotPanner(canvas());
panner->setMouseButton(Qt::MidButton);
QwtPlotPanner* panner = new QwtPlotPanner( canvas() );
panner->setMouseButton( Qt::MidButton );
auto wheelZoomer = new RiuQwtPlotWheelZoomer(this);
auto wheelZoomer = new RiuQwtPlotWheelZoomer( this );
connect(wheelZoomer, SIGNAL(zoomUpdated()), SLOT(onZoomedSlot()));
connect(m_zoomerLeft, SIGNAL(zoomed( const QRectF & )), SLOT(onZoomedSlot()));
connect(panner, SIGNAL(panned( int , int )), SLOT(onZoomedSlot()));
connect( wheelZoomer, SIGNAL( zoomUpdated() ), SLOT( onZoomedSlot() ) );
connect( m_zoomerLeft, SIGNAL( zoomed( const QRectF& ) ), SLOT( onZoomedSlot() ) );
connect( panner, SIGNAL( panned( int, int ) ), SLOT( onZoomedSlot() ) );
RiuQwtScalePicker* scalePicker = new RiuQwtScalePicker(this);
connect(scalePicker, SIGNAL(clicked(int, double)), this, SLOT(onAxisClicked(int, double)));
RiuQwtPlotTools::setCommonPlotBehaviour(this);
RiuQwtPlotTools::setDefaultAxes(this);
RiuQwtScalePicker* scalePicker = new RiuQwtScalePicker( this );
connect( scalePicker, SIGNAL( clicked( int, double ) ), this, SLOT( onAxisClicked( int, double ) ) );
RiuQwtPlotTools::setCommonPlotBehaviour( this );
RiuQwtPlotTools::setDefaultAxes( this );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlot::~RiuQwtPlot()
{
if (ownerPlotDefinition())
if ( ownerPlotDefinition() )
{
ownerPlotDefinition()->detachAllCurves();
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RimRiuQwtPlotOwnerInterface* RiuQwtPlot::ownerPlotDefinition() const
{
RimRiuQwtPlotOwnerInterface* plotDefinition = dynamic_cast<RimRiuQwtPlotOwnerInterface*>(ownerViewWindow());
RimRiuQwtPlotOwnerInterface* plotDefinition = dynamic_cast<RimRiuQwtPlotOwnerInterface*>( ownerViewWindow() );
return plotDefinition;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RimViewWindow* RiuQwtPlot::ownerViewWindow() const
{
@@ -116,135 +116,131 @@ RimViewWindow* RiuQwtPlot::ownerViewWindow() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QSize RiuQwtPlot::minimumSizeHint() const
{
return QSize(0, 100);
return QSize( 0, 100 );
}
//--------------------------------------------------------------------------------------------------
/// Empty default implementation
//--------------------------------------------------------------------------------------------------
void RiuQwtPlot::selectSample(QwtPlotCurve* curve, int sampleNumber)
{
}
void RiuQwtPlot::selectSample( QwtPlotCurve* curve, int sampleNumber ) {}
//--------------------------------------------------------------------------------------------------
/// Empty default implementation
//--------------------------------------------------------------------------------------------------
void RiuQwtPlot::clearSampleSelection()
{
}
void RiuQwtPlot::clearSampleSelection() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlot::hideEvent(QHideEvent* event)
void RiuQwtPlot::hideEvent( QHideEvent* event )
{
resetCurveHighlighting();
QwtPlot::hideEvent(event);
QwtPlot::hideEvent( event );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QSize RiuQwtPlot::sizeHint() const
{
return QSize(0, 0);
return QSize( 0, 0 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QwtInterval RiuQwtPlot::currentAxisRange(QwtPlot::Axis axis)
QwtInterval RiuQwtPlot::currentAxisRange( QwtPlot::Axis axis )
{
return axisScaleDiv(axis).interval();
return axisScaleDiv( axis ).interval();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuQwtPlot::eventFilter(QObject* watched, QEvent* event)
bool RiuQwtPlot::eventFilter( QObject* watched, QEvent* event )
{
if(watched == canvas())
if ( watched == canvas() )
{
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
if(mouseEvent)
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>( event );
if ( mouseEvent )
{
if(mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonRelease)
if ( mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonRelease )
{
bool anyZoomingActive = false;
if (m_zoomerLeft && m_zoomerLeft->isActiveAndValid())
if ( m_zoomerLeft && m_zoomerLeft->isActiveAndValid() )
{
anyZoomingActive = true;
}
if (m_zoomerRight && m_zoomerRight->isActiveAndValid())
if ( m_zoomerRight && m_zoomerRight->isActiveAndValid() )
{
anyZoomingActive = true;
}
if (!anyZoomingActive)
if ( !anyZoomingActive )
{
selectClosestCurve(mouseEvent->pos());
selectClosestCurve( mouseEvent->pos() );
}
}
}
}
return QwtPlot::eventFilter(watched, event);
return QwtPlot::eventFilter( watched, event );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlot::selectClosestCurve(const QPoint& pos)
void RiuQwtPlot::selectClosestCurve( const QPoint& pos )
{
QwtPlotCurve* closestCurve = nullptr;
double distMin = DBL_MAX;
int closestCurvePoint = -1;
const QwtPlotItemList& itmList = itemList();
for(QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++)
QwtPlotCurve* closestCurve = nullptr;
double distMin = DBL_MAX;
int closestCurvePoint = -1;
const QwtPlotItemList& itmList = itemList();
for ( QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++ )
{
if((*it)->rtti() == QwtPlotItem::Rtti_PlotCurve)
if ( ( *it )->rtti() == QwtPlotItem::Rtti_PlotCurve )
{
QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>(*it);
double dist = DBL_MAX;
int curvePoint = candidateCurve->closestPoint(pos, &dist);
if(dist < distMin)
QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>( *it );
double dist = DBL_MAX;
int curvePoint = candidateCurve->closestPoint( pos, &dist );
if ( dist < distMin )
{
closestCurve = candidateCurve;
distMin = dist;
closestCurve = candidateCurve;
distMin = dist;
closestCurvePoint = curvePoint;
}
}
}
resetCurveHighlighting();
if (closestCurve && distMin < 20)
if ( closestCurve && distMin < 20 )
{
CVF_ASSERT(closestCurvePoint >= 0);
caf::PdmObject* selectedPlotObject = ownerPlotDefinition()->findRimPlotObjectFromQwtCurve(closestCurve);
CVF_ASSERT( closestCurvePoint >= 0 );
caf::PdmObject* selectedPlotObject = ownerPlotDefinition()->findRimPlotObjectFromQwtCurve( closestCurve );
if (selectedPlotObject)
if ( selectedPlotObject )
{
RimProject* proj = nullptr;
selectedPlotObject->firstAncestorOrThisOfType(proj);
selectedPlotObject->firstAncestorOrThisOfType( proj );
if (proj)
if ( proj )
{
RiuPlotMainWindowTools::showPlotMainWindow();
RiuPlotMainWindowTools::selectAsCurrentItem(selectedPlotObject);
highlightCurve(closestCurve);
}
RiuPlotMainWindowTools::selectAsCurrentItem( selectedPlotObject );
highlightCurve( closestCurve );
}
}
}
if (closestCurve && distMin < 10)
if ( closestCurve && distMin < 10 )
{
selectSample(closestCurve, closestCurvePoint);
selectSample( closestCurve, closestCurvePoint );
}
else
{
@@ -257,15 +253,15 @@ void RiuQwtPlot::selectClosestCurve(const QPoint& pos)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlot::highlightCurve(const QwtPlotCurve* closestCurve)
void RiuQwtPlot::highlightCurve( const QwtPlotCurve* closestCurve )
{
// NB! Create a copy of the item list before the loop to avoid invalidated iterators when iterating the list
// plotCurve->setZ() causes the ordering of items in the list to change
auto plotItemList = this->itemList();
for (QwtPlotItem* plotItem : plotItemList)
for ( QwtPlotItem* plotItem : plotItemList )
{
QwtPlotCurve* plotCurve = dynamic_cast<QwtPlotCurve*>(plotItem);
if (plotCurve)
QwtPlotCurve* plotCurve = dynamic_cast<QwtPlotCurve*>( plotItem );
if ( plotCurve )
{
QPen existingPen = plotCurve->pen();
QColor bgColor = this->canvasBackground().color();
@@ -274,34 +270,34 @@ void RiuQwtPlot::highlightCurve(const QwtPlotCurve* closestCurve)
QColor symbolColor;
QColor symbolLineColor;
QwtSymbol* symbol = const_cast<QwtSymbol*>(plotCurve->symbol());
if (symbol)
QwtSymbol* symbol = const_cast<QwtSymbol*>( plotCurve->symbol() );
if ( symbol )
{
symbolColor = symbol->brush().color();
symbolLineColor = symbol->pen().color();
}
double zValue = plotCurve->z();
if (plotCurve == closestCurve)
if ( plotCurve == closestCurve )
{
plotCurve->setZ(zValue + 100.0);
plotCurve->setZ( zValue + 100.0 );
}
else
{
QColor blendedColor = RiaColorTools::blendQColors(bgColor, curveColor, 3, 1);
QColor blendedSymbolColor = RiaColorTools::blendQColors(bgColor, symbolColor, 3, 1);
QColor blendedSymbolLineColor = RiaColorTools::blendQColors(bgColor, symbolLineColor, 3, 1);
QColor blendedColor = RiaColorTools::blendQColors( bgColor, curveColor, 3, 1 );
QColor blendedSymbolColor = RiaColorTools::blendQColors( bgColor, symbolColor, 3, 1 );
QColor blendedSymbolLineColor = RiaColorTools::blendQColors( bgColor, symbolLineColor, 3, 1 );
plotCurve->setPen(blendedColor, existingPen.width(), existingPen.style());
if (symbol)
plotCurve->setPen( blendedColor, existingPen.width(), existingPen.style() );
if ( symbol )
{
symbol->setColor(blendedSymbolColor);
symbol->setPen(blendedSymbolLineColor, symbol->pen().width(), symbol->pen().style());
symbol->setColor( blendedSymbolColor );
symbol->setPen( blendedSymbolLineColor, symbol->pen().width(), symbol->pen().style() );
}
}
CurveColors curveColors = {curveColor, symbolColor, symbolLineColor};
m_originalCurveColors.insert(std::make_pair(plotCurve, curveColors));
m_originalZValues.insert(std::make_pair(plotCurve, zValue));
m_originalCurveColors.insert( std::make_pair( plotCurve, curveColors ) );
m_originalZValues.insert( std::make_pair( plotCurve, zValue ) );
}
}
}
@@ -314,22 +310,22 @@ void RiuQwtPlot::resetCurveHighlighting()
// NB! Create a copy of the item list before the loop to avoid invalidated iterators when iterating the list
// plotCurve->setZ() causes the ordering of items in the list to change
auto plotItemList = this->itemList();
for (QwtPlotItem* plotItem : plotItemList)
for ( QwtPlotItem* plotItem : plotItemList )
{
QwtPlotCurve* plotCurve = dynamic_cast<QwtPlotCurve*>(plotItem);
if (plotCurve && m_originalCurveColors.count(plotCurve))
QwtPlotCurve* plotCurve = dynamic_cast<QwtPlotCurve*>( plotItem );
if ( plotCurve && m_originalCurveColors.count( plotCurve ) )
{
const QPen& existingPen = plotCurve->pen();
auto colors = m_originalCurveColors[plotCurve];
double zValue = m_originalZValues[plotCurve];
plotCurve->setPen(colors.lineColor, existingPen.width(), existingPen.style());
plotCurve->setZ(zValue);
QwtSymbol* symbol = const_cast<QwtSymbol*>(plotCurve->symbol());
if (symbol)
plotCurve->setPen( colors.lineColor, existingPen.width(), existingPen.style() );
plotCurve->setZ( zValue );
QwtSymbol* symbol = const_cast<QwtSymbol*>( plotCurve->symbol() );
if ( symbol )
{
symbol->setColor(colors.symbolColor);
symbol->setPen(colors.symbolLineColor, symbol->pen().width(), symbol->pen().style());
symbol->setColor( colors.symbolColor );
symbol->setPen( colors.symbolLineColor, symbol->pen().width(), symbol->pen().style() );
}
}
}
@@ -346,9 +342,9 @@ void RiuQwtPlot::onZoomedSlot()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlot::onAxisClicked(int axis, double value)
{
ownerPlotDefinition()->selectAxisInPropertyEditor(axis);
void RiuQwtPlot::onAxisClicked( int axis, double value )
{
ownerPlotDefinition()->selectAxisInPropertyEditor( axis );
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -45,34 +45,35 @@ class QwtScaleWidget;
class RiuQwtPlot : public QwtPlot, public RiuInterfaceToViewWindow
{
Q_OBJECT;
public:
RiuQwtPlot(RimViewWindow* viewWindow, QWidget* parent = nullptr);
RiuQwtPlot( RimViewWindow* viewWindow, QWidget* parent = nullptr );
~RiuQwtPlot() override;
RimRiuQwtPlotOwnerInterface* ownerPlotDefinition() const;
RimViewWindow* ownerViewWindow() const override;
RimRiuQwtPlotOwnerInterface* ownerPlotDefinition() const;
RimViewWindow* ownerViewWindow() const override;
QwtInterval currentAxisRange(QwtPlot::Axis axis);
QwtInterval currentAxisRange( QwtPlot::Axis axis );
protected:
bool eventFilter(QObject* watched, QEvent* event) override;
bool eventFilter( QObject* watched, QEvent* event ) override;
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
virtual void selectSample(QwtPlotCurve* curve, int sampleNumber);
virtual void clearSampleSelection();
virtual void selectSample( QwtPlotCurve* curve, int sampleNumber );
virtual void clearSampleSelection();
virtual void hideEvent(QHideEvent *event) override;
virtual void hideEvent( QHideEvent* event ) override;
private:
void selectClosestCurve(const QPoint& pos);
void selectClosestCurve( const QPoint& pos );
void highlightCurve(const QwtPlotCurve* closestCurve);
void resetCurveHighlighting();
void highlightCurve( const QwtPlotCurve* closestCurve );
void resetCurveHighlighting();
private slots:
void onZoomedSlot( );
void onAxisClicked(int axis, double value);
void onZoomedSlot();
void onAxisClicked( int axis, double value );
private:
struct CurveColors
@@ -81,12 +82,11 @@ private:
QColor symbolColor;
QColor symbolLineColor;
};
caf::PdmPointer<RimViewWindow> m_ownerViewWindow;
caf::PdmPointer<RimViewWindow> m_ownerViewWindow;
QPointer<RiuQwtPlotZoomer> m_zoomerLeft;
QPointer<RiuQwtPlotZoomer> m_zoomerRight;
QPointer<RiuQwtPlotZoomer> m_zoomerLeft;
QPointer<RiuQwtPlotZoomer> m_zoomerRight;
std::map<QwtPlotCurve*, CurveColors> m_originalCurveColors;
std::map<QwtPlotCurve*, double> m_originalZValues;
};

View File

@@ -2,17 +2,17 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -23,272 +23,307 @@
#include "RiaImageTools.h"
#include "RiuQwtSymbol.h"
#include "qwt_symbol.h"
#include "qwt_date.h"
#include "qwt_point_mapper.h"
#include "qwt_interval_symbol.h"
#include "qwt_painter.h"
#include "qwt_plot_intervalcurve.h"
#include "qwt_point_mapper.h"
#include "qwt_scale_map.h"
#include "qwt_interval_symbol.h"
#include "qwt_symbol.h"
#include <limits>
//--------------------------------------------------------------------------------------------------
/// Internal constants
//--------------------------------------------------------------------------------------------------
#define DOUBLE_INF std::numeric_limits<double>::infinity()
#define DOUBLE_INF std::numeric_limits<double>::infinity()
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotCurve::RiuQwtPlotCurve(const QString &title)
: QwtPlotCurve(title)
RiuQwtPlotCurve::RiuQwtPlotCurve( const QString& title )
: QwtPlotCurve( title )
{
this->setLegendAttribute(QwtPlotCurve::LegendShowLine, true);
this->setLegendAttribute(QwtPlotCurve::LegendShowSymbol, true);
this->setLegendAttribute(QwtPlotCurve::LegendShowBrush, true);
this->setLegendAttribute( QwtPlotCurve::LegendShowLine, true );
this->setLegendAttribute( QwtPlotCurve::LegendShowSymbol, true );
this->setLegendAttribute( QwtPlotCurve::LegendShowBrush, true );
this->setRenderHint(QwtPlotItem::RenderAntialiased, true);
this->setRenderHint( QwtPlotItem::RenderAntialiased, true );
m_symbolSkipPixelDistance = 10.0f;
m_errorBars = new QwtPlotIntervalCurve();
m_errorBars->setStyle(QwtPlotIntervalCurve::CurveStyle::NoCurve);
m_errorBars->setSymbol(new QwtIntervalSymbol(QwtIntervalSymbol::Bar));
m_errorBars->setItemAttribute(QwtPlotItem::Legend, false);
m_errorBars->setZ(Z_ERROR_BARS);
m_errorBars->setStyle( QwtPlotIntervalCurve::CurveStyle::NoCurve );
m_errorBars->setSymbol( new QwtIntervalSymbol( QwtIntervalSymbol::Bar ) );
m_errorBars->setItemAttribute( QwtPlotItem::Legend, false );
m_errorBars->setZ( Z_ERROR_BARS );
m_showErrorBars = true;
m_attachedToPlot = nullptr;
m_showErrorBars = true;
m_attachedToPlot = nullptr;
m_blackAndWhiteLegendIcon = false;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotCurve::~RiuQwtPlotCurve()
{
}
RiuQwtPlotCurve::~RiuQwtPlotCurve() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::setSamplesFromXValuesAndYValues(const std::vector<double>& xValues, const std::vector<double>& yValues, const std::vector<double>& yErrorValues, bool keepOnlyPositiveValues)
void RiuQwtPlotCurve::setSamplesFromXValuesAndYValues( const std::vector<double>& xValues,
const std::vector<double>& yValues,
const std::vector<double>& yErrorValues,
bool keepOnlyPositiveValues )
{
CVF_ASSERT(xValues.size() == yValues.size());
CVF_ASSERT(yErrorValues.empty() || yErrorValues.size() == xValues.size());
CVF_ASSERT( xValues.size() == yValues.size() );
CVF_ASSERT( yErrorValues.empty() || yErrorValues.size() == xValues.size() );
bool showErrorBars = m_showErrorBars && !yErrorValues.empty();
QPolygonF points;
QVector<QwtIntervalSample> errorIntervals;
std::vector< std::pair<size_t, size_t> > filteredIntervals;
bool showErrorBars = m_showErrorBars && !yErrorValues.empty();
QPolygonF points;
QVector<QwtIntervalSample> errorIntervals;
std::vector<std::pair<size_t, size_t>> filteredIntervals;
{
std::vector<double> filteredYValues;
std::vector<double> filteredXValues;
std::vector<double> filteredYErrorValues;
{
auto intervalsOfValidValues = RiaCurveDataTools::calculateIntervalsOfValidValues(yValues, keepOnlyPositiveValues);
auto intervalsOfValidValues = RiaCurveDataTools::calculateIntervalsOfValidValues( yValues,
keepOnlyPositiveValues );
RiaCurveDataTools::getValuesByIntervals(yValues, intervalsOfValidValues, &filteredYValues);
RiaCurveDataTools::getValuesByIntervals(xValues, intervalsOfValidValues, &filteredXValues);
RiaCurveDataTools::getValuesByIntervals( yValues, intervalsOfValidValues, &filteredYValues );
RiaCurveDataTools::getValuesByIntervals( xValues, intervalsOfValidValues, &filteredXValues );
if(showErrorBars) RiaCurveDataTools::getValuesByIntervals(yErrorValues, intervalsOfValidValues, &filteredYErrorValues);
if ( showErrorBars )
RiaCurveDataTools::getValuesByIntervals( yErrorValues, intervalsOfValidValues, &filteredYErrorValues );
filteredIntervals = RiaCurveDataTools::computePolyLineStartStopIndices(intervalsOfValidValues);
filteredIntervals = RiaCurveDataTools::computePolyLineStartStopIndices( intervalsOfValidValues );
}
points.reserve(static_cast<int>(filteredXValues.size()));
errorIntervals.reserve(static_cast<int>(filteredXValues.size()));
points.reserve( static_cast<int>( filteredXValues.size() ) );
errorIntervals.reserve( static_cast<int>( filteredXValues.size() ) );
for ( size_t i = 0; i < filteredXValues.size(); i++ )
{
points << QPointF(filteredXValues[i], filteredYValues[i]);
points << QPointF( filteredXValues[i], filteredYValues[i] );
if (showErrorBars && filteredYValues[i] != DOUBLE_INF && filteredYErrorValues[i] != DOUBLE_INF)
if ( showErrorBars && filteredYValues[i] != DOUBLE_INF && filteredYErrorValues[i] != DOUBLE_INF )
{
errorIntervals << QwtIntervalSample(filteredXValues[i], filteredYValues[i] - filteredYErrorValues[i], filteredYValues[i] + filteredYErrorValues[i]);
errorIntervals << QwtIntervalSample( filteredXValues[i],
filteredYValues[i] - filteredYErrorValues[i],
filteredYValues[i] + filteredYErrorValues[i] );
}
}
}
this->setSamples(points);
this->setLineSegmentStartStopIndices(filteredIntervals);
this->setSamples( points );
this->setLineSegmentStartStopIndices( filteredIntervals );
if(showErrorBars) m_errorBars->setSamples(errorIntervals);
if ( showErrorBars ) m_errorBars->setSamples( errorIntervals );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::setSamplesFromXValuesAndYValues(const std::vector<double>& xValues, const std::vector<double>& yValues, bool keepOnlyPositiveValues)
void RiuQwtPlotCurve::setSamplesFromXValuesAndYValues( const std::vector<double>& xValues,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
setSamplesFromXValuesAndYValues(xValues, yValues, std::vector<double>(), keepOnlyPositiveValues);
setSamplesFromXValuesAndYValues( xValues, yValues, std::vector<double>(), keepOnlyPositiveValues );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::setSamplesFromDatesAndYValues(const std::vector<QDateTime>& dateTimes, const std::vector<double>& yValues, bool keepOnlyPositiveValues)
void RiuQwtPlotCurve::setSamplesFromDatesAndYValues( const std::vector<QDateTime>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
setSamplesFromXValuesAndYValues(RiuQwtPlotCurve::fromQDateTime(dateTimes), yValues, std::vector<double>(), keepOnlyPositiveValues);
setSamplesFromXValuesAndYValues( RiuQwtPlotCurve::fromQDateTime( dateTimes ),
yValues,
std::vector<double>(),
keepOnlyPositiveValues );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::setSamplesFromTimeTAndYValues(const std::vector<time_t>& dateTimes, const std::vector<double>& yValues, bool keepOnlyPositiveValues)
void RiuQwtPlotCurve::setSamplesFromTimeTAndYValues( const std::vector<time_t>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues )
{
setSamplesFromXValuesAndYValues(RiuQwtPlotCurve::fromTime_t(dateTimes), yValues, std::vector<double>(), keepOnlyPositiveValues);
setSamplesFromXValuesAndYValues( RiuQwtPlotCurve::fromTime_t( dateTimes ),
yValues,
std::vector<double>(),
keepOnlyPositiveValues );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::setSamplesFromTimeTAndYValues(const std::vector<time_t>& dateTimes, const std::vector<double>& yValues, const std::vector<double>& yErrorValues, bool keepOnlyPositiveValues)
void RiuQwtPlotCurve::setSamplesFromTimeTAndYValues( const std::vector<time_t>& dateTimes,
const std::vector<double>& yValues,
const std::vector<double>& yErrorValues,
bool keepOnlyPositiveValues )
{
setSamplesFromXValuesAndYValues(RiuQwtPlotCurve::fromTime_t(dateTimes), yValues, yErrorValues, keepOnlyPositiveValues);
setSamplesFromXValuesAndYValues( RiuQwtPlotCurve::fromTime_t( dateTimes ),
yValues,
yErrorValues,
keepOnlyPositiveValues );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::drawCurve(QPainter* p, int style,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect, int from, int to) const
void RiuQwtPlotCurve::drawCurve(
QPainter* p, int style, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect, int from, int to ) const
{
size_t intervalCount = m_polyLineStartStopIndices.size();
if (intervalCount > 0)
if ( intervalCount > 0 )
{
for (size_t intIdx = 0; intIdx < intervalCount; intIdx++)
for ( size_t intIdx = 0; intIdx < intervalCount; intIdx++ )
{
if (m_polyLineStartStopIndices[intIdx].first == m_polyLineStartStopIndices[intIdx].second)
if ( m_polyLineStartStopIndices[intIdx].first == m_polyLineStartStopIndices[intIdx].second )
{
// Use a symbol to draw a single value, as a single value will not be visible
// when using QwtPlotCurve::drawCurve without symbols activated
QwtSymbol symbol(QwtSymbol::XCross);
symbol.setSize(10, 10);
QwtSymbol symbol( QwtSymbol::XCross );
symbol.setSize( 10, 10 );
QwtPlotCurve::drawSymbols(p, symbol, xMap, yMap, canvasRect, (int) m_polyLineStartStopIndices[intIdx].first, (int) m_polyLineStartStopIndices[intIdx].second);
QwtPlotCurve::drawSymbols( p,
symbol,
xMap,
yMap,
canvasRect,
(int)m_polyLineStartStopIndices[intIdx].first,
(int)m_polyLineStartStopIndices[intIdx].second );
}
else
{
QwtPlotCurve::drawCurve(p, style, xMap, yMap, canvasRect, (int) m_polyLineStartStopIndices[intIdx].first, (int) m_polyLineStartStopIndices[intIdx].second);
QwtPlotCurve::drawCurve( p,
style,
xMap,
yMap,
canvasRect,
(int)m_polyLineStartStopIndices[intIdx].first,
(int)m_polyLineStartStopIndices[intIdx].second );
}
}
}
else
{
QwtPlotCurve::drawCurve(p, style, xMap, yMap, canvasRect, from, to);
QwtPlotCurve::drawCurve( p, style, xMap, yMap, canvasRect, from, to );
}
};
//--------------------------------------------------------------------------------------------------
/// Drawing symbols but skipping if they are to close to the previous one
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::drawSymbols(QPainter *painter, const QwtSymbol &symbol,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, int from, int to) const
void RiuQwtPlotCurve::drawSymbols( QPainter* painter,
const QwtSymbol& symbol,
const QwtScaleMap& xMap,
const QwtScaleMap& yMap,
const QRectF& canvasRect,
int from,
int to ) const
{
QwtPointMapper mapper;
bool filterSymbols = m_symbolSkipPixelDistance > 0;
bool filterSymbols = m_symbolSkipPixelDistance > 0;
if (filterSymbols)
if ( filterSymbols )
{
mapper.setFlag(QwtPointMapper::RoundPoints,
QwtPainter::roundingAlignment(painter));
mapper.setFlag(QwtPointMapper::WeedOutPoints,
testPaintAttribute(QwtPlotCurve::FilterPoints));
mapper.setBoundingRect(canvasRect);
mapper.setFlag( QwtPointMapper::RoundPoints, QwtPainter::roundingAlignment( painter ) );
mapper.setFlag( QwtPointMapper::WeedOutPoints, testPaintAttribute( QwtPlotCurve::FilterPoints ) );
mapper.setBoundingRect( canvasRect );
}
const QPolygonF points = mapper.toPointsF(xMap, yMap, data(), from, to);
int pointCount = points.size();
QPolygonF pointsToDisplay;
const QPolygonF points = mapper.toPointsF( xMap, yMap, data(), from, to );
int pointCount = points.size();
QPolygonF pointsToDisplay;
if (filterSymbols)
if ( filterSymbols )
{
QPointF lastDrawnSymbolPos;
if (pointCount > 0)
if ( pointCount > 0 )
{
pointsToDisplay.push_back(points[0]);
pointsToDisplay.push_back( points[0] );
lastDrawnSymbolPos = points[0];
}
float sqSkipDist = m_symbolSkipPixelDistance * m_symbolSkipPixelDistance;
float sqSkipDist = m_symbolSkipPixelDistance * m_symbolSkipPixelDistance;
float sqSkipToLastDiff = m_symbolSkipPixelDistance / 10 * m_symbolSkipPixelDistance / 10;
for (int pIdx = 1; pIdx < pointCount - 1; ++pIdx)
for ( int pIdx = 1; pIdx < pointCount - 1; ++pIdx )
{
QPointF diff = points[pIdx] - lastDrawnSymbolPos;
float sqDistBetweenSymbols = diff.x()*diff.x() + diff.y()*diff.y();
QPointF diff = points[pIdx] - lastDrawnSymbolPos;
float sqDistBetweenSymbols = diff.x() * diff.x() + diff.y() * diff.y();
if (sqDistBetweenSymbols > sqSkipDist)
if ( sqDistBetweenSymbols > sqSkipDist )
{
if (pIdx == pointCount - 2)
{
QPointF diffToBack = points.back() - points[pIdx];
if ( pIdx == pointCount - 2 )
{
QPointF diffToBack = points.back() - points[pIdx];
float sqDistToBack = diffToBack.x() * diffToBack.x() + diffToBack.y() * diffToBack.y();
if (sqDistToBack < sqSkipToLastDiff)
continue;
}
pointsToDisplay.push_back(points[pIdx]);
if ( sqDistToBack < sqSkipToLastDiff ) continue;
}
pointsToDisplay.push_back( points[pIdx] );
lastDrawnSymbolPos = points[pIdx];
}
}
if (pointCount > 1) pointsToDisplay.push_back(points.back());
if ( pointCount > 1 ) pointsToDisplay.push_back( points.back() );
}
else
{
pointsToDisplay = points;
}
if (pointsToDisplay.size() > 0)
if ( pointsToDisplay.size() > 0 )
{
symbol.drawSymbols(painter, pointsToDisplay);
symbol.drawSymbols( painter, pointsToDisplay );
const RiuQwtSymbol* sym = dynamic_cast<const RiuQwtSymbol*>(&symbol);
const RiuQwtSymbol* sym = dynamic_cast<const RiuQwtSymbol*>( &symbol );
if (sym && !sym->label().isEmpty())
if ( sym && !sym->label().isEmpty() )
{
for (auto& pt : pointsToDisplay)
for ( auto& pt : pointsToDisplay )
{
sym->renderSymbolLabel(painter, pt);
sym->renderSymbolLabel( painter, pt );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::setLineSegmentStartStopIndices(const std::vector< std::pair<size_t, size_t> >& lineSegmentStartStopIndices)
void RiuQwtPlotCurve::setLineSegmentStartStopIndices(
const std::vector<std::pair<size_t, size_t>>& lineSegmentStartStopIndices )
{
m_polyLineStartStopIndices = lineSegmentStartStopIndices;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::setSymbolSkipPixelDistance(float distance)
void RiuQwtPlotCurve::setSymbolSkipPixelDistance( float distance )
{
m_symbolSkipPixelDistance = distance >= 0.0f ? distance: 0.0f;
m_symbolSkipPixelDistance = distance >= 0.0f ? distance : 0.0f;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::attach(QwtPlot *plot)
void RiuQwtPlotCurve::attach( QwtPlot* plot )
{
QwtPlotItem::attach(plot);
if(m_showErrorBars) m_errorBars->attach(plot);
QwtPlotItem::attach( plot );
if ( m_showErrorBars ) m_errorBars->attach( plot );
m_attachedToPlot = plot;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::detach()
{
@@ -298,92 +333,94 @@ void RiuQwtPlotCurve::detach()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::clearErrorBars()
{
m_errorBars->setSamples(nullptr);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::showErrorBars(bool show)
{
m_showErrorBars = show;
if (m_showErrorBars && m_attachedToPlot) m_errorBars->attach(m_attachedToPlot);
else m_errorBars->detach();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::setErrorBarsColor(QColor color)
{
QwtIntervalSymbol* newSymbol = new QwtIntervalSymbol(QwtIntervalSymbol::Bar);
newSymbol->setPen(QPen(color));
m_errorBars->setSymbol(newSymbol);
m_errorBars->setSamples( nullptr );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::setAppearance(LineStyleEnum lineStyle,
CurveInterpolationEnum interpolationType,
int requestedCurveThickness,
const QColor& curveColor)
void RiuQwtPlotCurve::showErrorBars( bool show )
{
m_showErrorBars = show;
if ( m_showErrorBars && m_attachedToPlot )
m_errorBars->attach( m_attachedToPlot );
else
m_errorBars->detach();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::setErrorBarsColor( QColor color )
{
QwtIntervalSymbol* newSymbol = new QwtIntervalSymbol( QwtIntervalSymbol::Bar );
newSymbol->setPen( QPen( color ) );
m_errorBars->setSymbol( newSymbol );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::setAppearance( LineStyleEnum lineStyle,
CurveInterpolationEnum interpolationType,
int requestedCurveThickness,
const QColor& curveColor )
{
QwtPlotCurve::CurveStyle curveStyle = QwtPlotCurve::NoCurve;
Qt::PenStyle penStyle = Qt::NoPen;
Qt::PenStyle penStyle = Qt::NoPen;
// Qwt bug workaround (#4135): need to set 0 curve thickness for STYLE_NONE
int curveThickness = 0;
if (lineStyle != STYLE_NONE)
if ( lineStyle != STYLE_NONE )
{
curveThickness = requestedCurveThickness;
switch (interpolationType)
switch ( interpolationType )
{
case INTERPOLATION_STEP_LEFT:
curveStyle = QwtPlotCurve::Steps;
setCurveAttribute(QwtPlotCurve::Inverted, false);
break;
case INTERPOLATION_POINT_TO_POINT: // Fall through
default:
curveStyle = QwtPlotCurve::Lines;
break;
case INTERPOLATION_STEP_LEFT:
curveStyle = QwtPlotCurve::Steps;
setCurveAttribute( QwtPlotCurve::Inverted, false );
break;
case INTERPOLATION_POINT_TO_POINT: // Fall through
default:
curveStyle = QwtPlotCurve::Lines;
break;
}
switch (lineStyle)
switch ( lineStyle )
{
case STYLE_SOLID:
penStyle = Qt::SolidLine;
break;
case STYLE_DASH:
penStyle = Qt::DashLine;
break;
case STYLE_DOT:
penStyle = Qt::DotLine;
break;
case STYLE_DASH_DOT:
penStyle = Qt::DashDotLine;
break;
case STYLE_SOLID:
penStyle = Qt::SolidLine;
break;
case STYLE_DASH:
penStyle = Qt::DashLine;
break;
case STYLE_DOT:
penStyle = Qt::DotLine;
break;
case STYLE_DASH_DOT:
penStyle = Qt::DashDotLine;
break;
default:
break;
default:
break;
}
}
QPen curvePen(curveColor);
curvePen.setWidth(curveThickness);
curvePen.setStyle(penStyle);
QPen curvePen( curveColor );
curvePen.setWidth( curveThickness );
curvePen.setStyle( penStyle );
setPen(curvePen);
setStyle(curveStyle);
setPen( curvePen );
setStyle( curveStyle );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotCurve::setBlackAndWhiteLegendIcon(bool blackAndWhite)
void RiuQwtPlotCurve::setBlackAndWhiteLegendIcon( bool blackAndWhite )
{
m_blackAndWhiteLegendIcon = blackAndWhite;
}
@@ -391,34 +428,34 @@ void RiuQwtPlotCurve::setBlackAndWhiteLegendIcon(bool blackAndWhite)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QwtGraphic RiuQwtPlotCurve::legendIcon(int index, const QSizeF& size) const
QwtGraphic RiuQwtPlotCurve::legendIcon( int index, const QSizeF& size ) const
{
QwtGraphic icon = QwtPlotCurve::legendIcon(index, size);
if (m_blackAndWhiteLegendIcon)
QwtGraphic icon = QwtPlotCurve::legendIcon( index, size );
if ( m_blackAndWhiteLegendIcon )
{
QImage image = icon.toImage();
RiaImageTools::makeGrayScale(image);
QPainter painter(&icon);
painter.drawImage(QPoint(0, 0), image);
RiaImageTools::makeGrayScale( image );
QPainter painter( &icon );
painter.drawImage( QPoint( 0, 0 ), image );
}
return icon;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RiuQwtPlotCurve::fromQDateTime(const std::vector<QDateTime>& dateTimes)
std::vector<double> RiuQwtPlotCurve::fromQDateTime( const std::vector<QDateTime>& dateTimes )
{
std::vector<double> doubleValues;
if (!dateTimes.empty())
if ( !dateTimes.empty() )
{
doubleValues.reserve(dateTimes.size());
doubleValues.reserve( dateTimes.size() );
for (const auto& dt : dateTimes)
for ( const auto& dt : dateTimes )
{
doubleValues.push_back(QwtDate::toDouble(dt));
doubleValues.push_back( QwtDate::toDouble( dt ) );
}
}
@@ -426,20 +463,22 @@ std::vector<double> RiuQwtPlotCurve::fromQDateTime(const std::vector<QDateTime>&
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RiuQwtPlotCurve::fromTime_t(const std::vector<time_t>& timeSteps)
std::vector<double> RiuQwtPlotCurve::fromTime_t( const std::vector<time_t>& timeSteps )
{
std::vector<double> doubleValues;
if (!timeSteps.empty())
if ( !timeSteps.empty() )
{
doubleValues.reserve(timeSteps.size());
for (const auto& time : timeSteps)
doubleValues.reserve( timeSteps.size() );
for ( const auto& time : timeSteps )
{
double milliSecSinceEpoch = time * 1000; // This is kind of hack, as the c++ standard does not state what time_t is. "Almost always" secs since epoch according to cppreference.com
doubleValues.push_back(milliSecSinceEpoch);
double milliSecSinceEpoch = time *
1000; // This is kind of hack, as the c++ standard does not state what time_t
// is. "Almost always" secs since epoch according to cppreference.com
doubleValues.push_back( milliSecSinceEpoch );
}
}

View File

@@ -2,26 +2,26 @@
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "qwt_symbol.h"
#include "qwt_plot_curve.h"
#include "qwt_plot_intervalcurve.h"
#include "qwt_symbol.h"
class RiuErrorBarsQwtPlotCurve;
@@ -74,71 +74,75 @@ public:
};
public:
explicit RiuQwtPlotCurve(const QString &title = QString::null);
explicit RiuQwtPlotCurve( const QString& title = QString::null );
~RiuQwtPlotCurve() override;
void setSamplesFromXValuesAndYValues(const std::vector<double>& xValues,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues);
void setSamplesFromXValuesAndYValues( const std::vector<double>& xValues,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues );
void setSamplesFromXValuesAndYValues(const std::vector<double>& xValues,
const std::vector<double>& yValues,
const std::vector<double>& yErrorValues,
bool keepOnlyPositiveValues);
void setSamplesFromDatesAndYValues(const std::vector<QDateTime>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues);
void setSamplesFromXValuesAndYValues( const std::vector<double>& xValues,
const std::vector<double>& yValues,
const std::vector<double>& yErrorValues,
bool keepOnlyPositiveValues );
void setSamplesFromTimeTAndYValues(const std::vector<time_t>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues);
void setSamplesFromDatesAndYValues( const std::vector<QDateTime>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues );
void setSamplesFromTimeTAndYValues(const std::vector<time_t>& dateTimes,
const std::vector<double>& yValues,
const std::vector<double>& yErrorValues,
bool keepOnlyPositiveValues);
void setSamplesFromTimeTAndYValues( const std::vector<time_t>& dateTimes,
const std::vector<double>& yValues,
bool keepOnlyPositiveValues );
void setLineSegmentStartStopIndices(const std::vector< std::pair<size_t, size_t> >& lineSegmentStartStopIndices);
void setSamplesFromTimeTAndYValues( const std::vector<time_t>& dateTimes,
const std::vector<double>& yValues,
const std::vector<double>& yErrorValues,
bool keepOnlyPositiveValues );
void setSymbolSkipPixelDistance(float distance);
void setLineSegmentStartStopIndices( const std::vector<std::pair<size_t, size_t>>& lineSegmentStartStopIndices );
void attach(QwtPlot *plot);
void detach();
void clearErrorBars();
void showErrorBars(bool show);
void setErrorBarsColor(QColor color);
void setSymbolSkipPixelDistance( float distance );
void setAppearance(LineStyleEnum lineStyle,
CurveInterpolationEnum interpolationType,
int curveThickness,
const QColor& curveColor);
void setBlackAndWhiteLegendIcon(bool blackAndWhite);
QwtGraphic legendIcon(int index, const QSizeF& size) const override;
void attach( QwtPlot* plot );
void detach();
void clearErrorBars();
void showErrorBars( bool show );
void setErrorBarsColor( QColor color );
void setAppearance( LineStyleEnum lineStyle,
CurveInterpolationEnum interpolationType,
int curveThickness,
const QColor& curveColor );
void setBlackAndWhiteLegendIcon( bool blackAndWhite );
QwtGraphic legendIcon( int index, const QSizeF& size ) const override;
protected:
void drawCurve(QPainter* p, int style,
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
const QRectF& canvasRect,
int from, int to) const override;
void drawCurve( QPainter* p,
int style,
const QwtScaleMap& xMap,
const QwtScaleMap& yMap,
const QRectF& canvasRect,
int from,
int to ) const override;
void drawSymbols(QPainter *p, const QwtSymbol &symbol,
const QwtScaleMap &xMap,
const QwtScaleMap &yMap,
const QRectF &canvasRect,
int from, int to) const override;
void drawSymbols( QPainter* p,
const QwtSymbol& symbol,
const QwtScaleMap& xMap,
const QwtScaleMap& yMap,
const QRectF& canvasRect,
int from,
int to ) const override;
private:
static std::vector<double> fromQDateTime(const std::vector<QDateTime>& dateTimes);
static std::vector<double> fromTime_t(const std::vector<time_t>& timeSteps);
static std::vector<double> fromQDateTime( const std::vector<QDateTime>& dateTimes );
static std::vector<double> fromTime_t( const std::vector<time_t>& timeSteps );
private:
std::vector< std::pair<size_t, size_t> > m_polyLineStartStopIndices;
float m_symbolSkipPixelDistance;
std::vector<std::pair<size_t, size_t>> m_polyLineStartStopIndices;
float m_symbolSkipPixelDistance;
bool m_showErrorBars;
QwtPlotIntervalCurve* m_errorBars;
QwtPlot* m_attachedToPlot;
bool m_blackAndWhiteLegendIcon;
bool m_showErrorBars;
QwtPlotIntervalCurve* m_errorBars;
QwtPlot* m_attachedToPlot;
bool m_blackAndWhiteLegendIcon;
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -21,10 +21,7 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotItemGroup::RiuQwtPlotItemGroup()
{
}
RiuQwtPlotItemGroup::RiuQwtPlotItemGroup() {}
//--------------------------------------------------------------------------------------------------
///
@@ -32,11 +29,11 @@ RiuQwtPlotItemGroup::RiuQwtPlotItemGroup()
RiuQwtPlotItemGroup::~RiuQwtPlotItemGroup()
{
this->detach();
for (QwtPlotItem* item : m_plotItems)
for ( QwtPlotItem* item : m_plotItems )
{
delete item;
}
for (QwtPlotItem* legendItem : m_legendItems)
for ( QwtPlotItem* legendItem : m_legendItems )
{
delete legendItem;
}
@@ -45,27 +42,30 @@ RiuQwtPlotItemGroup::~RiuQwtPlotItemGroup()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotItemGroup::addPlotItem(QwtPlotItem* plotItem)
void RiuQwtPlotItemGroup::addPlotItem( QwtPlotItem* plotItem )
{
m_plotItems.push_back(plotItem);
m_plotItems.push_back( plotItem );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotItemGroup::addLegendItem(QwtPlotItem* legendItem)
void RiuQwtPlotItemGroup::addLegendItem( QwtPlotItem* legendItem )
{
m_legendItems.push_back(legendItem);
m_legendItems.push_back( legendItem );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotItemGroup::draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const
void RiuQwtPlotItemGroup::draw( QPainter* painter,
const QwtScaleMap& xMap,
const QwtScaleMap& yMap,
const QRectF& canvasRect ) const
{
for (const QwtPlotItem* item : m_plotItems)
for ( const QwtPlotItem* item : m_plotItems )
{
item->draw(painter, xMap, yMap, canvasRect);
item->draw( painter, xMap, yMap, canvasRect );
}
}
@@ -75,9 +75,9 @@ void RiuQwtPlotItemGroup::draw(QPainter *painter, const QwtScaleMap &xMap, const
QRectF RiuQwtPlotItemGroup::boundingRect() const
{
QRectF totalBoundingRect;
for (const QwtPlotItem* item : m_plotItems)
for ( const QwtPlotItem* item : m_plotItems )
{
totalBoundingRect = totalBoundingRect.united(item->boundingRect());
totalBoundingRect = totalBoundingRect.united( item->boundingRect() );
}
return totalBoundingRect;
}
@@ -85,26 +85,25 @@ QRectF RiuQwtPlotItemGroup::boundingRect() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QwtGraphic RiuQwtPlotItemGroup::legendIcon(int index, const QSizeF& size) const
QwtGraphic RiuQwtPlotItemGroup::legendIcon( int index, const QSizeF& size ) const
{
QwtGraphic graphic;
graphic.setDefaultSize(size);
graphic.setDefaultSize( size );
QPainter painter(&graphic);
painter.setRenderHint(QPainter::Antialiasing,
testRenderHint(QwtPlotItem::RenderAntialiased));
QPainter painter( &graphic );
painter.setRenderHint( QPainter::Antialiasing, testRenderHint( QwtPlotItem::RenderAntialiased ) );
for (QwtPlotItem* legendItem : m_legendItems)
for ( QwtPlotItem* legendItem : m_legendItems )
{
QwtGraphic subGraphic = legendItem->legendIcon(index, legendItem->legendIconSize());
QRectF boundingRect = legendItem->boundingRect();
QImage subImage = subGraphic.toImage();
QRectF subRect(0.0, 0.0, legendItem->legendIconSize().width(), legendItem->legendIconSize().height());
QwtGraphic subGraphic = legendItem->legendIcon( index, legendItem->legendIconSize() );
QRectF boundingRect = legendItem->boundingRect();
QImage subImage = subGraphic.toImage();
QRectF subRect( 0.0, 0.0, legendItem->legendIconSize().width(), legendItem->legendIconSize().height() );
// Symbols may not have a bounding width/height. Force the width height to be the same as the icon
boundingRect.setWidth(subRect.width());
boundingRect.setHeight(subRect.height());
boundingRect.setWidth( subRect.width() );
boundingRect.setHeight( subRect.height() );
// Paint onto the existing icon
painter.drawImage(boundingRect, subImage, subRect);
painter.drawImage( boundingRect, subImage, subRect );
}
return graphic;
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -26,7 +26,7 @@ class QPainter;
//==================================================================================================
/// Class that can combine multiple Qwt plot items into one Qwt graphic with a combined legend.
///
///
//==================================================================================================
class RiuQwtPlotItemGroup : public QwtPlotItem
{
@@ -34,16 +34,18 @@ public:
RiuQwtPlotItemGroup();
~RiuQwtPlotItemGroup() override;
void addPlotItem(QwtPlotItem* plotItem);
void addLegendItem(QwtPlotItem* legendItem);
void addPlotItem( QwtPlotItem* plotItem );
void addLegendItem( QwtPlotItem* legendItem );
int rtti() const override { return 5000; }
void draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const override;
QRectF boundingRect() const override;
QwtGraphic legendIcon(int index, const QSizeF &size) const override;
int rtti() const override
{
return 5000;
}
void draw( QPainter* painter, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect ) const override;
QRectF boundingRect() const override;
QwtGraphic legendIcon( int index, const QSizeF& size ) const override;
private:
std::vector<QwtPlotItem*> m_plotItems;
std::vector<QwtPlotItem*> m_legendItems;
};

View File

@@ -32,93 +32,93 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotTools::setCommonPlotBehaviour(QwtPlot* plot)
void RiuQwtPlotTools::setCommonPlotBehaviour( QwtPlot* plot )
{
// Plot background and frame look
QPalette newPalette(plot->palette());
newPalette.setColor(QPalette::Background, Qt::white);
plot->setPalette(newPalette);
QPalette newPalette( plot->palette() );
newPalette.setColor( QPalette::Background, Qt::white );
plot->setPalette( newPalette );
plot->setAutoFillBackground(true);
plot->setCanvasBackground(Qt::white);
plot->setAutoFillBackground( true );
plot->setCanvasBackground( Qt::white );
QFrame* canvasFrame = dynamic_cast<QFrame*>(plot->canvas());
if (canvasFrame)
QFrame* canvasFrame = dynamic_cast<QFrame*>( plot->canvas() );
if ( canvasFrame )
{
canvasFrame->setFrameShape(QFrame::NoFrame);
canvasFrame->setFrameShape( QFrame::NoFrame );
}
// Grid
QwtPlotGrid* grid = new QwtPlotGrid;
grid->attach(plot);
QPen gridPen(Qt::SolidLine);
gridPen.setColor(Qt::lightGray);
grid->setPen(gridPen);
grid->attach( plot );
QPen gridPen( Qt::SolidLine );
gridPen.setColor( Qt::lightGray );
grid->setPen( gridPen );
// Axis number font
QFont axisFont = plot->axisFont(QwtPlot::xBottom);
axisFont.setPointSize(10);
QFont axisFont = plot->axisFont( QwtPlot::xBottom );
axisFont.setPointSize( 10 );
plot->setAxisFont(QwtPlot::xBottom, axisFont);
plot->setAxisFont(QwtPlot::xTop, axisFont);
plot->setAxisFont(QwtPlot::yLeft, axisFont);
plot->setAxisFont(QwtPlot::yRight, axisFont);
plot->setAxisFont( QwtPlot::xBottom, axisFont );
plot->setAxisFont( QwtPlot::xTop, axisFont );
plot->setAxisFont( QwtPlot::yLeft, axisFont );
plot->setAxisFont( QwtPlot::yRight, axisFont );
// Axis title font
std::vector<QwtPlot::Axis> axes = {QwtPlot::xBottom, QwtPlot::xTop, QwtPlot::yLeft, QwtPlot::yRight};
for (QwtPlot::Axis axis : axes)
for ( QwtPlot::Axis axis : axes )
{
QwtText axisTitle = plot->axisTitle(axis);
QwtText axisTitle = plot->axisTitle( axis );
QFont axisTitleFont = axisTitle.font();
axisTitleFont.setPointSize(10);
axisTitleFont.setBold(false);
axisTitle.setFont(axisTitleFont);
axisTitle.setRenderFlags(Qt::AlignRight);
axisTitleFont.setPointSize( 10 );
axisTitleFont.setBold( false );
axisTitle.setFont( axisTitleFont );
axisTitle.setRenderFlags( Qt::AlignRight );
plot->setAxisTitle(axis, axisTitle);
plot->setAxisTitle( axis, axisTitle );
}
// Set a focus policy to allow it taking key press events.
// This is not strictly necessary since this widget inherit QwtPlot
// which already has a focus policy.
// However, for completeness we still do it here.
plot->setFocusPolicy(Qt::WheelFocus);
plot->setFocusPolicy( Qt::WheelFocus );
// Enable mousetracking and event filter
plot->canvas()->setMouseTracking(true);
plot->canvas()->installEventFilter(plot);
plot->plotLayout()->setAlignCanvasToScales(true);
plot->canvas()->setMouseTracking( true );
plot->canvas()->installEventFilter( plot );
plot->plotLayout()->setAlignCanvasToScales( true );
plot->setContentsMargins(4, 4, 4, 4);
plot->setContentsMargins( 4, 4, 4, 4 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotTools::setDefaultAxes(QwtPlot* plot)
void RiuQwtPlotTools::setDefaultAxes( QwtPlot* plot )
{
plot->enableAxis(QwtPlot::xBottom, true);
plot->enableAxis(QwtPlot::yLeft, true);
plot->enableAxis(QwtPlot::xTop, false);
plot->enableAxis(QwtPlot::yRight, false);
plot->enableAxis( QwtPlot::xBottom, true );
plot->enableAxis( QwtPlot::yLeft, true );
plot->enableAxis( QwtPlot::xTop, false );
plot->enableAxis( QwtPlot::yRight, false );
plot->setAxisMaxMinor(QwtPlot::xBottom, 2);
plot->setAxisMaxMinor(QwtPlot::yLeft, 3);
plot->setAxisMaxMinor( QwtPlot::xBottom, 2 );
plot->setAxisMaxMinor( QwtPlot::yLeft, 3 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotTools::enableDateBasedBottomXAxis(QwtPlot* plot,
const QString& dateFormat,
const QString& timeFormat,
RiaQDateTimeTools::DateFormatComponents dateComponents,
RiaQDateTimeTools::TimeFormatComponents timeComponents)
void RiuQwtPlotTools::enableDateBasedBottomXAxis( QwtPlot* plot,
const QString& dateFormat,
const QString& timeFormat,
RiaQDateTimeTools::DateFormatComponents dateComponents,
RiaQDateTimeTools::TimeFormatComponents timeComponents )
{
QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw(Qt::UTC);
QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw( Qt::UTC );
std::set<QwtDate::IntervalType> intervals = {QwtDate::Year,
QwtDate::Month,
@@ -129,66 +129,78 @@ void RiuQwtPlotTools::enableDateBasedBottomXAxis(QwtPlot* plot,
QwtDate::Second,
QwtDate::Millisecond};
for (QwtDate::IntervalType interval : intervals)
for ( QwtDate::IntervalType interval : intervals )
{
scaleDraw->setDateFormat(interval, dateTimeFormatForInterval(interval, dateFormat, timeFormat, dateComponents, timeComponents));
scaleDraw->setDateFormat( interval,
dateTimeFormatForInterval( interval,
dateFormat,
timeFormat,
dateComponents,
timeComponents ) );
}
QwtDateScaleEngine* scaleEngine = new QwtDateScaleEngine(Qt::UTC);
plot->setAxisScaleEngine(QwtPlot::xBottom, scaleEngine);
plot->setAxisScaleDraw(QwtPlot::xBottom, scaleDraw);
QwtDateScaleEngine* scaleEngine = new QwtDateScaleEngine( Qt::UTC );
plot->setAxisScaleEngine( QwtPlot::xBottom, scaleEngine );
plot->setAxisScaleDraw( QwtPlot::xBottom, scaleDraw );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiuQwtPlotTools::dateTimeFormatForInterval(QwtDate::IntervalType interval,
const QString& dateFormat,
const QString& timeFormat,
RiaQDateTimeTools::DateFormatComponents dateComponents,
RiaQDateTimeTools::TimeFormatComponents timeComponents)
QString RiuQwtPlotTools::dateTimeFormatForInterval( QwtDate::IntervalType interval,
const QString& dateFormat,
const QString& timeFormat,
RiaQDateTimeTools::DateFormatComponents dateComponents,
RiaQDateTimeTools::TimeFormatComponents timeComponents )
{
if (dateComponents != RiaQDateTimeTools::DATE_FORMAT_UNSPECIFIED && timeComponents != RiaQDateTimeTools::TIME_FORMAT_UNSPECIFIED)
{
return RiaQDateTimeTools::timeFormatString(timeFormat, timeComponents) + "\n" +
RiaQDateTimeTools::dateFormatString(dateFormat, dateComponents);
if ( dateComponents != RiaQDateTimeTools::DATE_FORMAT_UNSPECIFIED &&
timeComponents != RiaQDateTimeTools::TIME_FORMAT_UNSPECIFIED )
{
return RiaQDateTimeTools::timeFormatString( timeFormat, timeComponents ) + "\n" +
RiaQDateTimeTools::dateFormatString( dateFormat, dateComponents );
}
else
{
switch ( interval )
{
case QwtDate::Millisecond:
return RiaQDateTimeTools::timeFormatString( timeFormat,
RiaQDateTimeTools::TIME_FORMAT_HOUR_MINUTE_SECOND_MILLISECOND );
case QwtDate::Second:
return RiaQDateTimeTools::timeFormatString( timeFormat,
RiaQDateTimeTools::TIME_FORMAT_HOUR_MINUTE_SECOND );
case QwtDate::Minute:
{
QString fullFormat = RiaQDateTimeTools::timeFormatString( timeFormat,
RiaQDateTimeTools::TIME_FORMAT_HOUR_MINUTE );
fullFormat += "\n";
fullFormat += RiaQDateTimeTools::dateFormatString( dateFormat,
RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY );
return fullFormat;
}
case QwtDate::Hour:
{
QString fullFormat = RiaQDateTimeTools::timeFormatString( timeFormat,
RiaQDateTimeTools::TIME_FORMAT_HOUR );
if ( !fullFormat.endsWith( "AP" ) )
{
fullFormat += ":00";
}
fullFormat += "\n";
fullFormat += RiaQDateTimeTools::dateFormatString( dateFormat,
RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY );
return fullFormat;
}
case QwtDate::Day:
return RiaQDateTimeTools::dateFormatString( dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY );
case QwtDate::Week:
return RiaQDateTimeTools::dateFormatString( dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH );
case QwtDate::Month:
return RiaQDateTimeTools::dateFormatString( dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH );
case QwtDate::Year:
return RiaQDateTimeTools::dateFormatString( dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR );
default:
return RiaQDateTimeTools::dateFormatString( dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY );
}
}
else
{
switch (interval)
{
case QwtDate::Millisecond:
return RiaQDateTimeTools::timeFormatString(timeFormat, RiaQDateTimeTools::TIME_FORMAT_HOUR_MINUTE_SECOND_MILLISECOND);
case QwtDate::Second:
return RiaQDateTimeTools::timeFormatString(timeFormat, RiaQDateTimeTools::TIME_FORMAT_HOUR_MINUTE_SECOND);
case QwtDate::Minute:
{
QString fullFormat = RiaQDateTimeTools::timeFormatString(timeFormat, RiaQDateTimeTools::TIME_FORMAT_HOUR_MINUTE);
fullFormat += "\n";
fullFormat += RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY);
return fullFormat;
}
case QwtDate::Hour:
{
QString fullFormat = RiaQDateTimeTools::timeFormatString(timeFormat, RiaQDateTimeTools::TIME_FORMAT_HOUR);
if (!fullFormat.endsWith("AP"))
{
fullFormat += ":00";
}
fullFormat += "\n";
fullFormat += RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY);
return fullFormat;
}
case QwtDate::Day:
return RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY);
case QwtDate::Week:
return RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH);
case QwtDate::Month:
return RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH);
case QwtDate::Year:
return RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR);
default:
return RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY);
}
}
}

View File

@@ -25,17 +25,18 @@ class QwtPlot;
class RiuQwtPlotTools
{
public:
static void setCommonPlotBehaviour(QwtPlot* plot);
static void setDefaultAxes(QwtPlot* plot);
static void enableDateBasedBottomXAxis(QwtPlot* plot,
const QString& dateFormat,
const QString& timeFormat,
RiaQDateTimeTools::DateFormatComponents dateComponents = RiaQDateTimeTools::DATE_FORMAT_UNSPECIFIED,
RiaQDateTimeTools::TimeFormatComponents timeComponents = RiaQDateTimeTools::TIME_FORMAT_UNSPECIFIED);
static void setCommonPlotBehaviour( QwtPlot* plot );
static void setDefaultAxes( QwtPlot* plot );
static void enableDateBasedBottomXAxis(
QwtPlot* plot,
const QString& dateFormat,
const QString& timeFormat,
RiaQDateTimeTools::DateFormatComponents dateComponents = RiaQDateTimeTools::DATE_FORMAT_UNSPECIFIED,
RiaQDateTimeTools::TimeFormatComponents timeComponents = RiaQDateTimeTools::TIME_FORMAT_UNSPECIFIED );
static QString dateTimeFormatForInterval(QwtDate::IntervalType interval,
const QString& dateFormat,
const QString& timeFormat,
RiaQDateTimeTools::DateFormatComponents dateComponents,
RiaQDateTimeTools::TimeFormatComponents timeComponents);
static QString dateTimeFormatForInterval( QwtDate::IntervalType interval,
const QString& dateFormat,
const QString& timeFormat,
RiaQDateTimeTools::DateFormatComponents dateComponents,
RiaQDateTimeTools::TimeFormatComponents timeComponents );
};

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -21,48 +21,49 @@
#include <QEvent>
#include <QWheelEvent>
#define RIU_SCROLLWHEEL_ZOOMFACTOR 1.1
#define RIU_SCROLLWHEEL_PANFACTOR 0.1
#define RIU_SCROLLWHEEL_ZOOMFACTOR 1.1
#define RIU_SCROLLWHEEL_PANFACTOR 0.1
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWheelZoomer::RiuQwtPlotWheelZoomer(QwtPlot* plot): QObject(plot), m_plot(plot)
RiuQwtPlotWheelZoomer::RiuQwtPlotWheelZoomer( QwtPlot* plot )
: QObject( plot )
, m_plot( plot )
{
plot->canvas()->installEventFilter(this);
plot->canvas()->installEventFilter( this );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void zoomOnAxis(QwtPlot* plot, QwtPlot::Axis axis, double zoomFactor, int eventPos)
void zoomOnAxis( QwtPlot* plot, QwtPlot::Axis axis, double zoomFactor, int eventPos )
{
QwtScaleMap scaleMap = plot->canvasMap(axis);
double zoomCenter = scaleMap.invTransform(eventPos);
double newMin = zoomCenter - zoomFactor * (zoomCenter - scaleMap.s1());
double newMax = zoomCenter + zoomFactor * (-zoomCenter + scaleMap.s2());
plot->setAxisScale(axis, newMin, newMax);
QwtScaleMap scaleMap = plot->canvasMap( axis );
double zoomCenter = scaleMap.invTransform( eventPos );
double newMin = zoomCenter - zoomFactor * ( zoomCenter - scaleMap.s1() );
double newMax = zoomCenter + zoomFactor * ( -zoomCenter + scaleMap.s2() );
plot->setAxisScale( axis, newMin, newMax );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuQwtPlotWheelZoomer::eventFilter(QObject * watched, QEvent * event)
bool RiuQwtPlotWheelZoomer::eventFilter( QObject* watched, QEvent* event )
{
QWheelEvent* wheelEvent = dynamic_cast<QWheelEvent*>(event);
QWheelEvent* wheelEvent = dynamic_cast<QWheelEvent*>( event );
if ( wheelEvent )
{
double zoomFactor = 1.0/RIU_SCROLLWHEEL_ZOOMFACTOR;
double zoomFactor = 1.0 / RIU_SCROLLWHEEL_ZOOMFACTOR;
if ( wheelEvent->delta() > 0 )
{
zoomFactor = RIU_SCROLLWHEEL_ZOOMFACTOR;
}
zoomOnAxis(m_plot, QwtPlot::xBottom, zoomFactor, wheelEvent->pos().x());
zoomOnAxis(m_plot, QwtPlot::xTop, zoomFactor, wheelEvent->pos().x());
zoomOnAxis(m_plot, QwtPlot::yLeft, zoomFactor, wheelEvent->pos().y());
zoomOnAxis(m_plot, QwtPlot::yRight, zoomFactor, wheelEvent->pos().y());
zoomOnAxis( m_plot, QwtPlot::xBottom, zoomFactor, wheelEvent->pos().x() );
zoomOnAxis( m_plot, QwtPlot::xTop, zoomFactor, wheelEvent->pos().x() );
zoomOnAxis( m_plot, QwtPlot::yLeft, zoomFactor, wheelEvent->pos().y() );
zoomOnAxis( m_plot, QwtPlot::yRight, zoomFactor, wheelEvent->pos().y() );
m_plot->replot();
emit zoomUpdated();
@@ -70,4 +71,3 @@ bool RiuQwtPlotWheelZoomer::eventFilter(QObject * watched, QEvent * event)
return false;
}

View File

@@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -24,17 +24,15 @@ class QEvent;
class RiuQwtPlotWheelZoomer : public QObject
{
Q_OBJECT
Q_OBJECT
public:
RiuQwtPlotWheelZoomer(QwtPlot* plot);
RiuQwtPlotWheelZoomer( QwtPlot* plot );
bool eventFilter(QObject * watched, QEvent * event) override;
bool eventFilter( QObject* watched, QEvent* event ) override;
signals:
signals:
void zoomUpdated();
private:
QwtPlot* m_plot;
};

View File

@@ -22,17 +22,17 @@
class RiuQwtPlotZoomer : public QwtPlotZoomer
{
public:
RiuQwtPlotZoomer(QWidget* canvas, bool doReplot = true)
: QwtPlotZoomer(canvas, doReplot)
RiuQwtPlotZoomer( QWidget* canvas, bool doReplot = true )
: QwtPlotZoomer( canvas, doReplot )
{
}
bool isActiveAndValid() const
{
if (!isActive()) return false;
if ( !isActive() ) return false;
auto currentSelection = selection();
return accept(currentSelection);
return accept( currentSelection );
}
protected:
@@ -41,17 +41,17 @@ protected:
return QwtPlotZoomer::minZoomSize() / 10.0e6;
}
bool accept(QPolygon& pa) const override
bool accept( QPolygon& pa ) const override
{
if (pa.count() < 2) return false;
if ( pa.count() < 2 ) return false;
QRect rect = QRect(pa[0], pa[int(pa.count()) - 1]);
QRect rect = QRect( pa[0], pa[int( pa.count() ) - 1] );
rect = rect.normalized();
// This size is larger than the minSize value in the base class
const int minSize = 10;
if (rect.width() < minSize && rect.height() < minSize) return false;
if ( rect.width() < minSize && rect.height() < minSize ) return false;
return QwtPlotZoomer::accept(pa);
return QwtPlotZoomer::accept( pa );
}
};

View File

@@ -8,30 +8,29 @@
#include <qwt_scale_widget.h>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuQwtScalePicker::RiuQwtScalePicker( QwtPlot *plot ):
QObject( plot )
RiuQwtScalePicker::RiuQwtScalePicker( QwtPlot* plot )
: QObject( plot )
{
for ( uint i = 0; i < QwtPlot::axisCnt; i++ )
{
QwtScaleWidget *scaleWidget = plot->axisWidget( i );
if ( scaleWidget )
scaleWidget->installEventFilter( this );
QwtScaleWidget* scaleWidget = plot->axisWidget( i );
if ( scaleWidget ) scaleWidget->installEventFilter( this );
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RiuQwtScalePicker::eventFilter( QObject *object, QEvent *event )
bool RiuQwtScalePicker::eventFilter( QObject* object, QEvent* event )
{
if ( event->type() == QEvent::MouseButtonPress )
{
QwtScaleWidget *scaleWidget = qobject_cast<QwtScaleWidget *>( object );
QwtScaleWidget* scaleWidget = qobject_cast<QwtScaleWidget*>( object );
if ( scaleWidget )
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>( event );
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>( event );
mouseClicked( scaleWidget, mouseEvent->pos() );
return true;
@@ -42,52 +41,50 @@ bool RiuQwtScalePicker::eventFilter( QObject *object, QEvent *event )
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuQwtScalePicker::mouseClicked( const QwtScaleWidget *scale, const QPoint &pos )
void RiuQwtScalePicker::mouseClicked( const QwtScaleWidget* scale, const QPoint& pos )
{
QRect rect = scale->rect();
int margin = 10; // 10 pixels tolerance
rect.setRect( rect.x() - margin, rect.y() - margin,
rect.width() + 2 * margin, rect.height() + 2 * margin );
rect.setRect( rect.x() - margin, rect.y() - margin, rect.width() + 2 * margin, rect.height() + 2 * margin );
if ( rect.contains( pos ) ) // No click on the title
{
// translate the position in a value on the scale
double value = 0.0;
int axis = -1;
int axis = -1;
const QwtScaleDraw *sd = scale->scaleDraw();
switch( scale->alignment() )
const QwtScaleDraw* sd = scale->scaleDraw();
switch ( scale->alignment() )
{
case QwtScaleDraw::LeftScale:
{
value = sd->scaleMap().invTransform( pos.y() );
axis = QwtPlot::yLeft;
axis = QwtPlot::yLeft;
break;
}
case QwtScaleDraw::RightScale:
{
value = sd->scaleMap().invTransform( pos.y() );
axis = QwtPlot::yRight;
axis = QwtPlot::yRight;
break;
}
case QwtScaleDraw::BottomScale:
{
value = sd->scaleMap().invTransform( pos.x() );
axis = QwtPlot::xBottom;
axis = QwtPlot::xBottom;
break;
}
case QwtScaleDraw::TopScale:
{
value = sd->scaleMap().invTransform( pos.x() );
axis = QwtPlot::xTop;
axis = QwtPlot::xTop;
break;
}
}
Q_EMIT clicked( axis, value );
}
}

Some files were not shown because too many files have changed in this diff Show More