Skip to content

Commit

Permalink
Started adding colocalization widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Glowacki committed Mar 7, 2023
1 parent 1e21976 commit bdad89b
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 148 deletions.
53 changes: 25 additions & 28 deletions src/gstar/AbstractImageWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ using namespace gstar;
AbstractImageWidget::AbstractImageWidget(int rows, int cols, QWidget* parent)
: QWidget(parent)
{

// Background
m_treeModel = nullptr;
m_annotationToolbar = nullptr;
m_coordinateModel = nullptr;
m_imageWidgetToolBar = nullptr;
m_range = nullptr;
m_imageWidthDim = nullptr;
m_imageHeightDim = nullptr;
m_tabWidget = new QTabWidget(this);
//m_tabWidget->setPalette(pal);
//m_tabWidget->setAutoFillBackground(true);
//m_tabWidget->addTab(layoutWidget, QIcon(), "Annotations");
//QPalette pal = this->palette();
//pal.setColor(this->backgroundRole(), Qt::white);
//this->setPalette(pal);
Expand Down Expand Up @@ -82,16 +86,10 @@ AbstractImageWidget::AbstractImageWidget(int rows, int cols, QWidget* parent)

createAnnotationToolBar();

m_tabWidget = new QTabWidget();
//m_tabWidget->setPalette(pal);
//m_tabWidget->setAutoFillBackground(true);

m_annotationsEnabled = true;
//add it in parent class so you can control what tab it is on.
//m_tabWidget->addTab(layoutWidget, QIcon(), "Annotations");

//m_lblPixelXCoordinate = nullptr;

//m_lblPixelXCoordinate = nullptr;
}

/*---------------------------------------------------------------------------*/
Expand All @@ -100,13 +98,14 @@ AbstractImageWidget::~AbstractImageWidget()
{

m_imageViewWidget->setSceneSelectionModel(nullptr);

if(m_treeModel != nullptr)
{
delete m_treeModel;
m_treeModel = nullptr;
}

if(m_treeModel != nullptr)
{
delete m_treeModel;
m_treeModel = nullptr;
}

/*
if(m_annotationToolbar != nullptr)
{
delete m_annotationToolbar;
Expand All @@ -118,7 +117,7 @@ AbstractImageWidget::~AbstractImageWidget()
delete m_imageWidgetToolBar;
m_imageWidgetToolBar = nullptr;
}

*/
}

/*---------------------------------------------------------------------------*/
Expand All @@ -145,21 +144,19 @@ void AbstractImageWidget::addRuler()

void AbstractImageWidget::appendAnnotationTab(bool bToolbar)
{
QVBoxLayout* infoLayout = new QVBoxLayout();
if (bToolbar)
{
infoLayout->addWidget(m_annotationToolbar->getToolBar());
}
infoLayout->addWidget(m_annoTreeView);

QVBoxLayout* infoLayout = new QVBoxLayout();
if (bToolbar)
{
infoLayout->addWidget(m_annotationToolbar->getToolBar());
}
infoLayout->addWidget(m_annoTreeView);

m_treeTabWidget = new QWidget(this);
//m_treeTabWidget->setPalette(pal);
//m_treeTabWidget->setAutoFillBackground(true);
m_treeTabWidget->setLayout(infoLayout);

m_tabWidget->addTab(m_treeTabWidget, QIcon(), "Annotations");
m_treeTabWidget = new QWidget(this);
//m_treeTabWidget->setPalette(pal);
//m_treeTabWidget->setAutoFillBackground(true);
m_treeTabWidget->setLayout(infoLayout);

m_tabWidget->addTab(m_treeTabWidget, QIcon(), "Annotations");
}

/*---------------------------------------------------------------------------*/
Expand Down
2 changes: 1 addition & 1 deletion src/gstar/AbstractImageWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class AbstractImageWidget
/**
* Destructor.
*/
~AbstractImageWidget();
virtual ~AbstractImageWidget();

