+ apply changes
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5109 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
parent
72bfc3c74b
commit
c4fe31a837
|
@ -85,50 +85,15 @@ void ImageView::createActions()
|
||||||
_pOneToOneAct->setStatusTip(tr("Display the image at a 1:1 scale"));
|
_pOneToOneAct->setStatusTip(tr("Display the image at a 1:1 scale"));
|
||||||
connect(_pOneToOneAct, SIGNAL(triggered()), this, SLOT(oneToOneImage()));
|
connect(_pOneToOneAct, SIGNAL(triggered()), this, SLOT(oneToOneImage()));
|
||||||
|
|
||||||
// Create an action group for the exclusive color actions
|
|
||||||
_pShowColActGrp = new QActionGroup (this);
|
|
||||||
_pShowColActGrp->setExclusive(true);
|
|
||||||
connect(_pShowColActGrp, SIGNAL(triggered(QAction*)), this, SLOT(handleColorAct(QAction*)));
|
|
||||||
|
|
||||||
_pShowOrigAct = new QAction(_pShowColActGrp);
|
|
||||||
_pShowOrigAct->setCheckable(true);
|
|
||||||
_pShowOrigAct->setText(tr("&Original color"));
|
|
||||||
_pShowOrigAct->setIcon(QPixmap(image_orig));
|
|
||||||
_pShowOrigAct->setStatusTip(tr("Display the image with its original color(s)"));
|
|
||||||
|
|
||||||
_pShowBrightAct = new QAction(_pShowColActGrp);
|
|
||||||
_pShowBrightAct->setCheckable(true);
|
|
||||||
_pShowBrightAct->setText(tr("&Brightened color"));
|
|
||||||
_pShowBrightAct->setIcon(QPixmap(image_bright));
|
|
||||||
_pShowBrightAct->setStatusTip(tr("Display the image with brightened color(s)"));
|
|
||||||
|
|
||||||
// Create the menus and add the actions
|
// Create the menus and add the actions
|
||||||
_pContextMenu = new QMenu(this);
|
_pContextMenu = new QMenu(this);
|
||||||
_pContextMenu->addAction(_pFitAct);
|
_pContextMenu->addAction(_pFitAct);
|
||||||
_pContextMenu->addAction(_pOneToOneAct);
|
_pContextMenu->addAction(_pOneToOneAct);
|
||||||
_pContextMenu->addAction(_pShowOrigAct);
|
|
||||||
_pContextMenu->addAction(_pShowBrightAct);
|
|
||||||
|
|
||||||
// Create the toolbars and add the actions
|
// Create the toolbars and add the actions
|
||||||
_pStdToolBar = this->addToolBar(tr("Standard"));
|
_pStdToolBar = this->addToolBar(tr("Standard"));
|
||||||
_pStdToolBar->addAction(_pFitAct);
|
_pStdToolBar->addAction(_pFitAct);
|
||||||
_pStdToolBar->addAction(_pOneToOneAct);
|
_pStdToolBar->addAction(_pOneToOneAct);
|
||||||
_pStdToolBar->addAction(_pShowOrigAct);
|
|
||||||
_pStdToolBar->addAction(_pShowBrightAct);
|
|
||||||
|
|
||||||
// Add a slider to the toolbar (for brightness adjustment)
|
|
||||||
_sliderBrightAdjVal = 10;
|
|
||||||
_pSliderBrightAdj = new QSlider(Qt::Horizontal, _pStdToolBar);
|
|
||||||
_pSliderBrightAdj->setRange(0, 100);
|
|
||||||
_pSliderBrightAdj->setValue(_sliderBrightAdjVal);
|
|
||||||
_pSliderBrightAdj->setPageStep(10);
|
|
||||||
_pStdToolBar->addWidget(_pSliderBrightAdj);
|
|
||||||
_pSliderBrightAdj->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
|
|
||||||
_pSliderBrightAdj->setEnabled(false);
|
|
||||||
connect(_pSliderBrightAdj, SIGNAL(valueChanged(int)), this, SLOT(sliderValueAdjusted(int)));
|
|
||||||
|
|
||||||
// Set the original color action to ON
|
|
||||||
_pShowOrigAct->setChecked(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable or disable the status bar
|
// Enable or disable the status bar
|
||||||
|
@ -176,31 +141,6 @@ void ImageView::EnableFitImageAction(bool Enable)
|
||||||
_pFitAct->setVisible(Enable);
|
_pFitAct->setVisible(Enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable (show) or disable (hide) the color actions (_pShowOrigAct and _pShowBrightAct)
|
|
||||||
// If enabling:
|
|
||||||
// image is redisplayed with either original or brightened colors (depending on which state the toggle buttons are in)
|
|
||||||
// If disabling
|
|
||||||
// color map is left as is and image is not redisplayed
|
|
||||||
// This function should be used to hide the color actions when a derived class implements its own color map scheme
|
|
||||||
void ImageView::EnableColorActions(bool Enable)
|
|
||||||
{
|
|
||||||
if (Enable == true)
|
|
||||||
{
|
|
||||||
_pShowOrigAct->setVisible(true);
|
|
||||||
_pShowBrightAct->setVisible(true);
|
|
||||||
if (_pShowBrightAct->isChecked() == true)
|
|
||||||
showBrightened();
|
|
||||||
else
|
|
||||||
showOriginalColors();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_pShowOrigAct->setVisible(false);
|
|
||||||
_pShowBrightAct->setVisible(false);
|
|
||||||
_pSliderBrightAdj->setVisible(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Slot function to fit (stretch/shrink) the image to the view size
|
// Slot function to fit (stretch/shrink) the image to the view size
|
||||||
void ImageView::fitImage()
|
void ImageView::fitImage()
|
||||||
{
|
{
|
||||||
|
@ -216,21 +156,6 @@ void ImageView::oneToOneImage()
|
||||||
updateStatusBar();
|
updateStatusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slot function to handle the color actions
|
|
||||||
void ImageView::handleColorAct( QAction* act)
|
|
||||||
{
|
|
||||||
if (act == _pShowOrigAct)
|
|
||||||
{
|
|
||||||
_pSliderBrightAdj->setEnabled(false);
|
|
||||||
showOriginalColors();
|
|
||||||
}
|
|
||||||
else if (act == _pShowBrightAct)
|
|
||||||
{
|
|
||||||
_pSliderBrightAdj->setEnabled(true);
|
|
||||||
showBrightened();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show the original colors (no enhancement)
|
// Show the original colors (no enhancement)
|
||||||
// but image will be scaled for the number of significant bits
|
// but image will be scaled for the number of significant bits
|
||||||
// (i.e if 12 significant bits (in 16-bit image) a value of 4095 will be shown as white)
|
// (i.e if 12 significant bits (in 16-bit image) a value of 4095 will be shown as white)
|
||||||
|
@ -240,36 +165,6 @@ void ImageView::showOriginalColors()
|
||||||
_pGLImageBox->redraw();
|
_pGLImageBox->redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the image with a brightness adjustment
|
|
||||||
void ImageView::showBrightened()
|
|
||||||
{
|
|
||||||
if (createColorMap(0, false) == 0)
|
|
||||||
{
|
|
||||||
// Fill the color map with the preset enhancement
|
|
||||||
int numMapEntries = getNumColorMapEntries();
|
|
||||||
double expValue = (_sliderBrightAdjVal / 1000.0) * 256 / numMapEntries;
|
|
||||||
for (int in = 0; in < numMapEntries; in++)
|
|
||||||
{
|
|
||||||
double out = 1.0 - exp (-(double)in * expValue);
|
|
||||||
setColorMapRedValue(in, (float)out);
|
|
||||||
setColorMapGreenValue(in, (float)out);
|
|
||||||
setColorMapBlueValue(in, (float)out);
|
|
||||||
setColorMapAlphaValue(in, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// redraw
|
|
||||||
_pGLImageBox->redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Slot function to adjust the brightness slider's value
|
|
||||||
void ImageView::sliderValueAdjusted(int NewValue)
|
|
||||||
{
|
|
||||||
_sliderBrightAdjVal = NewValue;
|
|
||||||
if (_pShowBrightAct->isChecked() == true)
|
|
||||||
showBrightened();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a color map
|
// Create a color map
|
||||||
// (All red entries come first, then green, then blue, then alpha)
|
// (All red entries come first, then green, then blue, then alpha)
|
||||||
// returns 0 for OK, -1 for memory allocation error
|
// returns 0 for OK, -1 for memory allocation error
|
||||||
|
@ -366,9 +261,6 @@ void ImageView::clearImage()
|
||||||
int ImageView::createImageCopy(void* pSrcPixelData, unsigned long width, unsigned long height, int format, unsigned short numSigBitsPerSample, int displayMode)
|
int ImageView::createImageCopy(void* pSrcPixelData, unsigned long width, unsigned long height, int format, unsigned short numSigBitsPerSample, int displayMode)
|
||||||
{
|
{
|
||||||
int ret = _pGLImageBox->createImageCopy(pSrcPixelData, width, height, format, numSigBitsPerSample, displayMode);
|
int ret = _pGLImageBox->createImageCopy(pSrcPixelData, width, height, format, numSigBitsPerSample, displayMode);
|
||||||
if (_pShowBrightAct->isChecked() == true)
|
|
||||||
showBrightened();
|
|
||||||
else
|
|
||||||
showOriginalColors();
|
showOriginalColors();
|
||||||
updateStatusBar();
|
updateStatusBar();
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -393,9 +285,6 @@ int ImageView::createImageCopy(void* pSrcPixelData, unsigned long width, unsigne
|
||||||
int ImageView::pointImageTo(void* pSrcPixelData, unsigned long width, unsigned long height, int format, unsigned short numSigBitsPerSample, bool takeOwnership, int displayMode)
|
int ImageView::pointImageTo(void* pSrcPixelData, unsigned long width, unsigned long height, int format, unsigned short numSigBitsPerSample, bool takeOwnership, int displayMode)
|
||||||
{
|
{
|
||||||
int ret = _pGLImageBox->pointImageTo(pSrcPixelData, width, height, format, numSigBitsPerSample, takeOwnership, displayMode);
|
int ret = _pGLImageBox->pointImageTo(pSrcPixelData, width, height, format, numSigBitsPerSample, takeOwnership, displayMode);
|
||||||
if (_pShowBrightAct->isChecked() == true)
|
|
||||||
showBrightened();
|
|
||||||
else
|
|
||||||
showOriginalColors();
|
showOriginalColors();
|
||||||
updateStatusBar();
|
updateStatusBar();
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -53,7 +53,6 @@ public:
|
||||||
virtual void EnableMouseEvents(bool Enable);
|
virtual void EnableMouseEvents(bool Enable);
|
||||||
virtual void EnableOneToOneAction(bool Enable);
|
virtual void EnableOneToOneAction(bool Enable);
|
||||||
virtual void EnableFitImageAction(bool Enable);
|
virtual void EnableFitImageAction(bool Enable);
|
||||||
virtual void EnableColorActions(bool Enable);
|
|
||||||
virtual int createColorMap(int numEntriesReq = 0, bool Initialise = true);
|
virtual int createColorMap(int numEntriesReq = 0, bool Initialise = true);
|
||||||
virtual void clearColorMap();
|
virtual void clearColorMap();
|
||||||
virtual int getNumColorMapEntries() const;
|
virtual int getNumColorMapEntries() const;
|
||||||
|
@ -68,14 +67,11 @@ public Q_SLOTS:
|
||||||
virtual void oneToOneImage();
|
virtual void oneToOneImage();
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
virtual void handleColorAct( QAction* act);
|
|
||||||
virtual void sliderValueAdjusted(int NewValue);
|
|
||||||
virtual void drawGraphics();
|
virtual void drawGraphics();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void createActions();
|
virtual void createActions();
|
||||||
virtual void showOriginalColors();
|
virtual void showOriginalColors();
|
||||||
virtual void showBrightened();
|
|
||||||
virtual void mousePressEvent(QMouseEvent* cEvent);
|
virtual void mousePressEvent(QMouseEvent* cEvent);
|
||||||
virtual void mouseDoubleClickEvent(QMouseEvent* cEvent);
|
virtual void mouseDoubleClickEvent(QMouseEvent* cEvent);
|
||||||
virtual void mouseMoveEvent(QMouseEvent* cEvent);
|
virtual void mouseMoveEvent(QMouseEvent* cEvent);
|
||||||
|
@ -107,14 +103,9 @@ protected:
|
||||||
int dragStartWCx;
|
int dragStartWCx;
|
||||||
int dragStartWCy;
|
int dragStartWCy;
|
||||||
|
|
||||||
// Action groups
|
|
||||||
QActionGroup* _pShowColActGrp;
|
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
QAction* _pFitAct;
|
QAction* _pFitAct;
|
||||||
QAction* _pOneToOneAct;
|
QAction* _pOneToOneAct;
|
||||||
QAction* _pShowOrigAct;
|
|
||||||
QAction* _pShowBrightAct;
|
|
||||||
|
|
||||||
// Menus
|
// Menus
|
||||||
QMenu* _pContextMenu;
|
QMenu* _pContextMenu;
|
||||||
|
@ -122,14 +113,9 @@ protected:
|
||||||
// Toolbars
|
// Toolbars
|
||||||
QToolBar* _pStdToolBar;
|
QToolBar* _pStdToolBar;
|
||||||
|
|
||||||
// Slider for brightness adjustment
|
|
||||||
QSlider* _pSliderBrightAdj;
|
|
||||||
int _sliderBrightAdjVal;
|
|
||||||
|
|
||||||
// Flag for status bar enablement
|
// Flag for status bar enablement
|
||||||
bool _statusBarEnabled;
|
bool _statusBarEnabled;
|
||||||
bool _mouseEventsEnabled;
|
bool _mouseEventsEnabled;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ImageViewGui
|
} // namespace ImageViewGui
|
||||||
|
|
Loading…
Reference in New Issue
Block a user