mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Columns in well log plots
This commit is contained in:
parent
cf02211713
commit
2857a13e7c
@ -93,8 +93,6 @@ void RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot( RimWellLogPlot*
|
||||
{
|
||||
CVF_ASSERT( dstWellLogPlot );
|
||||
|
||||
RiuPlotMainWindow* plotWindow = RiaGuiApplication::instance()->getOrCreateMainPlotWindow();
|
||||
|
||||
std::set<RimWellLogPlot*> srcPlots;
|
||||
|
||||
for ( size_t tIdx = 0; tIdx < tracksToMove.size(); tIdx++ )
|
||||
@ -113,12 +111,9 @@ void RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot( RimWellLogPlot*
|
||||
|
||||
for ( std::set<RimWellLogPlot*>::iterator pIt = srcPlots.begin(); pIt != srcPlots.end(); ++pIt )
|
||||
{
|
||||
RiuWellLogPlot* viewWidget = dynamic_cast<RiuWellLogPlot*>( ( *pIt )->viewWidget() );
|
||||
plotWindow->setWidthOfMdiWindow( viewWidget, viewWidget->preferredWidth() );
|
||||
|
||||
( *pIt )->calculateAvailableDepthRange();
|
||||
( *pIt )->updateTrackNames();
|
||||
( *pIt )->updateDepthZoom();
|
||||
( *pIt )->updateTrackNames();
|
||||
( *pIt )->updateConnectedEditors();
|
||||
}
|
||||
|
||||
@ -129,9 +124,8 @@ void RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot( RimWellLogPlot*
|
||||
{
|
||||
dstWellLogPlot->insertTrack( tracksToMove[tIdx], insertionStartIndex + tIdx );
|
||||
}
|
||||
RiuWellLogPlot* viewWidget = dynamic_cast<RiuWellLogPlot*>( dstWellLogPlot->viewWidget() );
|
||||
plotWindow->setWidthOfMdiWindow( viewWidget, viewWidget->preferredWidth() );
|
||||
|
||||
dstWellLogPlot->calculateAvailableDepthRange();
|
||||
dstWellLogPlot->updateDepthZoom();
|
||||
dstWellLogPlot->updateTrackNames();
|
||||
dstWellLogPlot->updateTracks();
|
||||
dstWellLogPlot->updateConnectedEditors();
|
||||
|
@ -676,7 +676,6 @@ std::vector<caf::PdmFieldHandle*> RimWellLogCurveCommonDataSource::fieldsToShowI
|
||||
fieldsToDisplay.push_back( &m_simWellName );
|
||||
}
|
||||
fieldsToDisplay.push_back( &m_timeStep );
|
||||
|
||||
return fieldsToDisplay;
|
||||
}
|
||||
|
||||
@ -923,7 +922,8 @@ void RimWellLogCurveCommonDataSource::defineEditorAttribute( const caf::PdmField
|
||||
|
||||
if ( field == &m_case )
|
||||
{
|
||||
modifierText = ( "(Shift+" );
|
||||
modifierText = ( "(Shift+" );
|
||||
myAttr->minimumContentsLength = 14;
|
||||
}
|
||||
else if ( field == &m_wellPath || field == &m_simWellName )
|
||||
{
|
||||
@ -931,7 +931,8 @@ void RimWellLogCurveCommonDataSource::defineEditorAttribute( const caf::PdmField
|
||||
}
|
||||
else if ( field == &m_timeStep )
|
||||
{
|
||||
modifierText = ( "(" );
|
||||
modifierText = ( "(" );
|
||||
myAttr->minimumContentsLength = 12;
|
||||
}
|
||||
|
||||
if ( !modifierText.isEmpty() )
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "RimWellLogTrack.h"
|
||||
|
||||
#include "RiuPlotMainWindow.h"
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
#include "RiuWellLogPlot.h"
|
||||
#include "RiuWellLogTrack.h"
|
||||
|
||||
@ -56,6 +57,17 @@ void caf::AppEnum<RimWellLogPlot::DepthTypeEnum>::setUp()
|
||||
setDefault( RimWellLogPlot::MEASURED_DEPTH );
|
||||
}
|
||||
|
||||
template <>
|
||||
void RimWellLogPlot::ColumnCountEnum::setUp()
|
||||
{
|
||||
addItem( RimWellLogPlot::COLUMNS_1, "1", "1 Column" );
|
||||
addItem( RimWellLogPlot::COLUMNS_2, "2", "2 Columns" );
|
||||
addItem( RimWellLogPlot::COLUMNS_3, "3", "3 Columns" );
|
||||
addItem( RimWellLogPlot::COLUMNS_4, "4", "4 Columns" );
|
||||
addItem( RimWellLogPlot::COLUMNS_UNLIMITED, "UNLIMITED", "Unlimited" );
|
||||
setDefault( RimWellLogPlot::COLUMNS_UNLIMITED );
|
||||
}
|
||||
|
||||
template <>
|
||||
void RimWellLogPlot::AxisGridEnum::setUp()
|
||||
{
|
||||
@ -111,6 +123,8 @@ RimWellLogPlot::RimWellLogPlot()
|
||||
CAF_PDM_InitFieldNoDefault( &m_tracks, "Tracks", "", "", "", "" );
|
||||
m_tracks.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_columnCountEnum, "NumberOfColumns", "Number of Columns", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "", "", "", "" );
|
||||
m_nameConfig.uiCapability()->setUiTreeHidden( true );
|
||||
m_nameConfig.uiCapability()->setUiTreeChildrenHidden( true );
|
||||
@ -204,6 +218,11 @@ void RimWellLogPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
{
|
||||
updateTracks();
|
||||
}
|
||||
else if ( changedField == &m_columnCountEnum )
|
||||
{
|
||||
updateTracks();
|
||||
updateColumnCount();
|
||||
}
|
||||
else if ( changedField == &m_showTitleInPlot )
|
||||
{
|
||||
m_viewer->setTitleVisible( m_showTitleInPlot() );
|
||||
@ -261,6 +280,29 @@ QList<caf::PdmOptionItemInfo> RimWellLogPlot::calculateValueOptions( const caf::
|
||||
options.push_back( caf::PdmOptionItemInfo( "Vertical", QVariant::fromValue( false ) ) );
|
||||
options.push_back( caf::PdmOptionItemInfo( "Horizontal", QVariant::fromValue( true ) ) );
|
||||
}
|
||||
else if ( fieldNeedingOptions == &m_columnCountEnum )
|
||||
{
|
||||
for ( size_t i = 0; i < ColumnCountEnum::size(); ++i )
|
||||
{
|
||||
ColumnCount enumVal = ColumnCountEnum::fromIndex( i );
|
||||
if ( enumVal == COLUMNS_UNLIMITED )
|
||||
{
|
||||
QString iconPath( ":/ColumnsUnlimited.png" );
|
||||
options.push_back( caf::PdmOptionItemInfo( ColumnCountEnum::uiText( enumVal ),
|
||||
enumVal,
|
||||
false,
|
||||
caf::QIconProvider( iconPath ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
QString iconPath = QString( ":/Columns%1.png" ).arg( static_cast<int>( enumVal ) );
|
||||
options.push_back( caf::PdmOptionItemInfo( ColumnCountEnum::uiText( enumVal ),
|
||||
enumVal,
|
||||
false,
|
||||
caf::QIconProvider( iconPath ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
( *useOptionsOnly ) = true;
|
||||
return options;
|
||||
@ -295,6 +337,7 @@ void RimWellLogPlot::addTrack( RimWellLogTrack* track )
|
||||
track->recreateViewer();
|
||||
m_viewer->addTrackPlot( track->viewer() );
|
||||
}
|
||||
updateColumnCount();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -311,6 +354,7 @@ void RimWellLogPlot::insertTrack( RimWellLogTrack* track, size_t index )
|
||||
}
|
||||
|
||||
updateTrackNames();
|
||||
updateColumnCount();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -322,6 +366,8 @@ void RimWellLogPlot::removeTrack( RimWellLogTrack* track )
|
||||
{
|
||||
if ( m_viewer ) m_viewer->removeTrackPlot( track->viewer() );
|
||||
m_tracks.removeChildObject( track );
|
||||
|
||||
updateColumnCount();
|
||||
}
|
||||
}
|
||||
|
||||
@ -610,6 +656,7 @@ void RimWellLogPlot::uiOrderingForPlotSettings( caf::PdmUiOrdering& uiOrdering )
|
||||
titleAndLegendsGroup->add( &m_showTrackLegends );
|
||||
titleAndLegendsGroup->add( &m_trackLegendsHorizontal );
|
||||
titleAndLegendsGroup->add( &m_showTitleInPlot );
|
||||
titleAndLegendsGroup->add( &m_columnCountEnum );
|
||||
m_nameConfig->uiOrdering( "", *titleAndLegendsGroup );
|
||||
}
|
||||
|
||||
@ -775,6 +822,18 @@ void RimWellLogPlot::setAvailableDepthTypes( const std::set<DepthTypeEnum>& dept
|
||||
m_availableDepthTypes = depthTypes;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlot::updateTrackOrderFromWidget()
|
||||
{
|
||||
std::sort( m_tracks.begin(), m_tracks.end(), [this]( RimWellLogTrack* lhs, RimWellLogTrack* rhs ) {
|
||||
return m_viewer->indexOfTrackPlot( lhs->viewer() ) < m_viewer->indexOfTrackPlot( rhs->viewer() );
|
||||
} );
|
||||
updateTrackNames();
|
||||
updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -980,6 +1039,23 @@ void RimWellLogPlot::initAfterRead()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlot::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
if ( field == &m_columnCountEnum )
|
||||
{
|
||||
auto comboAttr = dynamic_cast<caf::PdmUiComboBoxEditorAttribute*>( attribute );
|
||||
if ( comboAttr )
|
||||
{
|
||||
comboAttr->iconSize = QSize( 24, 14 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1112,6 +1188,26 @@ void RimWellLogPlot::setTrackLegendsHorizontal( bool horizontal )
|
||||
m_trackLegendsHorizontal = horizontal;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimWellLogPlot::columnCount() const
|
||||
{
|
||||
if ( m_columnCountEnum() == COLUMNS_UNLIMITED )
|
||||
{
|
||||
return static_cast<int>( visibleTracks().size() );
|
||||
}
|
||||
return static_cast<int>( m_columnCountEnum() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimWellLogPlot::columnCountField()
|
||||
{
|
||||
return &m_columnCountEnum;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1146,3 +1242,11 @@ void RimWellLogPlot::updatePlotTitle()
|
||||
/// Default empty implementation
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlot::onDepthTypeChanged() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlot::updateColumnCount()
|
||||
{
|
||||
RiuPlotMainWindowTools::refreshToolbars();
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmFieldHandle.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "RiaDefines.h"
|
||||
@ -56,6 +57,16 @@ public:
|
||||
CONNECTION_NUMBER
|
||||
};
|
||||
|
||||
enum ColumnCount
|
||||
{
|
||||
COLUMNS_1 = 1,
|
||||
COLUMNS_2 = 2,
|
||||
COLUMNS_3 = 3,
|
||||
COLUMNS_4 = 4,
|
||||
COLUMNS_UNLIMITED = 1000,
|
||||
};
|
||||
typedef caf::AppEnum<ColumnCount> ColumnCountEnum;
|
||||
|
||||
enum AxisGridVisibility
|
||||
{
|
||||
AXIS_GRID_NONE,
|
||||
@ -86,12 +97,14 @@ public:
|
||||
void enableDepthGridLines( AxisGridVisibility gridVisibility );
|
||||
AxisGridVisibility depthGridLinesVisibility() const;
|
||||
|
||||
bool isPlotTitleVisible() const;
|
||||
void setPlotTitleVisible( bool visible );
|
||||
bool areTrackLegendsVisible() const;
|
||||
void setTrackLegendsVisible( bool doShow );
|
||||
bool areTrackLegendsHorizontal() const;
|
||||
void setTrackLegendsHorizontal( bool horizontal );
|
||||
bool isPlotTitleVisible() const;
|
||||
void setPlotTitleVisible( bool visible );
|
||||
bool areTrackLegendsVisible() const;
|
||||
void setTrackLegendsVisible( bool doShow );
|
||||
bool areTrackLegendsHorizontal() const;
|
||||
void setTrackLegendsHorizontal( bool horizontal );
|
||||
int columnCount() const;
|
||||
caf::PdmFieldHandle* columnCountField();
|
||||
|
||||
void addTrack( RimWellLogTrack* track );
|
||||
void insertTrack( RimWellLogTrack* track, size_t index );
|
||||
@ -136,6 +149,7 @@ public:
|
||||
|
||||
void setAvailableDepthUnits( const std::set<RiaDefines::DepthUnitType>& depthUnits );
|
||||
void setAvailableDepthTypes( const std::set<RimWellLogPlot::DepthTypeEnum>& depthTypes );
|
||||
void updateTrackOrderFromWidget();
|
||||
|
||||
protected:
|
||||
void performAutoNameUpdate() override;
|
||||
@ -156,6 +170,9 @@ protected:
|
||||
void deleteViewWidget() override;
|
||||
|
||||
void initAfterRead() override;
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
private:
|
||||
void applyZoomAllDepths();
|
||||
@ -165,6 +182,7 @@ private:
|
||||
|
||||
void updatePlotTitle();
|
||||
virtual void onDepthTypeChanged();
|
||||
void updateColumnCount();
|
||||
|
||||
protected:
|
||||
caf::PdmField<QString> m_userName_OBSOLETE;
|
||||
@ -178,9 +196,10 @@ protected:
|
||||
caf::PdmField<AxisGridEnum> m_depthAxisGridVisibility;
|
||||
caf::PdmField<bool> m_isAutoScaleDepthEnabled;
|
||||
|
||||
caf::PdmField<bool> m_showTitleInPlot;
|
||||
caf::PdmField<bool> m_showTrackLegends;
|
||||
caf::PdmField<bool> m_trackLegendsHorizontal;
|
||||
caf::PdmField<bool> m_showTitleInPlot;
|
||||
caf::PdmField<bool> m_showTrackLegends;
|
||||
caf::PdmField<bool> m_trackLegendsHorizontal;
|
||||
caf::PdmField<ColumnCountEnum> m_columnCountEnum;
|
||||
|
||||
caf::PdmChildField<RimWellLogPlotNameConfig*> m_nameConfig;
|
||||
|
||||
|
BIN
ApplicationCode/Resources/Columns1.png
Normal file
BIN
ApplicationCode/Resources/Columns1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 250 B |
BIN
ApplicationCode/Resources/Columns2.png
Normal file
BIN
ApplicationCode/Resources/Columns2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 266 B |
BIN
ApplicationCode/Resources/Columns3.png
Normal file
BIN
ApplicationCode/Resources/Columns3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 294 B |
BIN
ApplicationCode/Resources/Columns4.png
Normal file
BIN
ApplicationCode/Resources/Columns4.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 229 B |
BIN
ApplicationCode/Resources/ColumnsUnlimited.png
Normal file
BIN
ApplicationCode/Resources/ColumnsUnlimited.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 378 B |
@ -159,6 +159,11 @@
|
||||
<file>RulerPoly24x24.png</file>
|
||||
<file>Swap.png</file>
|
||||
<file>SummaryTemplate16x16.png</file>
|
||||
<file>Columns1.png</file>
|
||||
<file>Columns2.png</file>
|
||||
<file>Columns3.png</file>
|
||||
<file>Columns4.png</file>
|
||||
<file>ColumnsUnlimited.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/Shader/">
|
||||
<file>fs_CellFace.glsl</file>
|
||||
|
@ -532,6 +532,7 @@ void RiuPlotMainWindow::updateWellLogPlotToolBar()
|
||||
{
|
||||
std::vector<caf::PdmFieldHandle*> toolBarFields;
|
||||
toolBarFields = wellLogPlot->commonDataSource()->fieldsToShowInToolbar();
|
||||
toolBarFields.push_back( wellLogPlot->columnCountField() );
|
||||
|
||||
m_wellLogPlotToolBarEditor->setFields( toolBarFields );
|
||||
m_wellLogPlotToolBarEditor->updateUi();
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "WellLogCommands/RicWellLogPlotTrackFeatureImpl.h"
|
||||
|
||||
#include "RimContextCommandBuilder.h"
|
||||
#include "RimWellLogPlot.h"
|
||||
#include "RimWellLogTrack.h"
|
||||
@ -40,6 +42,7 @@
|
||||
#include "qwt_plot_layout.h"
|
||||
#include "qwt_scale_draw.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFocusEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMdiSubWindow>
|
||||
@ -84,6 +87,7 @@ RiuWellLogPlot::RiuWellLogPlot( RimWellLogPlot* plotDefinition, QWidget* parent
|
||||
|
||||
m_scrollBar = new QScrollBar( nullptr );
|
||||
m_scrollBar->setOrientation( Qt::Vertical );
|
||||
m_scrollBar->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
|
||||
|
||||
m_scrollBarLayout = new QVBoxLayout;
|
||||
m_scrollBarLayout->addWidget( m_scrollBar, 0 );
|
||||
@ -94,6 +98,8 @@ RiuWellLogPlot::RiuWellLogPlot( RimWellLogPlot* plotDefinition, QWidget* parent
|
||||
|
||||
setFocusPolicy( Qt::StrongFocus );
|
||||
connect( m_scrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) );
|
||||
|
||||
setAcceptDrops( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -119,7 +125,7 @@ void RiuWellLogPlot::addTrackPlot( RiuWellLogTrack* trackPlot )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::insertTrackPlot( RiuWellLogTrack* trackPlot, size_t index )
|
||||
void RiuWellLogPlot::insertTrackPlot( RiuWellLogTrack* trackPlot, size_t index, bool updateLayoutAfter )
|
||||
{
|
||||
m_trackPlots.insert( static_cast<int>( index ), trackPlot );
|
||||
|
||||
@ -137,15 +143,19 @@ void RiuWellLogPlot::insertTrackPlot( RiuWellLogTrack* trackPlot, size_t index )
|
||||
SIGNAL( legendDataChanged( const QVariant&, const QList<QwtLegendData>& ) ),
|
||||
SLOT( updateLegend( const QVariant&, const QList<QwtLegendData>& ) ) );
|
||||
legend->contentsWidget()->layout()->setAlignment( Qt::AlignBottom | Qt::AlignHCenter );
|
||||
trackPlot->updateLegend();
|
||||
m_legends.insert( static_cast<int>( index ), legend );
|
||||
|
||||
updateChildrenLayout();
|
||||
if ( updateLayoutAfter )
|
||||
{
|
||||
updateChildrenLayout();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::removeTrackPlot( RiuWellLogTrack* trackPlot )
|
||||
void RiuWellLogPlot::removeTrackPlot( RiuWellLogTrack* trackPlot, bool updateLayoutAfter )
|
||||
{
|
||||
if ( !trackPlot ) return;
|
||||
|
||||
@ -159,7 +169,10 @@ void RiuWellLogPlot::removeTrackPlot( RiuWellLogTrack* trackPlot )
|
||||
m_legends.removeAt( trackIdx );
|
||||
delete legend;
|
||||
|
||||
updateChildrenLayout();
|
||||
if ( updateLayoutAfter )
|
||||
{
|
||||
updateChildrenLayout();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -222,6 +235,14 @@ void RiuWellLogPlot::setScrollbarVisible( bool visible )
|
||||
m_scrollBar->setVisible( visible );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiuWellLogPlot::indexOfTrackPlot( RiuWellLogTrack* track )
|
||||
{
|
||||
return m_trackPlots.indexOf( track );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -312,6 +333,131 @@ void RiuWellLogPlot::changeEvent( QEvent* event )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::dragEnterEvent( QDragEnterEvent* event )
|
||||
{
|
||||
if ( this->geometry().contains( event->pos() ) )
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::dragMoveEvent( QDragMoveEvent* event )
|
||||
{
|
||||
if ( this->geometry().contains( event->pos() ) )
|
||||
{
|
||||
RiuWellLogTrack* source = dynamic_cast<RiuWellLogTrack*>( event->source() );
|
||||
if ( source )
|
||||
{
|
||||
QRect originalGeometry = source->geometry();
|
||||
QPoint offset = source->dragStartPosition();
|
||||
QRect newRect( event->pos() - offset, originalGeometry.size() );
|
||||
|
||||
QList<QPointer<RiuWellLogTrack>> visibleTracks = this->visibleTracks();
|
||||
|
||||
int insertBeforeIndex = visibleTracks.size();
|
||||
for ( int visibleIndex = 0; visibleIndex < visibleTracks.size(); ++visibleIndex )
|
||||
{
|
||||
visibleTracks[visibleIndex]->setDefaultStyleSheet();
|
||||
|
||||
if ( visibleTracks[visibleIndex]->frameIsInFrontOfThis( newRect ) )
|
||||
{
|
||||
insertBeforeIndex = std::min( insertBeforeIndex, visibleIndex );
|
||||
}
|
||||
}
|
||||
if ( insertBeforeIndex >= 0 && insertBeforeIndex < visibleTracks.size() )
|
||||
{
|
||||
visibleTracks[insertBeforeIndex]->setStyleSheetForThisObject(
|
||||
"border-left: 2px solid red; border-top: none; border-bottom: none; border-right: none;" );
|
||||
}
|
||||
|
||||
if ( insertBeforeIndex > 0 )
|
||||
{
|
||||
int insertAfterIndex = insertBeforeIndex - 1;
|
||||
visibleTracks[insertAfterIndex]->setStyleSheetForThisObject(
|
||||
"border-left: none; border-top: none; border-bottom: none; border-right: 2px solid red;" );
|
||||
}
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::dragLeaveEvent( QDragLeaveEvent* event )
|
||||
{
|
||||
for ( int tIdx = 0; tIdx < m_trackPlots.size(); ++tIdx )
|
||||
{
|
||||
m_trackPlots[tIdx]->setDefaultStyleSheet();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::dropEvent( QDropEvent* event )
|
||||
{
|
||||
for ( int tIdx = 0; tIdx < m_trackPlots.size(); ++tIdx )
|
||||
{
|
||||
m_trackPlots[tIdx]->setDefaultStyleSheet();
|
||||
}
|
||||
|
||||
if ( this->geometry().contains( event->pos() ) )
|
||||
{
|
||||
RiuWellLogTrack* source = dynamic_cast<RiuWellLogTrack*>( event->source() );
|
||||
|
||||
if ( source )
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
|
||||
QRect originalGeometry = source->geometry();
|
||||
QPoint offset = source->dragStartPosition();
|
||||
QRect newRect( event->pos() - offset, originalGeometry.size() );
|
||||
|
||||
int beforeIndex = m_trackPlots.size();
|
||||
for ( int tIdx = 0; tIdx < m_trackPlots.size(); ++tIdx )
|
||||
{
|
||||
if ( m_trackPlots[tIdx]->isVisible() )
|
||||
{
|
||||
if ( m_trackPlots[tIdx]->frameIsInFrontOfThis( newRect ) )
|
||||
{
|
||||
beforeIndex = tIdx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
RimWellLogTrack* insertAfter = nullptr;
|
||||
if ( beforeIndex > 0 )
|
||||
{
|
||||
insertAfter = m_trackPlots[beforeIndex - 1]->plotDefinition();
|
||||
}
|
||||
|
||||
RimWellLogTrack* rimTrack = source->plotDefinition();
|
||||
|
||||
if ( insertAfter != rimTrack )
|
||||
{
|
||||
RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot( m_plotDefinition, {rimTrack}, insertAfter );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<int, int> RiuWellLogPlot::rowAndColumnCount( int trackCount ) const
|
||||
{
|
||||
int columnCount = std::max( 1, std::min( m_plotDefinition->columnCount(), trackCount ) );
|
||||
int rowCount = static_cast<int>( std::ceil( trackCount / static_cast<double>( columnCount ) ) );
|
||||
return std::make_pair( rowCount, columnCount );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -341,24 +487,27 @@ void RiuWellLogPlot::alignCanvasTopsAndScrollbar()
|
||||
{
|
||||
CVF_ASSERT( m_legends.size() == m_trackPlots.size() );
|
||||
|
||||
double maxExtent = 0.0;
|
||||
for ( int tIdx = 0; tIdx < m_trackPlots.size(); ++tIdx )
|
||||
QList<QPointer<RiuWellLogTrack>> tracks = visibleTracks();
|
||||
|
||||
auto rowAndColumnCount = this->rowAndColumnCount( tracks.size() );
|
||||
|
||||
std::vector<double> maxExtents( rowAndColumnCount.first, 0.0 );
|
||||
|
||||
for ( int visibleIndex = 0; visibleIndex < tracks.size(); ++visibleIndex )
|
||||
{
|
||||
if ( m_trackPlots[tIdx]->isVisible() )
|
||||
{
|
||||
QFont font = m_trackPlots[tIdx]->axisFont( QwtPlot::xTop );
|
||||
maxExtent = std::max( maxExtent, m_trackPlots[tIdx]->axisScaleDraw( QwtPlot::xTop )->extent( font ) );
|
||||
}
|
||||
int row = visibleIndex / rowAndColumnCount.second;
|
||||
|
||||
QFont font = m_trackPlots[visibleIndex]->axisFont( QwtPlot::xTop );
|
||||
maxExtents[row] = std::max( maxExtents[row],
|
||||
tracks[visibleIndex]->axisScaleDraw( QwtPlot::xTop )->extent( font ) );
|
||||
}
|
||||
|
||||
for ( int tIdx = 0; tIdx < m_trackPlots.size(); ++tIdx )
|
||||
for ( int visibleIndex = 0; visibleIndex < tracks.size(); ++visibleIndex )
|
||||
{
|
||||
if ( m_trackPlots[tIdx]->isVisible() )
|
||||
{
|
||||
m_trackPlots[tIdx]->axisScaleDraw( QwtPlot::xTop )->setMinimumExtent( maxExtent );
|
||||
}
|
||||
int row = visibleIndex / rowAndColumnCount.second;
|
||||
tracks[visibleIndex]->axisScaleDraw( QwtPlot::xTop )->setMinimumExtent( maxExtents[row] );
|
||||
}
|
||||
m_scrollBarLayout->setContentsMargins( 0, maxExtent, 0, 0 );
|
||||
m_scrollBarLayout->setContentsMargins( 0, maxExtents[0], 0, 0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -368,53 +517,59 @@ void RiuWellLogPlot::reinsertTracksAndScrollbar()
|
||||
{
|
||||
clearTrackLayout();
|
||||
|
||||
int visibleIndex = 0;
|
||||
for ( int tIdx = 0; tIdx < m_trackPlots.size(); ++tIdx )
|
||||
{
|
||||
if ( m_trackPlots[tIdx]->isRimTrackVisible() )
|
||||
m_trackPlots[tIdx]->hide();
|
||||
}
|
||||
|
||||
QList<QPointer<RiuWellLogTrack>> tracks = this->visibleTracks();
|
||||
QList<QPointer<QwtLegend>> legends = this->visibleLegends();
|
||||
|
||||
auto rowAndColumnCount = this->rowAndColumnCount( tracks.size() );
|
||||
|
||||
for ( int visibleIndex = 0; visibleIndex < tracks.size(); ++visibleIndex )
|
||||
{
|
||||
int row = visibleIndex / rowAndColumnCount.second;
|
||||
int column = visibleIndex % rowAndColumnCount.second;
|
||||
|
||||
m_trackLayout->addWidget( legends[visibleIndex], 2 * row, column );
|
||||
m_trackLayout->addWidget( tracks[visibleIndex], 2 * row + 1, column );
|
||||
|
||||
if ( m_plotDefinition->areTrackLegendsVisible() )
|
||||
{
|
||||
m_trackLayout->addWidget( m_legends[tIdx], 0, visibleIndex );
|
||||
m_trackLayout->addWidget( m_trackPlots[tIdx], 1, visibleIndex );
|
||||
|
||||
if ( m_plotDefinition->areTrackLegendsVisible() )
|
||||
int legendColumns = 1;
|
||||
if ( m_plotDefinition->areTrackLegendsHorizontal() )
|
||||
{
|
||||
int legendColumns = 1;
|
||||
if ( m_plotDefinition->areTrackLegendsHorizontal() )
|
||||
{
|
||||
legendColumns = 0; // unlimited
|
||||
}
|
||||
m_legends[tIdx]->setMaxColumns( legendColumns );
|
||||
int minimumHeight = m_legends[tIdx]->heightForWidth( m_trackPlots[tIdx]->width() );
|
||||
m_legends[tIdx]->setMinimumHeight( minimumHeight );
|
||||
|
||||
m_legends[tIdx]->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_legends[tIdx]->hide();
|
||||
legendColumns = 0; // unlimited
|
||||
}
|
||||
legends[visibleIndex]->setMaxColumns( legendColumns );
|
||||
int minimumHeight = legends[visibleIndex]->heightForWidth( tracks[visibleIndex]->width() );
|
||||
legends[visibleIndex]->setMinimumHeight( minimumHeight );
|
||||
|
||||
m_trackPlots[tIdx]->setDepthTitle( visibleIndex == 0 ? m_plotDefinition->depthPlotTitle() : "" );
|
||||
m_trackPlots[tIdx]->enableDepthAxisLabelsAndTicks( visibleIndex == 0 );
|
||||
m_trackPlots[tIdx]->show();
|
||||
|
||||
int widthScaleFactor = m_trackPlots[tIdx]->widthScaleFactor();
|
||||
if ( visibleIndex == 0 )
|
||||
{
|
||||
widthScaleFactor += 1; // Give it a bit extra room due to depth axis
|
||||
}
|
||||
m_trackLayout->setColumnStretch( visibleIndex, widthScaleFactor );
|
||||
m_trackLayout->setRowStretch( 1, 1 );
|
||||
visibleIndex++;
|
||||
legends[visibleIndex]->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_trackPlots[tIdx]->hide();
|
||||
m_legends[tIdx]->hide();
|
||||
legends[visibleIndex]->hide();
|
||||
}
|
||||
|
||||
tracks[visibleIndex]->setDepthTitle( column == 0 ? m_plotDefinition->depthPlotTitle() : "" );
|
||||
tracks[visibleIndex]->enableDepthAxisLabelsAndTicks( column == 0 );
|
||||
tracks[visibleIndex]->show();
|
||||
|
||||
int widthScaleFactor = tracks[visibleIndex]->widthScaleFactor();
|
||||
if ( column == 0 )
|
||||
{
|
||||
widthScaleFactor += 1; // Give it a bit extra room due to depth axis
|
||||
}
|
||||
m_trackLayout->setColumnStretch( column,
|
||||
std::max( m_trackLayout->columnStretch( column ),
|
||||
tracks[visibleIndex]->widthScaleFactor() ) );
|
||||
m_trackLayout->setRowStretch( 2 * row + 1, 1 );
|
||||
}
|
||||
m_trackLayout->addLayout( m_scrollBarLayout, 1, visibleIndex );
|
||||
m_scrollBar->setVisible( visibleIndex > 0 );
|
||||
m_trackLayout->addLayout( m_scrollBarLayout, 1, rowAndColumnCount.second, rowAndColumnCount.first * 2 - 1, 1 );
|
||||
m_trackLayout->setColumnStretch( rowAndColumnCount.second, 0 );
|
||||
m_scrollBar->setVisible( tracks.size() > 0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -424,13 +579,54 @@ void RiuWellLogPlot::clearTrackLayout()
|
||||
{
|
||||
if ( m_trackLayout )
|
||||
{
|
||||
for ( int tIdx = 0; tIdx < m_trackPlots.size(); ++tIdx )
|
||||
{
|
||||
m_trackLayout->removeWidget( m_legends[tIdx] );
|
||||
m_trackLayout->removeWidget( m_trackPlots[tIdx] );
|
||||
}
|
||||
|
||||
QLayoutItem* item;
|
||||
while ( ( item = m_trackLayout->takeAt( 0 ) ) != 0 )
|
||||
{
|
||||
}
|
||||
QWidget().setLayout( m_trackLayout );
|
||||
delete m_trackLayout;
|
||||
m_trackLayout = new QGridLayout( m_trackFrame );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<QPointer<RiuWellLogTrack>> RiuWellLogPlot::visibleTracks() const
|
||||
{
|
||||
QList<QPointer<RiuWellLogTrack>> tracks;
|
||||
for ( QPointer<RiuWellLogTrack> track : m_trackPlots )
|
||||
{
|
||||
if ( track->isRimTrackVisible() )
|
||||
{
|
||||
tracks.push_back( track );
|
||||
}
|
||||
}
|
||||
return tracks;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<QPointer<QwtLegend>> RiuWellLogPlot::visibleLegends() const
|
||||
{
|
||||
QList<QPointer<QwtLegend>> legends;
|
||||
for ( int i = 0; i < m_trackPlots.size(); ++i )
|
||||
{
|
||||
if ( m_trackPlots[i]->isRimTrackVisible() )
|
||||
{
|
||||
legends.push_back( m_legends[i] );
|
||||
}
|
||||
}
|
||||
return legends;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -58,8 +58,8 @@ public:
|
||||
RimViewWindow* ownerViewWindow() const override;
|
||||
|
||||
void addTrackPlot( RiuWellLogTrack* trackPlot );
|
||||
void insertTrackPlot( RiuWellLogTrack* trackPlot, size_t index );
|
||||
void removeTrackPlot( RiuWellLogTrack* trackPlot );
|
||||
void insertTrackPlot( RiuWellLogTrack* trackPlot, size_t index, bool updateLayoutAfter = true );
|
||||
void removeTrackPlot( RiuWellLogTrack* trackPlot, bool updateLayoutAfter = true );
|
||||
|
||||
void setDepthZoomAndReplot( double minDepth, double maxDepth );
|
||||
void setPlotTitle( const QString& plotTitle );
|
||||
@ -68,18 +68,25 @@ public:
|
||||
void setTitleVisible( bool visible );
|
||||
void setScrollbarVisible( bool visible );
|
||||
|
||||
int indexOfTrackPlot( RiuWellLogTrack* track );
|
||||
|
||||
public slots:
|
||||
void updateChildrenLayout();
|
||||
|
||||
protected:
|
||||
void contextMenuEvent( QContextMenuEvent* ) override;
|
||||
void keyPressEvent( QKeyEvent* keyEvent ) override;
|
||||
|
||||
void contextMenuEvent( QContextMenuEvent* ) override;
|
||||
void keyPressEvent( QKeyEvent* keyEvent ) override;
|
||||
QLabel* createTitleLabel() const;
|
||||
|
||||
void resizeEvent( QResizeEvent* event ) override;
|
||||
void showEvent( QShowEvent* event ) override;
|
||||
void changeEvent( QEvent* ) override;
|
||||
void dragEnterEvent( QDragEnterEvent* event ) override;
|
||||
void dragMoveEvent( QDragMoveEvent* event ) override;
|
||||
void dragLeaveEvent( QDragLeaveEvent* event ) override;
|
||||
void dropEvent( QDropEvent* event ) override;
|
||||
|
||||
std::pair<int, int> rowAndColumnCount( int trackCount ) const;
|
||||
|
||||
private:
|
||||
void updateScrollBar( double minDepth, double maxDepth );
|
||||
@ -87,6 +94,9 @@ private:
|
||||
void reinsertTracksAndScrollbar();
|
||||
void clearTrackLayout();
|
||||
|
||||
QList<QPointer<RiuWellLogTrack>> visibleTracks() const;
|
||||
QList<QPointer<QwtLegend>> visibleLegends() const;
|
||||
|
||||
private slots:
|
||||
void slotSetMinDepth( int value );
|
||||
|
||||
|
@ -42,8 +42,10 @@
|
||||
#include "qwt_symbol.h"
|
||||
#include "qwt_text.h"
|
||||
|
||||
#include <QDrag>
|
||||
#include <QFont>
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QMimeData>
|
||||
#include <QMouseEvent>
|
||||
#include <QScrollArea>
|
||||
#include <QWheelEvent>
|
||||
@ -70,45 +72,6 @@ RiuWellLogTrack::RiuWellLogTrack( RimWellLogTrack* plotTrackDefinition, QWidget*
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellLogTrack::~RiuWellLogTrack() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogTrack::setDefaults()
|
||||
{
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour( this );
|
||||
|
||||
enableAxis( QwtPlot::xTop, true );
|
||||
enableAxis( QwtPlot::yLeft, true );
|
||||
enableAxis( QwtPlot::xBottom, false );
|
||||
enableAxis( QwtPlot::yRight, false );
|
||||
|
||||
axisScaleEngine( QwtPlot::yLeft )->setAttribute( QwtScaleEngine::Inverted, true );
|
||||
|
||||
// Align the canvas with the actual min and max values of the curves
|
||||
axisScaleEngine( QwtPlot::xTop )->setAttribute( QwtScaleEngine::Floating, true );
|
||||
axisScaleEngine( QwtPlot::yLeft )->setAttribute( QwtScaleEngine::Floating, true );
|
||||
setAxisScale( QwtPlot::yLeft, 1000, 0 );
|
||||
setXRange( 0, 100 );
|
||||
axisScaleDraw( QwtPlot::xTop )->setMinimumExtent( axisExtent( QwtPlot::xTop ) );
|
||||
setMinimumWidth( defaultMinimumWidth() );
|
||||
|
||||
canvas()->setContentsMargins( 0, 0, 0, 0 );
|
||||
QFrame* canvasFrame = dynamic_cast<QFrame*>( canvas() );
|
||||
canvasFrame->setFrameShape( QFrame::Box );
|
||||
canvasFrame->setStyleSheet( "border: 1px solid black" );
|
||||
|
||||
QGraphicsDropShadowEffect* dropShadowEffect = new QGraphicsDropShadowEffect( canvas() );
|
||||
dropShadowEffect->setOffset( 1.0, 1.0 );
|
||||
dropShadowEffect->setBlurRadius( 3.0 );
|
||||
dropShadowEffect->setColor( QColor( 60, 60, 60, 60 ) );
|
||||
canvas()->setGraphicsEffect( dropShadowEffect );
|
||||
|
||||
axisScaleDraw( QwtPlot::xTop )->enableComponent( QwtAbstractScaleDraw::Backbone, false );
|
||||
axisScaleDraw( QwtPlot::yLeft )->enableComponent( QwtAbstractScaleDraw::Backbone, false );
|
||||
axisWidget( QwtPlot::xTop )->setMargin( 0 );
|
||||
axisWidget( QwtPlot::yLeft )->setMargin( 0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -153,131 +116,6 @@ void RiuWellLogTrack::setXTitle( const QString& title )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuWellLogTrack::eventFilter( QObject* watched, QEvent* event )
|
||||
{
|
||||
if ( watched == canvas() )
|
||||
{
|
||||
QWheelEvent* wheelEvent = dynamic_cast<QWheelEvent*>( event );
|
||||
if ( wheelEvent )
|
||||
{
|
||||
if ( !m_plotTrackDefinition )
|
||||
{
|
||||
return QwtPlot::eventFilter( watched, event );
|
||||
}
|
||||
|
||||
RimWellLogPlot* plotDefinition;
|
||||
m_plotTrackDefinition->firstAncestorOrThisOfType( plotDefinition );
|
||||
if ( !plotDefinition )
|
||||
{
|
||||
return QwtPlot::eventFilter( watched, event );
|
||||
}
|
||||
|
||||
if ( wheelEvent->modifiers() & Qt::ControlModifier )
|
||||
{
|
||||
QwtScaleMap scaleMap = canvasMap( QwtPlot::yLeft );
|
||||
double zoomCenter = scaleMap.invTransform( wheelEvent->pos().y() );
|
||||
|
||||
if ( wheelEvent->delta() > 0 )
|
||||
{
|
||||
plotDefinition->setDepthZoomByFactorAndCenter( RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter );
|
||||
}
|
||||
else
|
||||
{
|
||||
plotDefinition->setDepthZoomByFactorAndCenter( 1.0 / RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
plotDefinition->panDepth( wheelEvent->delta() < 0 ? RIU_SCROLLWHEEL_PANFACTOR
|
||||
: -RIU_SCROLLWHEEL_PANFACTOR );
|
||||
}
|
||||
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>( event );
|
||||
if ( mouseEvent )
|
||||
{
|
||||
if ( mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonRelease )
|
||||
{
|
||||
selectClosestCurve( mouseEvent->pos() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QwtPlot::eventFilter( watched, event );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogTrack::selectClosestCurve( const QPoint& pos )
|
||||
{
|
||||
QwtPlotCurve* closestCurve = nullptr;
|
||||
double distMin = DBL_MAX;
|
||||
|
||||
const QwtPlotItemList& itmList = itemList();
|
||||
for ( QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++ )
|
||||
{
|
||||
if ( ( *it )->rtti() == QwtPlotItem::Rtti_PlotCurve )
|
||||
{
|
||||
QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>( *it );
|
||||
double dist = DBL_MAX;
|
||||
candidateCurve->closestPoint( pos, &dist );
|
||||
if ( dist < distMin )
|
||||
{
|
||||
closestCurve = candidateCurve;
|
||||
distMin = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( closestCurve && distMin < 20 )
|
||||
{
|
||||
RimWellLogCurve* selectedCurve = m_plotTrackDefinition->curveDefinitionFromCurve( closestCurve );
|
||||
if ( selectedCurve )
|
||||
{
|
||||
RiuPlotMainWindowTools::showPlotMainWindow();
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( selectedCurve );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RiuPlotMainWindowTools::showPlotMainWindow();
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( m_plotTrackDefinition );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiuWellLogTrack::defaultMinimumWidth()
|
||||
{
|
||||
return 80;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuWellLogTrack::sizeHint() const
|
||||
{
|
||||
return QSize( 0, 0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuWellLogTrack::minimumSizeHint() const
|
||||
{
|
||||
return QSize( 0, 0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -415,3 +253,269 @@ int RiuWellLogTrack::axisExtent( QwtPlot::Axis axis ) const
|
||||
}
|
||||
return lineExtent;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuWellLogTrack::frameIsInFrontOfThis( const QRect& frameGeometry )
|
||||
{
|
||||
QRect ownGeometry = this->canvas()->geometry();
|
||||
ownGeometry.translate( this->geometry().topLeft() );
|
||||
|
||||
if ( frameGeometry.bottom() < ownGeometry.center().y() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( frameGeometry.left() < ownGeometry.left() && frameGeometry.top() < ownGeometry.center().y() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
QRect intersection = ownGeometry.intersected( frameGeometry );
|
||||
|
||||
double ownArea = double( ownGeometry.height() ) * double( ownGeometry.width() );
|
||||
double frameArea = double( frameGeometry.height() ) * double( frameGeometry.width() );
|
||||
double intersectionArea = double( intersection.height() ) * double( intersection.width() );
|
||||
if ( intersectionArea > 0.8 * std::min( ownArea, frameArea ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QPoint RiuWellLogTrack::dragStartPosition() const
|
||||
{
|
||||
return m_dragStartPosition;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogTrack::setDefaultStyleSheet()
|
||||
{
|
||||
this->setStyleSheetForThisObject( "border: 1px dashed blue;", "hover" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogTrack::setStyleSheetForThisObject( const QString& content, const QString& state /*= "" */ )
|
||||
{
|
||||
QString stateTag = !state.isEmpty() ? QString( ":%1" ).arg( state ) : "";
|
||||
QString stylesheet = QString( "QwtPlot#%1%2 { %3 }" ).arg( this->objectName() ).arg( stateTag ).arg( content );
|
||||
this->setStyleSheet( stylesheet );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellLogTrack* RiuWellLogTrack::plotDefinition() const
|
||||
{
|
||||
return m_plotTrackDefinition;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuWellLogTrack::eventFilter( QObject* watched, QEvent* event )
|
||||
{
|
||||
if ( watched == canvas() )
|
||||
{
|
||||
QWheelEvent* wheelEvent = dynamic_cast<QWheelEvent*>( event );
|
||||
if ( wheelEvent )
|
||||
{
|
||||
if ( !m_plotTrackDefinition )
|
||||
{
|
||||
return QwtPlot::eventFilter( watched, event );
|
||||
}
|
||||
|
||||
RimWellLogPlot* plotDefinition;
|
||||
m_plotTrackDefinition->firstAncestorOrThisOfType( plotDefinition );
|
||||
if ( !plotDefinition )
|
||||
{
|
||||
return QwtPlot::eventFilter( watched, event );
|
||||
}
|
||||
|
||||
if ( wheelEvent->modifiers() & Qt::ControlModifier )
|
||||
{
|
||||
QwtScaleMap scaleMap = canvasMap( QwtPlot::yLeft );
|
||||
double zoomCenter = scaleMap.invTransform( wheelEvent->pos().y() );
|
||||
|
||||
if ( wheelEvent->delta() > 0 )
|
||||
{
|
||||
plotDefinition->setDepthZoomByFactorAndCenter( RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter );
|
||||
}
|
||||
else
|
||||
{
|
||||
plotDefinition->setDepthZoomByFactorAndCenter( 1.0 / RIU_SCROLLWHEEL_ZOOMFACTOR, zoomCenter );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
plotDefinition->panDepth( wheelEvent->delta() < 0 ? RIU_SCROLLWHEEL_PANFACTOR
|
||||
: -RIU_SCROLLWHEEL_PANFACTOR );
|
||||
}
|
||||
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>( event );
|
||||
if ( mouseEvent )
|
||||
{
|
||||
if ( mouseEvent->button() == Qt::LeftButton && mouseEvent->type() == QMouseEvent::MouseButtonRelease )
|
||||
{
|
||||
selectClosestCurve( mouseEvent->pos() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QwtPlot::eventFilter( watched, event );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuWellLogTrack::sizeHint() const
|
||||
{
|
||||
return QSize( 0, 0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuWellLogTrack::minimumSizeHint() const
|
||||
{
|
||||
return QSize( 0, 0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogTrack::mousePressEvent( QMouseEvent* event )
|
||||
{
|
||||
if ( event->button() == Qt::LeftButton && this->underMouse() )
|
||||
{
|
||||
m_dragStartPosition = event->pos();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogTrack::mouseMoveEvent( QMouseEvent* event )
|
||||
{
|
||||
if ( !( event->buttons() & Qt::LeftButton ) ) return;
|
||||
if ( ( event->pos() - m_dragStartPosition ).manhattanLength() < QApplication::startDragDistance() ) return;
|
||||
|
||||
QPoint dragPositionOffset = this->canvas()->geometry().topLeft() - m_dragStartPosition;
|
||||
QPixmap pixmap = this->canvas()->grab();
|
||||
QDrag* drag = new QDrag( this );
|
||||
QMimeData* mimeData = new QMimeData;
|
||||
mimeData->setImageData( pixmap );
|
||||
drag->setMimeData( mimeData );
|
||||
drag->setPixmap( pixmap );
|
||||
drag->setHotSpot( m_dragStartPosition );
|
||||
drag->exec( Qt::MoveAction );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogTrack::setDefaults()
|
||||
{
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour( this );
|
||||
|
||||
enableAxis( QwtPlot::xTop, true );
|
||||
enableAxis( QwtPlot::yLeft, true );
|
||||
enableAxis( QwtPlot::xBottom, false );
|
||||
enableAxis( QwtPlot::yRight, false );
|
||||
|
||||
axisScaleEngine( QwtPlot::yLeft )->setAttribute( QwtScaleEngine::Inverted, true );
|
||||
|
||||
// Align the canvas with the actual min and max values of the curves
|
||||
axisScaleEngine( QwtPlot::xTop )->setAttribute( QwtScaleEngine::Floating, true );
|
||||
axisScaleEngine( QwtPlot::yLeft )->setAttribute( QwtScaleEngine::Floating, true );
|
||||
setAxisScale( QwtPlot::yLeft, 1000, 0 );
|
||||
setXRange( 0, 100 );
|
||||
axisScaleDraw( QwtPlot::xTop )->setMinimumExtent( axisExtent( QwtPlot::xTop ) );
|
||||
setMinimumWidth( defaultMinimumWidth() );
|
||||
|
||||
canvas()->setContentsMargins( 0, 0, 0, 0 );
|
||||
QFrame* canvasFrame = dynamic_cast<QFrame*>( canvas() );
|
||||
canvasFrame->setFrameShape( QFrame::Box );
|
||||
canvasFrame->setStyleSheet( "border: 1px solid black" );
|
||||
|
||||
QGraphicsDropShadowEffect* dropShadowEffect = new QGraphicsDropShadowEffect( canvas() );
|
||||
dropShadowEffect->setOffset( 1.0, 1.0 );
|
||||
dropShadowEffect->setBlurRadius( 3.0 );
|
||||
dropShadowEffect->setColor( QColor( 60, 60, 60, 60 ) );
|
||||
canvas()->setGraphicsEffect( dropShadowEffect );
|
||||
|
||||
axisScaleDraw( QwtPlot::xTop )->enableComponent( QwtAbstractScaleDraw::Backbone, false );
|
||||
axisScaleDraw( QwtPlot::yLeft )->enableComponent( QwtAbstractScaleDraw::Backbone, false );
|
||||
axisWidget( QwtPlot::xTop )->setMargin( 0 );
|
||||
axisWidget( QwtPlot::yLeft )->setMargin( 0 );
|
||||
|
||||
// Store the pointer address as an object name. This way each track can be identified uniquely for CSS-stylesheets
|
||||
QString objectName = QString( "%1" ).arg( reinterpret_cast<uint64_t>( this ) );
|
||||
setObjectName( objectName );
|
||||
|
||||
setDefaultStyleSheet();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogTrack::selectClosestCurve( const QPoint& pos )
|
||||
{
|
||||
QwtPlotCurve* closestCurve = nullptr;
|
||||
double distMin = DBL_MAX;
|
||||
|
||||
const QwtPlotItemList& itmList = itemList();
|
||||
for ( QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++ )
|
||||
{
|
||||
if ( ( *it )->rtti() == QwtPlotItem::Rtti_PlotCurve )
|
||||
{
|
||||
QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>( *it );
|
||||
double dist = DBL_MAX;
|
||||
candidateCurve->closestPoint( pos, &dist );
|
||||
if ( dist < distMin )
|
||||
{
|
||||
closestCurve = candidateCurve;
|
||||
distMin = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( closestCurve && distMin < 20 )
|
||||
{
|
||||
RimWellLogCurve* selectedCurve = m_plotTrackDefinition->curveDefinitionFromCurve( closestCurve );
|
||||
if ( selectedCurve )
|
||||
{
|
||||
RiuPlotMainWindowTools::showPlotMainWindow();
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( selectedCurve );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RiuPlotMainWindowTools::showPlotMainWindow();
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( m_plotTrackDefinition );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiuWellLogTrack::defaultMinimumWidth()
|
||||
{
|
||||
return 80;
|
||||
}
|
||||
|
@ -61,11 +61,19 @@ public:
|
||||
double getCurrentMajorTickInterval() const;
|
||||
double getCurrentMinorTickInterval() const;
|
||||
int axisExtent( QwtPlot::Axis axis ) const;
|
||||
bool frameIsInFrontOfThis( const QRect& frameGeometry );
|
||||
QPoint dragStartPosition() const;
|
||||
void setDefaultStyleSheet();
|
||||
void setStyleSheetForThisObject( const QString& content, const QString& state = "" );
|
||||
|
||||
RimWellLogTrack* plotDefinition() const;
|
||||
|
||||
protected:
|
||||
bool eventFilter( QObject* watched, QEvent* event ) override;
|
||||
QSize sizeHint() const override;
|
||||
QSize minimumSizeHint() const override;
|
||||
void mousePressEvent( QMouseEvent* event ) override;
|
||||
void mouseMoveEvent( QMouseEvent* event ) override;
|
||||
|
||||
private:
|
||||
void setDefaults();
|
||||
@ -74,4 +82,5 @@ private:
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimWellLogTrack> m_plotTrackDefinition;
|
||||
QPoint m_dragStartPosition;
|
||||
};
|
||||
|
@ -46,7 +46,9 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QComboBox>
|
||||
#include <QDebug>
|
||||
#include <QLabel>
|
||||
#include <QListView>
|
||||
#include <QWheelEvent>
|
||||
|
||||
|
||||
@ -197,11 +199,18 @@ void PdmUiComboBoxEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
|
||||
m_comboBox->blockSignals(true);
|
||||
m_comboBox->clear();
|
||||
QListView* listView = dynamic_cast<QListView*>(m_comboBox->view());
|
||||
if (listView)
|
||||
{
|
||||
listView->setSpacing(2);
|
||||
}
|
||||
|
||||
if (!options.isEmpty())
|
||||
{
|
||||
for (int i = 0; i < options.size(); i++)
|
||||
{
|
||||
m_comboBox->addItem(options[i].icon(), options[i].optionUiText());
|
||||
m_comboBox->setIconSize(attributes.iconSize);
|
||||
}
|
||||
m_comboBox->setCurrentIndex(uiField()->uiValue().toInt());
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
adjustWidthToContents = false;
|
||||
showPreviousAndNextButtons = false;
|
||||
minimumContentsLength = 8;
|
||||
iconSize = QSize(14, 14);
|
||||
}
|
||||
|
||||
public:
|
||||
@ -68,7 +69,7 @@ public:
|
||||
bool showPreviousAndNextButtons;
|
||||
int minimumContentsLength; // The length of string to adjust to if adjustWidthToContents = false.
|
||||
// Set to <= 0 to ignore and use AdjustToContentsOnFirstShow instead
|
||||
|
||||
QSize iconSize;
|
||||
QString nextButtonText;
|
||||
QString prevButtonText;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user