/**
* @brief appendTab
Expand Down
113 changes: 28 additions & 85 deletions src/mvc/CoLocalizationWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
CoLocalizationWidget::CoLocalizationWidget(QWidget* parent) : gstar::AbstractImageWidget(1, 1, parent)
{
_model = nullptr;
setAnnotationsEnabled(false);
_createLayout();
createActions();
}

//---------------------------------------------------------------------------
Expand All @@ -33,23 +35,36 @@ void CoLocalizationWidget::_createLayout()
{

QVBoxLayout* layout = new QVBoxLayout();
layout->addWidget(m_imageViewWidget);
QLayout* gen_layout = generateDefaultLayout(true);

//_imageViewWidget->setSceneModel(m_treeModel);
//_imageViewWidget->setSceneSelectionModel(m_selectionModel);
/*
_imageViewWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(_imageViewWidget,
SIGNAL(customContextMenuRequested(const QPoint&)),
this,
SLOT(viewContextMenu(const QPoint&)));
*/
m_imageViewWidget->setCoordsVisible(false);
m_imageViewWidget->setSelectorVisible(false);
m_imageViewWidget->setCountsVisible(false);

_cb_red_element = new QComboBox();

_cb_green_element = new QComboBox();

_cb_blue_element = new QComboBox();

QHBoxLayout* hb = new QHBoxLayout();
hb->addWidget(new QLabel("Red Element"));
hb->addWidget(_cb_red_element);

hb->addWidget(new QLabel("Green Element"));
hb->addWidget(_cb_green_element);

hb->addWidget(new QLabel("Blue Element"));
hb->addWidget(_cb_blue_element);
layout->addItem(hb);

appendAnnotationTab(false);

layout->addItem(gen_layout);
//layout->addWidget(m_imageViewWidget);

//don't erase counts when mouse is off scene
//_imageViewWidget->set_null_mouse_pos = false;
//connect(_imageViewWidget, SIGNAL(cbLabelChanged(QString, int)), this, SLOT(onElementSelect(QString, int)));

//connect(_imageViewWidget, &gstar::ImageViewWidget::parent_redraw, this, &CoLocalizationWidget::redrawCounts);

//createActions();

Expand Down Expand Up @@ -77,13 +92,6 @@ void CoLocalizationWidget::_createLayout()

//---------------------------------------------------------------------------
/*
void CoLocalizationWidget::onGridDialog()
{
iDiag.show();
}
//---------------------------------------------------------------------------
void CoLocalizationWidget::on_global_contrast_changed(int state)
Expand Down Expand Up @@ -137,36 +145,6 @@ void CoLocalizationWidget::onNewGridLayout(int rows, int cols)
Preferences::inst()->save();
}

//---------------------------------------------------------------------------
/*
void CoLocalizationWidget::addRoiMask()
{
int w = _imageViewWidget->scene()->getPixmapItem()->pixmap().width();
int h = _imageViewWidget->scene()->getPixmapItem()->pixmap().height();
gstar::RoiMaskGraphicsItem* annotation = new gstar::RoiMaskGraphicsItem(w, h);
insertAndSelectAnnotation(m_treeModel, m_annoTreeView, m_selectionModel, annotation);
//QString name = ano->getName();
//_spectra_widget->appendROISpectra()
// //data_struct Spectra = _model->load_roi(annotation->getROI());
connect(annotation, &gstar::RoiMaskGraphicsItem::mask_updated, this, &CoLocalizationWidget::roiUpdated);
}
*/
//---------------------------------------------------------------------------

void CoLocalizationWidget::roiUpdated(gstar::RoiMaskGraphicsItem* ano, bool reload)
{
if (ano != nullptr && reload)
{
{

}
}

}

//---------------------------------------------------------------------------

