123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- #include "blobshapetrans.h"
- #include "ui_blobshapetrans.h"
- #include "../ToolDialog.h"
- class ToolDialogImpl;
- BolbShapeTrans::BolbShapeTrans(QWidget *parent , ToolDialogImpl* p) : ToolInterface(parent), ui(new Ui::BolbShapeTrans)
- {
- ui->setupUi(this);
- m_pToolDialogImpl = p;
- ui->comboBox_index->setView(new QListView());
- ui->comboBox->setView(new QListView());
- if(m_pToolDialogImpl->m_LinkProcess.size() > 0)
- {
- ui->comboBox_index->setVisible(true);
- ui->label_index->setVisible(true);
- }
- else
- {
- ui->comboBox_index->setVisible(false);
- ui->label_index->setVisible(false);
- }
- for(int i = 0; i < m_pToolDialogImpl->m_LinkProcess.size(); i++)
- {
- ui->comboBox_index->addItem(QString::number(i));
- }
- }
- BolbShapeTrans::~BolbShapeTrans()
- {
- delete ui;
- }
- bool BolbShapeTrans::Serialized(QDataStream& ar, bool bIsOut)
- {
- int paranum;//参数数量
- if (bIsOut)//保存参数流程
- {
- paranum = 2;
- ar << paranum;//先保存参数数量
- ar << (int)1 << ui->comboBox_index->currentIndex();
- ar << (int)2 << ui->comboBox->currentIndex();
- }
- else//加载参数流程,参数加载顺序一定要跟保存顺序一致
- {
- int nCurrentIndex1 = 0;
- int nCurrentIndex2 = 0;
- int para;
- ar >> paranum;//读取参数数量
- for (int i = 0; i < paranum; i++)
- {
- ar >> para;
- switch (para)
- {
- case 1: ar >> nCurrentIndex1; break;
- case 2: ar >> nCurrentIndex2; break;
- default:
- {
- qWarning() << "Serialized(In) Error";
- return false;
- }
- break;
- }
- }
- {
- ui->comboBox_index->setCurrentIndex(nCurrentIndex1);
- ui->comboBox->setCurrentIndex(nCurrentIndex2);
- emit updateParameter(ShowParameter());
- }
- }
- return true;
- }
- QString BolbShapeTrans::ShowParameter()
- {
- QString str;
- str = ui->comboBox->currentText();
- return str;
- }
- int BolbShapeTrans::Execute()
- {
- int result = 1;
- int m_nType = ui->comboBox->currentIndex();
- try
- {
- if(ui->comboBox_index->currentIndex() == 0)
- {
- if(m_nType == 0)
- {
- ShapeTrans (m_InImage, &m_OutImage, "convex");
- }
- if(m_nType == 1)
- {
- ShapeTrans (m_InImage, &m_OutImage, "ellipse");
- }
- if(m_nType == 2)
- {
- ShapeTrans (m_InImage, &m_OutImage, "outer_circle");
- }
- if(m_nType == 3)
- {
- ShapeTrans (m_InImage, &m_OutImage, "inner_circle");
- }
- if(m_nType == 4)
- {
- ShapeTrans (m_InImage, &m_OutImage, "rectangle1");
- }
- if(m_nType == 5)
- {
- ShapeTrans (m_InImage, &m_OutImage, "rectangle2");
- }
- if(m_nType == 6)
- {
- ShapeTrans (m_InImage, &m_OutImage, "inner_rectangle1");
- }
- }
- else
- {
- int index = ui->comboBox_index->currentIndex() - 1;
- HObject inputimage = m_pToolDialogImpl->m_LinkProcess[index].p_dlg->GetResult();
- if(m_nType == 0)
- {
- ShapeTrans (inputimage, &m_OutImage, "convex");
- }
- if(m_nType == 1)
- {
- ShapeTrans (inputimage, &m_OutImage, "ellipse");
- }
- if(m_nType == 2)
- {
- ShapeTrans (inputimage, &m_OutImage, "outer_circle");
- }
- if(m_nType == 3)
- {
- ShapeTrans (inputimage, &m_OutImage, "inner_circle");
- }
- if(m_nType == 4)
- {
- ShapeTrans (inputimage, &m_OutImage, "rectangle1");
- }
- if(m_nType == 5)
- {
- ShapeTrans (inputimage, &m_OutImage, "rectangle2");
- }
- if(m_nType == 6)
- {
- ShapeTrans (inputimage, &m_OutImage, "inner_rectangle1");
- }
- }
- }
- catch(...)
- {
- }
- return result;
- }
- void BolbShapeTrans::on_comboBox_currentIndexChanged(int index)
- {
- emit updateParameter(ShowParameter());
- }
- void BolbShapeTrans::on_comboBox_index_currentIndexChanged(int index)
- {
- if(index > 0)
- {
- emit updateParameterIndex(QString::number(index - 1));
- }
- emit updateParameter(ShowParameter());
- }
|