Skip to content
Permalink
Browse files

Revert CVD function names to avoid API breakage

  • Loading branch information
willcohen authored and nyalldawson committed Oct 27, 2020
1 parent 7bd81df commit ea628e3129ef2514a2ef51d93868325ce5f9604c
@@ -24,10 +24,10 @@ color blindness modes.
enum PreviewMode
{
PreviewMono,
PreviewAchromatopsia,
PreviewProtanopia,
PreviewDeuteranopia,
PreviewTritanopia
PreviewGrayscale
PreviewProtanope,
PreviewDeuteranope,
PreviewTritanope
};

QgsPreviewEffect( QObject *parent /TransferThis/ );
@@ -557,35 +557,34 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
mView->setPreviewMode( QgsPreviewEffect::PreviewMono );
mView->setPreviewModeEnabled( true );
} );
connect( mActionPreviewAchromatopsia, &QAction::triggered, this, [ = ]
connect( mActionPreviewModeGrayscale, &QAction::triggered, this, [ = ]
{
mView->setPreviewMode( QgsPreviewEffect::PreviewAchromatopsia );
mView->setPreviewMode( QgsPreviewEffect::PreviewGrayscale );
mView->setPreviewModeEnabled( true );
} );
connect( mActionPreviewProtanopia, &QAction::triggered, this, [ = ]
connect( mActionPreviewProtanope, &QAction::triggered, this, [ = ]
{
mView->setPreviewMode( QgsPreviewEffect::PreviewProtanopia );
mView->setPreviewMode( QgsPreviewEffect::PreviewProtanope );
mView->setPreviewModeEnabled( true );
} );
connect( mActionPreviewDeuteranopia, &QAction::triggered, this, [ = ]
connect( mActionPreviewDeuteranope, &QAction::triggered, this, [ = ]
{
mView->setPreviewMode( QgsPreviewEffect::PreviewDeuteranopia );
mView->setPreviewMode( QgsPreviewEffect::PreviewDeuteranope );
mView->setPreviewModeEnabled( true );
} );
connect( mActionPreviewTritanopia, &QAction::triggered, this, [ = ]
connect( mActionPreviewTritanope, &QAction::triggered, this, [ = ]
{
mView->setPreviewMode( QgsPreviewEffect::PreviewTritanopia );
mView->setPreviewMode( QgsPreviewEffect::PreviewTritanope );
mView->setPreviewModeEnabled( true );
} );
QActionGroup *previewGroup = new QActionGroup( this );
previewGroup->setExclusive( true );
mActionPreviewModeOff->setActionGroup( previewGroup );
mActionPreviewModeGrayscale->setActionGroup( previewGroup );
mActionPreviewModeMono->setActionGroup( previewGroup );
mActionPreviewAchromatopsia->setActionGroup( previewGroup );
mActionPreviewProtanopia->setActionGroup( previewGroup );
mActionPreviewDeuteranopia->setActionGroup( previewGroup );
mActionPreviewTritanopia->setActionGroup( previewGroup );
mActionPreviewProtanope->setActionGroup( previewGroup );
mActionPreviewDeuteranope->setActionGroup( previewGroup );
mActionPreviewTritanope->setActionGroup( previewGroup );

connect( mActionSaveAsTemplate, &QAction::triggered, this, &QgsLayoutDesignerDialog::saveAsTemplate );
connect( mActionLoadFromTemplate, &QAction::triggered, this, &QgsLayoutDesignerDialog::addItemsFromTemplate );
@@ -3062,10 +3062,10 @@ void QgisApp::createActionGroups()
mPreviewGroup->setExclusive( true );
mActionPreviewModeOff->setActionGroup( mPreviewGroup );
mActionPreviewModeMono->setActionGroup( mPreviewGroup );
mActionPreviewAchromatopsia->setActionGroup( mPreviewGroup );
mActionPreviewProtanopia->setActionGroup( mPreviewGroup );
mActionPreviewDeuteranopia->setActionGroup( mPreviewGroup );
mActionPreviewTritanopia->setActionGroup( mPreviewGroup );
mActionPreviewGrayscale->setActionGroup( mPreviewGroup );
mActionPreviewProtanope->setActionGroup( mPreviewGroup );
mActionPreviewDeuteranope->setActionGroup( mPreviewGroup );
mActionPreviewTritanope->setActionGroup( mPreviewGroup );
}

void QgisApp::setAppStyleSheet( const QString &stylesheet )
@@ -4304,10 +4304,10 @@ void QgisApp::setupConnections()
// connect preview modes actions
connect( mActionPreviewModeOff, &QAction::triggered, this, &QgisApp::disablePreviewMode );
connect( mActionPreviewModeMono, &QAction::triggered, this, &QgisApp::activateMonoPreview );
connect( mActionPreviewAchromatopsia, &QAction::triggered, this, &QgisApp::activateAchromatopsiaPreview );
connect( mActionPreviewProtanopia, &QAction::triggered, this, &QgisApp::activateProtanopiaPreview );
connect( mActionPreviewDeuteranopia, &QAction::triggered, this, &QgisApp::activateDeuteranopiaPreview );
connect( mActionPreviewTritanopia, &QAction::triggered, this, &QgisApp::activateTritanopiaPreview );
connect( mActionPreviewGrayscale, &QAction::triggered, this, &QgisApp::activateGrayscalePreview );
connect( mActionPreviewProtanope, &QAction::triggered, this, &QgisApp::activateProtanopePreview );
connect( mActionPreviewDeuteranope, &QAction::triggered, this, &QgisApp::activateDeuteranopePreview );
connect( mActionPreviewTritanope, &QAction::triggered, this, &QgisApp::activateTritanopePreview );

// setup undo/redo actions
connect( mUndoWidget, &QgsUndoWidget::undoStackChanged, this, &QgisApp::updateUndoActions );
@@ -7698,28 +7698,28 @@ void QgisApp::activateMonoPreview()
mMapCanvas->setPreviewMode( QgsPreviewEffect::PreviewMono );
}

void QgisApp::activateAchromatopsiaPreview()
void QgisApp::activateGrayscalePreview()
{
mMapCanvas->setPreviewModeEnabled( true );
mMapCanvas->setPreviewMode( QgsPreviewEffect::PreviewAchromatopsia );
mMapCanvas->setPreviewMode( QgsPreviewEffect::PreviewGrayscale );
}

void QgisApp::activateProtanopiaPreview()
void QgisApp::activateProtanopePreview()
{
mMapCanvas->setPreviewModeEnabled( true );
mMapCanvas->setPreviewMode( QgsPreviewEffect::PreviewProtanopia );
mMapCanvas->setPreviewMode( QgsPreviewEffect::PreviewProtanope );
}

void QgisApp::activateDeuteranopiaPreview()
void QgisApp::activateDeuteranopePreview()
{
mMapCanvas->setPreviewModeEnabled( true );
mMapCanvas->setPreviewMode( QgsPreviewEffect::PreviewDeuteranopia );
mMapCanvas->setPreviewMode( QgsPreviewEffect::PreviewDeuteranope );
}

void QgisApp::activateTritanopiaPreview()
void QgisApp::activateTritanopePreview()
{
mMapCanvas->setPreviewModeEnabled( true );
mMapCanvas->setPreviewMode( QgsPreviewEffect::PreviewTritanopia );
mMapCanvas->setPreviewMode( QgsPreviewEffect::PreviewTritanope );
}

void QgisApp::toggleFilterLegendByExpression( bool checked )
@@ -1895,29 +1895,28 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void activateMonoPreview();

/**
* Enable a color blindness (achromatopsia) preview mode on the map canvas
* Replaces the grayscale preview mode
* \since QGIS 3.17
* Enable a grayscale preview mode on the map canvas
* \since QGIS 2.3
*/
void activateAchromatopsiaPreview();
void activateGrayscalePreview();

/**
* Enable a color blindness (protanopia) preview mode on the map canvas
* \since QGIS 2.3
*/
void activateProtanopiaPreview();
void activateProtanopePreview();

/**
* Enable a color blindness (deuteranopia) preview mode on the map canvas
* \since QGIS 2.3
*/
void activateDeuteranopiaPreview();
void activateDeuteranopePreview();

/**
* Enable a color blindness (tritanopia) preview mode on the map canvas
* \since QGIS 3.17
*/
void activateTritanopiaPreview();
void activateTritanopePreview();

void toggleFilterLegendByExpression( bool );
void updateFilterLegend();
@@ -2410,7 +2410,7 @@ QgsPreviewEffect::PreviewMode QgsMapCanvas::previewMode() const
{
if ( !mPreviewEffect )
{
return QgsPreviewEffect::PreviewAchromatopsia;
return QgsPreviewEffect::PreviewGrayscale;
}

return mPreviewEffect->mode();
@@ -21,7 +21,7 @@

QgsPreviewEffect::QgsPreviewEffect( QObject *parent )
: QGraphicsEffect( parent )
, mMode( PreviewAchromatopsia )
, mMode( PreviewGrayscale )
{
//effect is disabled by default
setEnabled( false );
@@ -60,10 +60,10 @@ void QgsPreviewEffect::draw( QPainter *painter )
painter->drawImage( offset, bwImage );
break;
}
case QgsPreviewEffect::PreviewAchromatopsia:
case QgsPreviewEffect::PreviewProtanopia:
case QgsPreviewEffect::PreviewDeuteranopia:
case QgsPreviewEffect::PreviewTritanopia:
case QgsPreviewEffect::PreviewGrayscale:
case QgsPreviewEffect::PreviewProtanope:
case QgsPreviewEffect::PreviewDeuteranope:
case QgsPreviewEffect::PreviewTritanope:
{
QRgb *line = nullptr;

@@ -98,17 +98,17 @@ QRgb QgsPreviewEffect::simulateColorBlindness( QRgb &originalColor, QgsPreviewEf
//https://www.inf.ufrgs.br/~oliveira/pubs_files/CVD_Simulation/CVD_Simulation.html
switch ( mode )
{
case PreviewAchromatopsia:
simulateAchromatopsia( r, g, b, red, green, blue );
case PreviewGrayscale:
simulateGrayscale( r, g, b, red, green, blue );
break;
case PreviewProtanopia:
simulateProtanopia( r, g, b, red, green, blue );
case PreviewProtanope:
simulateProtanope( r, g, b, red, green, blue );
break;
case PreviewDeuteranopia:
simulateDeuteranopia( r, g, b, red, green, blue );
case PreviewDeuteranope:
simulateDeuteranope( r, g, b, red, green, blue );
break;
case PreviewTritanopia:
simulateTritanopia( r, g, b, red, green, blue );
case PreviewTritanope:
simulateTritanope( r, g, b, red, green, blue );
break;
default:
break;
@@ -122,28 +122,28 @@ QRgb QgsPreviewEffect::simulateColorBlindness( QRgb &originalColor, QgsPreviewEf
return qRgb( r, g, b );
}

void QgsPreviewEffect::simulateAchromatopsia( int &r, int &g, int &b, int &red, int &green, int &blue )
void QgsPreviewEffect::simulateGrayscale( int &r, int &g, int &b, int &red, int &green, int &blue )
{
r = ( 0.299 * red ) + ( 0.587 * green ) + ( 0.114 * blue );
g = r;
b = r;
}

void QgsPreviewEffect::simulateProtanopia( int &r, int &g, int &b, int &red, int &green, int &blue )
void QgsPreviewEffect::simulateProtanope( int &r, int &g, int &b, int &red, int &green, int &blue )
{
r = ( 0.152286 * red ) + ( 1.052583 * green ) + ( -0.204868 * blue );
g = ( 0.114503 * red ) + ( 0.786281 * green ) + ( 0.099216 * blue );
b = ( -0.003882 * red ) + ( -0.048116 * green ) + ( 1.051998 * blue );
}

void QgsPreviewEffect::simulateDeuteranopia( int &r, int &g, int &b, int &red, int &green, int &blue )
void QgsPreviewEffect::simulateDeuteranope( int &r, int &g, int &b, int &red, int &green, int &blue )
{
r = ( 0.367322 * red ) + ( 0.860646 * green ) + ( -0.227968 * blue );
g = ( 0.280085 * red ) + ( 0.672501 * green ) + ( 0.047413 * blue );
b = ( -0.011820 * red ) + ( 0.042940 * green ) + ( 0.968881 * blue );
}

void QgsPreviewEffect::simulateTritanopia( int &r, int &g, int &b, int &red, int &green, int &blue )
void QgsPreviewEffect::simulateTritanope( int &r, int &g, int &b, int &red, int &green, int &blue )
{
r = ( 1.255528 * red ) + ( -0.076749 * green ) + ( -0.178779 * blue );
g = ( -0.078411 * red ) + ( 0.930809 * green ) + ( 0.147602 * blue );
@@ -36,10 +36,10 @@ class GUI_EXPORT QgsPreviewEffect: public QGraphicsEffect
enum PreviewMode
{
PreviewMono,
PreviewAchromatopsia,
PreviewProtanopia,
PreviewDeuteranopia,
PreviewTritanopia
PreviewGrayscale,
PreviewProtanope,
PreviewDeuteranope,
PreviewTritanope
};

QgsPreviewEffect( QObject *parent SIP_TRANSFERTHIS );
@@ -68,10 +68,10 @@ class GUI_EXPORT QgsPreviewEffect: public QGraphicsEffect
PreviewMode mMode;

QRgb simulateColorBlindness( QRgb &originalColor, PreviewMode type );
void simulateAchromatopsia( int &r, int &g, int &b, int &red, int &green, int &blue );
void simulateProtanopia( int &r, int &g, int &b, int &red, int &green, int &blue );
void simulateDeuteranopia( int &r, int &g, int &b, int &red, int &green, int &blue );
void simulateTritanopia( int &r, int &g, int &b, int &red, int &green, int &blue );
void simulateGrayscale( int &r, int &g, int &b, int &red, int &green, int &blue );
void simulateProtanope( int &r, int &g, int &b, int &red, int &green, int &blue );
void simulateDeuteranope( int &r, int &g, int &b, int &red, int &green, int &blue );
void simulateTritanope( int &r, int &g, int &b, int &red, int &green, int &blue );
};

#endif // QGSPREVIEWEFFECT_H
@@ -243,10 +243,10 @@
</property>
<addaction name="mActionPreviewModeOff"/>
<addaction name="mActionPreviewModeMono"/>
<addaction name="mActionPreviewAchromatopsia"/>
<addaction name="mActionPreviewProtanopia"/>
<addaction name="mActionPreviewDeuteranopia"/>
<addaction name="mActionPreviewTritanopia"/>
<addaction name="mActionPreviewGrayscale"/>
<addaction name="mActionPreviewProtanope"/>
<addaction name="mActionPreviewDeuteranope"/>
<addaction name="mActionPreviewTritanope"/>
</widget>
<addaction name="mActionRefreshView"/>
<addaction name="menuPreview"/>
@@ -1086,14 +1086,6 @@
<string>Normal</string>
</property>
</action>
<action name="mActionPreviewModeGrayscale">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Simulate Photocopy (&amp;Grayscale)</string>
</property>
</action>
<action name="mActionPreviewModeMono">
<property name="checkable">
<bool>true</bool>
@@ -1102,31 +1094,31 @@
<string>Simulate Fax (&amp;Mono)</string>
</property>
</action>
<action name="mActionPreviewAchromatopsia">
<action name="mActionPreviewModeGrayscale">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Simulate Achromatopsia Color Blindness and Photocopy (&amp;Grayscale)</string>
</property>
</action>
<action name="mActionPreviewProtanopia">
<action name="mActionPreviewProtanope">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Simulate Protonopia Color Blindness (&amp;No Red)</string>
</property>
</action>
<action name="mActionPreviewDeuteranopia">
<action name="mActionPreviewDeuteranope">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Simulate Deuteranopia Color Blindness (&amp;No Green)</string>
</property>
</action>
<action name="mActionPreviewTritanopia">
<action name="mActionPreviewTritanope">
<property name="checkable">
<bool>true</bool>
</property>

0 comments on commit ea628e3

Please sign in to comment.
You can’t perform that action at this time.