void CoLocalizationWidget::createActions()
Expand Down Expand Up @@ -264,41 +242,6 @@ void CoLocalizationWidget::onElementSelect(QString name, int viewIdx)
//---------------------------------------------------------------------------
void CoLocalizationWidget::onColormapSelect(QString colormap)
{
if(colormap == STR_COLORMAP_GRAY)
{
_selected_colormap = &_gray_colormap;
Preferences::inst()->setValue(STR_COLORMAP, STR_COLORMAP_GRAY);
}
else if(colormap == STR_COLORMAP_HEAT)
{
_selected_colormap = &_heat_colormap;
Preferences::inst()->setValue(STR_COLORMAP, STR_COLORMAP_HEAT);
}
else
{
_selected_colormap = ColorMap::inst()->get_color_map(colormap);
if (_selected_colormap == nullptr)
{
_selected_colormap = &_gray_colormap;
Preferences::inst()->setValue(STR_COLORMAP, STR_COLORMAP_GRAY);
}
else
{
Preferences::inst()->setValue(STR_COLORMAP, colormap);
}
}
_color_maps_ledgend->setColorTable(*_selected_colormap);
_color_map_ledgend_lbl->setPixmap(QPixmap::fromImage(_color_maps_ledgend->convertToFormat(QImage::Format_RGB32)));
redrawCounts();
Preferences::inst()->save();
}
//---------------------------------------------------------------------------
void CoLocalizationWidget::onSelectNormalizer(QString name)
{
if (name == "1")
Expand Down
34 changes: 10 additions & 24 deletions src/mvc/CoLocalizationWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CoLocalizationWidget : public gstar::AbstractImageWidget
/**
* Destructor.
*/
~CoLocalizationWidget();
virtual ~CoLocalizationWidget();

void setModel(MapsH5Model* h5_model);

Expand All @@ -46,31 +46,11 @@ public slots:

void redrawCounts();

void windowChanged(Qt::WindowStates oldState, Qt::WindowStates newState);
void windowChanged(Qt::WindowStates oldState, Qt::WindowStates newState);

void displayCounts(const std::string analysis_type, const std::string element, bool log_color, int grid_idx = 0);
void displayCounts(const std::string analysis_type, const std::string element, bool log_color, int grid_idx = 0);

//QPixmap generate_pixmap(const std::string analysis_type, const std::string element, bool log_color, int grid_idx);

//void onAnalysisSelect(QString name);

//void onElementSelect(QString name, int viewIdx = 0);

//void addRoiMask();

void roiUpdated(gstar::RoiMaskGraphicsItem* ano, bool reload);

//void onGridDialog();

void onNewGridLayout(int rows, int cols);

/*
void on_export_csv_and_png(QPixmap, ArrayDr*, ArrayDr*, ArrayDr*, ArrayDr*, unordered_map<string, ArrayDr>*);
void on_export_image_pressed();
void on_export_images();
*/
void onNewGridLayout(int rows, int cols);

protected:

Expand All @@ -93,6 +73,12 @@ public slots:

QWidget* _counts_window;

QComboBox* _cb_red_element;

QComboBox* _cb_green_element;

QComboBox* _cb_blue_element;

};


Expand Down
8 changes: 1 addition & 7 deletions src/mvc/ImageSegWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ImageSegWidget
/**
* Destructor.
*/
~ImageSegWidget();
virtual ~ImageSegWidget();

/**
* @brief widgetChanged
Expand Down Expand Up @@ -65,12 +65,6 @@ public slots:

protected slots:

//void mouseOverPixel(int x, int y);

//void mousePressEvent(QGraphicsSceneMouseEvent*);

//void mouseReleaseEvent(QGraphicsSceneMouseEvent*);

void currentRoiChanged(const QModelIndex& current, const QModelIndex& previous);

protected:
Expand Down
9 changes: 8 additions & 1 deletion src/mvc/MapsElementsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,19 @@ MapsElementsWidget::~MapsElementsWidget()
}
_model = nullptr;
*/
/*
if (_co_loc_widget != nullptr)
{
delete _co_loc_widget;
}
_co_loc_widget = nullptr;
if(_spectra_widget != nullptr)
{
delete _spectra_widget;
}
_spectra_widget = nullptr;

*/
}

//---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/mvc/MapsElementsWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MapsElementsWidget
/**
* Destructor.
*/
~MapsElementsWidget();
virtual ~MapsElementsWidget();

void setModel(MapsH5Model* h5_model);

Expand Down
2 changes: 1 addition & 1 deletion src/mvc/VLM_Widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class VLM_Widget
/**
* Destructor.
*/
~VLM_Widget();
virtual ~VLM_Widget();

/**
* @brief setCoordinateModel: Model is displayed at the bottom of the screen
Expand Down

0 comments on commit bdad89b

Please sign in to comment.