Skip to content

Commit

Permalink
Fixed generating and loading vlm
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Glowacki committed Jul 9, 2024
1 parent 09112e6 commit b997c97
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 70 deletions.
4 changes: 2 additions & 2 deletions src/gstar/Annotation/UProbeRegionGraphicsItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,8 +874,8 @@ void UProbeRegionGraphicsItem::updateModel()
&bottomRightY1,
&bottomRightZ1);

m_widthProp->setValue(topLeftX1-topRightX1);
m_heightProp->setValue(topRightY1-bottomRightY1);
m_widthProp->setValue(topRightX1-topLeftX1);
m_heightProp->setValue(bottomRightY1-topRightY1);

}

Expand Down
6 changes: 3 additions & 3 deletions src/gstar/ImageViewWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ImageViewWidget::ImageViewWidget(int rows, int cols , QWidget* parent)
m_zoomOutCursor = QCursor(QPixmap(":/images/zoomout.png"));

m_zoomPercent = nullptr;
m_mouseLeaveState = true;
m_mouseLeaveState = false;
set_null_mouse_pos = true;

/* m_widget = parent;
Expand Down Expand Up @@ -341,7 +341,7 @@ CoordinateWidget* ImageViewWidget::coordinateWidget()
void ImageViewWidget::enterEvent(QEvent * event)
{

m_mouseLeaveState = false;
//m_mouseLeaveState = false;
QWidget::enterEvent(static_cast<QEnterEvent*>(event));

}
Expand Down Expand Up @@ -414,7 +414,7 @@ QPointF ImageViewWidget::getCenterPoint() const
void ImageViewWidget::leaveEvent(QEvent * event)
{

m_mouseLeaveState = true;
//m_mouseLeaveState = true;

if(set_null_mouse_pos)
m_coordWidget -> setnullptr();
Expand Down
7 changes: 4 additions & 3 deletions src/mvc/GenScanVlmWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ void GenScanVlmWidget::_generate()
_btn_scan->setEnabled(false);
QString xml_name =_directory_name+QDir::separator()+"vlm"+QDir::separator()+_gen_name_le->text()+".xml";
QString tif_name =_directory_name+QDir::separator()+"vlm"+QDir::separator()+_gen_name_le->text()+".tif";
QString base_tif_name =_gen_name_le->text()+".tif";
TIFF_Model model;
if(_background_img_loc_le->text().size() > 0)
{
Expand Down Expand Up @@ -409,15 +410,15 @@ void GenScanVlmWidget::_generate()
float per_x = std::abs( mx - min_x_mot) / x_tot_mot;
float px = per_x * f_scene_w;
int width = itr.second[gstar::UPROBE_WIDTH].toInt();
int tlx = px - (width * 0.5);
int tlx = -(width * 0.5);
itr.second[gstar::UPROBE_REAL_POS_X] = QString::number(px);
itr.second[gstar::UPROBE_LIGHT_POS_X] = QString::number(px);
itr.second[gstar::UPROBE_RECT_TLX] = QString::number(tlx);
float my = itr.second[gstar::UPROBE_MICRO_POS_Y].toFloat();
float per_y = std::abs( my - min_y_mot) / y_tot_mot;
float py = per_y * f_scene_h;
int height = itr.second[gstar::UPROBE_HEIGHT].toInt();
int tly = py - (height * 0.5);
int tly = -(height * 0.5);
itr.second[gstar::UPROBE_REAL_POS_Y] = QString::number(py);
itr.second[gstar::UPROBE_LIGHT_POS_Y] = QString::number(py);
itr.second[gstar::UPROBE_RECT_TLY] = QString::number(tly);
Expand All @@ -427,7 +428,7 @@ void GenScanVlmWidget::_generate()
{
model.save_xml(xml_name);
}
emit new_scan_area(tif_name);
emit new_scan_area(base_tif_name);
close();

_btn_browse->setEnabled(true);
Expand Down
2 changes: 0 additions & 2 deletions src/mvc/VLM_Widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1992,8 +1992,6 @@ void VLM_Widget::restoreMarkerLoaded()
QPointF(marker[UPROBE_REAL_POS_X].toDouble(),
marker[UPROBE_REAL_POS_Y].toDouble()));

annotation->setPos(QPointF(marker[UPROBE_REAL_POS_X].toDouble(),
marker[UPROBE_REAL_POS_Y].toDouble()));
annotation->setPropertyValue(UPROBE_NAME,QVariant(marker[UPROBE_NAME]));
annotation->setPropertyValue(UPROBE_PRED_POS_X,marker[UPROBE_PRED_POS_X]);
annotation->setPropertyValue(UPROBE_PRED_POS_Y,marker[UPROBE_PRED_POS_Y]);
Expand Down
69 changes: 19 additions & 50 deletions src/solver/LinearCoordTransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@

LinearCoordTransformer::LinearCoordTransformer() : ITransformer()
{


_coefs[QSTR_SlopeX] = 1.0;
_coefs[QSTR_SlopeY] = 1.0;
_coefs[QSTR_InterceptX] = 0.0;
_coefs[QSTR_InterceptY] = 0.0;
_coefs[QSTR_SlopeXY] = 0.0;
_coefs[QSTR_InterceptXY] = 0.0;
_coefs[QSTR_SlopeYX] = 0.0;
_coefs[QSTR_InterceptYX] = 0.0;
}

//---------------------------------------------------------------------------
Expand All @@ -26,28 +32,14 @@ LinearCoordTransformer::~LinearCoordTransformer()
QMap<QString, double> LinearCoordTransformer::getAllCoef()
{

QMap<QString, double> m_coefs {
{STR_m2xfm_x, 0.0 },
{STR_m2xfm_y, 0.0 }
};
return m_coefs;
return _coefs;

}

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

bool LinearCoordTransformer::Init(QMap<QString, double> globalVars)
{


if(globalVars.count(STR_m2xfm_x) > 0)
{
m_2xfm_x = globalVars[STR_m2xfm_x];
}
if(globalVars.count(STR_m2xfm_y) > 0)
{
m_2xfm_y = globalVars[STR_m2xfm_y];
}

return true;

Expand All @@ -58,14 +50,9 @@ bool LinearCoordTransformer::Init(QMap<QString, double> globalVars)
bool LinearCoordTransformer::getVariable(QString name, double *val)
{

if(name == STR_m2xfm_x)
{
*val = m_2xfm_x;
return true;
}
else if(name == STR_m2xfm_y)
if(_coefs.count(name) > 0)
{
*val = m_2xfm_y;
*val = _coefs.value(name);
return true;
}

Expand All @@ -78,14 +65,9 @@ bool LinearCoordTransformer::getVariable(QString name, double *val)
bool LinearCoordTransformer::setVariable(QString name, double val)
{

if(name == STR_m2xfm_x)
{
m_2xfm_x= val;
return true;
}
else if(name == STR_m2xfm_y)
if(_coefs.count(name) > 0)
{
m_2xfm_y = val;
_coefs[name] = val;
return true;
}

Expand All @@ -102,27 +84,14 @@ void LinearCoordTransformer::transformCommand(double inX,
double *outY,
double *outZ)
{
/*
*outX = -(
( inX - m_offset_c ) *
sin( (m_angle_alpha + m_omega_prime) / 180.0 * M_PI)
/ sin( (m_omega_prime) / 180.0 * M_PI ) - (inY - m_offset_d)
* sin( ( m_omega - m_omega_prime - m_angle_alpha ) / 180.0 * M_PI )
/ sin( m_omega_prime / 180.0 * M_PI )
) * m_scaling_XFM_X + m_offset_a
+ (inZ - m_z_offset) * m_z_lin_x - m_2xfm_x;
*outY = -(
-(inX - m_offset_c) * sin( m_angle_alpha / 180.0 * M_PI)
/ sin( m_omega_prime / 180.0 * M_PI) + (inY - m_offset_d)
* sin( ( m_omega_prime + m_angle_alpha ) / 180.0 * M_PI)
/ sin( m_omega_prime / 180.0 * M_PI)
) * m_scaling_XFM_Y + m_offset_b
+ (inZ - m_z_offset) * m_z_lin_y - m_2xfm_y;

double xPred = inX * _coefs.value(QSTR_SlopeX) + _coefs.value(QSTR_InterceptX);
double yPred = inY * _coefs.value(QSTR_SlopeY) + _coefs.value(QSTR_InterceptY);
*outX = xPred + (yPred * _coefs.value(QSTR_SlopeYX) + _coefs.value(QSTR_InterceptYX));
*outY = yPred + (xPred * _coefs.value(QSTR_SlopeXY) + _coefs.value(QSTR_InterceptXY));

*outZ = 0.0;
*/

}

//---------------------------------------------------------------------------
Expand Down
22 changes: 12 additions & 10 deletions src/solver/LinearCoordTransformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,18 @@
#include "preferences/Attribute.h"
#include <unordered_map>

//---------------------------------------------------------------------------
const QString QSTR_SlopeX = "SlopeX";
const QString QSTR_SlopeY = "SlopeY";
const QString QSTR_InterceptX = "InterceptX";
const QString QSTR_InterceptY = "InterceptY";
const QString QSTR_SlopeXY = "SlopeXY";
const QString QSTR_InterceptXY = "InterceptXY";
const QString QSTR_SlopeYX = "SlopeYX";
const QString QSTR_InterceptYX = "InterceptYX";



//---------------------------------------------------------------------------
/**
* @brief
*
Expand Down Expand Up @@ -81,15 +91,7 @@ class LinearCoordTransformer : public gstar::ITransformer

protected:

/**
* @brief m_2xfm_x
*/
double m_2xfm_x;

/**
* @brief m_2xfm_y
*/
double m_2xfm_y;
QMap<QString, double> _coefs;

};

Expand Down

0 comments on commit b997c97

Please sign in to comment.