101 lines
2.1 KiB
C++
101 lines
2.1 KiB
C++
|
#include "QtGDALProcessBar.h"
|
|||
|
#include <QCoreApplication>
|
|||
|
|
|||
|
|
|||
|
QtGDALProcessBar::QtGDALProcessBar(QWidget *parent)
|
|||
|
: QProgressBar(parent)
|
|||
|
{
|
|||
|
//ui.setupUi(this);
|
|||
|
this->setTextVisible(true);
|
|||
|
m_dPosition = 0.0;
|
|||
|
m_iStepCount = 100;
|
|||
|
m_iCurStep = 0;
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
QtGDALProcessBar::~QtGDALProcessBar()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
* @param pszMsg <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
*/
|
|||
|
void QtGDALProcessBar::SetMessage(const char* pszMsg)
|
|||
|
{
|
|||
|
if (pszMsg != NULL)
|
|||
|
{
|
|||
|
m_strMessage = pszMsg;
|
|||
|
//setLabelText(QString(pszMsg));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
* @param dPosition <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
*/
|
|||
|
bool QtGDALProcessBar::SetPosition(double dPosition)
|
|||
|
{
|
|||
|
m_dPosition = dPosition;
|
|||
|
//cout << "m_dPosition " << m_dPosition << endl;
|
|||
|
//current_value = value();
|
|||
|
int temp_value = int(m_start_value +std::min(100u, (uint)(m_dPosition * 100.0 )) * m_scale);
|
|||
|
|
|||
|
setValue(temp_value);
|
|||
|
//setFormat(tr("%1%").arg(temp_value));
|
|||
|
//cout << "StepIt " << temp_value << "\t" << "current_value" << int(m_start_value + temp_value * m_scale) << endl;
|
|||
|
//QCoreApplication::instance()->processEvents();
|
|||
|
//this->update();
|
|||
|
//if (this->wasCanceled())
|
|||
|
// return false;
|
|||
|
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
bool QtGDALProcessBar::SetStartEndValue(int i_start_value, int i_end_value)
|
|||
|
{
|
|||
|
if (i_end_value< i_start_value )
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
m_start_value = i_start_value;
|
|||
|
m_end_value = i_end_value;
|
|||
|
m_scale = (m_end_value - m_start_value) / 100.0;
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>false<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
bool QtGDALProcessBar::StepIt()
|
|||
|
{
|
|||
|
m_iCurStep++;
|
|||
|
m_dPosition = m_iCurStep * 1.0 / m_iStepCount;
|
|||
|
//current_value = value();
|
|||
|
int temp_value = std::min(100u, (uint)(m_dPosition * 100.0));
|
|||
|
setValue(int(m_start_value + temp_value * m_scale));
|
|||
|
//setFormat(QString("<22><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>%1%").arg(temp_value));
|
|||
|
//cout << "StepIt " << temp_value <<"\t"<<"current_value"<< current_value << endl;
|
|||
|
|
|||
|
//QCoreApplication::instance()->processEvents();
|
|||
|
|
|||
|
//if (this->wasCanceled())
|
|||
|
// return false;
|
|||
|
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
void QtGDALProcessBar::updateProgress(int step)
|
|||
|
{
|
|||
|
this->setValue(step);
|
|||
|
//this->update();
|
|||
|
//cout << "updateProgress " << step << endl;
|
|||
|
//QCoreApplication::instance()->processEvents();
|
|||
|
}
|
|||
|
|
|||
|
|