108 lines
3.3 KiB
C++
108 lines
3.3 KiB
C++
|
#include "RasterProcessTool.h"
|
|||
|
#include <QObject>
|
|||
|
#include "QMergeRasterProcessDialog.h"
|
|||
|
#include "QImportGF3StripL1ADataset.h"
|
|||
|
#include "QComplex2AmpPhase.h"
|
|||
|
#include "QRDOrthProcessClass.h"
|
|||
|
#include "QOrthSlrRaster.h"
|
|||
|
|
|||
|
|
|||
|
RasterProcessTool::RasterProcessTool(QWidget *parent)
|
|||
|
: QMainWindow(parent)
|
|||
|
{
|
|||
|
ui.setupUi(this);
|
|||
|
|
|||
|
QObject::connect(this, SIGNAL(addBoxToolItemSIGNAL(QToolAbstract*)), this, SLOT(addBoxToolItemSLOT(QToolAbstract*)));
|
|||
|
}
|
|||
|
|
|||
|
RasterProcessTool::~RasterProcessTool()
|
|||
|
{}
|
|||
|
|
|||
|
void RasterProcessTool::addBoxToolItemSLOT(QToolAbstract* item)
|
|||
|
{
|
|||
|
QVector<QString> xnodepath = item->getToolXpath();
|
|||
|
QString toolName = item->getToolName();
|
|||
|
|
|||
|
QTreeWidgetItem* parentItem = findOrCreateParentItem(xnodepath);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> toolButton
|
|||
|
if (parentItem && ui.treeWidgetToolBox->itemWidget(parentItem, 0) == nullptr) {
|
|||
|
QTreeWidgetItem* actionItem = new QTreeWidgetItem(parentItem);
|
|||
|
parentItem->addChild(actionItem);
|
|||
|
QIcon icon(QString::fromUtf8(":/RasterProcessTool/toolicon"));
|
|||
|
QPushButton* button = new QPushButton(ui.treeWidgetToolBox);
|
|||
|
button->setIcon(icon);
|
|||
|
button->setText(toolName);
|
|||
|
button->setLayoutDirection(Qt::LeftToRight);
|
|||
|
button->setStyleSheet("QPushButton { text-align: left; }");
|
|||
|
ui.treeWidgetToolBox->setItemWidget(actionItem, 0, button);
|
|||
|
connect(button, SIGNAL(clicked()), item, SLOT(excute()));
|
|||
|
item->setParent(ui.treeWidgetToolBox);
|
|||
|
qDebug() << "ToolButton bound to parent:" << actionItem->text(0);
|
|||
|
}
|
|||
|
else {
|
|||
|
qDebug() << "ToolButton already bound to parent:" << parentItem->text(0);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD>һ<D2BB><F2B4B4BD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
QTreeWidgetItem* RasterProcessTool::findOrCreateParentItem( QVector<QString>& path) {
|
|||
|
QTreeWidgetItem* currentItem = nullptr;
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6>㿪ʼ<E3BFAA><CABC><EFBFBD><EFBFBD>
|
|||
|
for ( QString& nodeName : path) {
|
|||
|
if (currentItem == nullptr) {
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD><C7B6><EFBFBD><EFBFBD>ڵ<EFBFBD>
|
|||
|
currentItem = findOrCreateTopLevelItem(nodeName);
|
|||
|
}
|
|||
|
else {
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽڵ㣬<DAB5><E3A3AC><EFBFBD>ҵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڸ<EFBFBD><DAB8>ӽڵ<D3BD>
|
|||
|
currentItem = findChildItemByName(currentItem, nodeName);
|
|||
|
if (currentItem == nullptr) {
|
|||
|
currentItem = new QTreeWidgetItem(currentItem);
|
|||
|
currentItem->setText(0, nodeName);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return currentItem;
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD>Ҷ<EFBFBD><D2B6><EFBFBD><EFBFBD>ڵ㣬<DAB5><E3A3AC><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>
|
|||
|
QTreeWidgetItem* RasterProcessTool::findOrCreateTopLevelItem( QString& name) {
|
|||
|
for (int i = 0; i < ui.treeWidgetToolBox->topLevelItemCount(); ++i) {
|
|||
|
QTreeWidgetItem* item = ui.treeWidgetToolBox->topLevelItem(i);
|
|||
|
if (item->text(0) == name) {
|
|||
|
return item;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µĶ<C2B5><C4B6><EFBFBD><EFBFBD>ڵ<EFBFBD>
|
|||
|
QTreeWidgetItem* newItem = new QTreeWidgetItem(ui.treeWidgetToolBox);
|
|||
|
QIcon icon(QString::fromUtf8(":/RasterProcessTool/toolboxIcon"));
|
|||
|
newItem->setIcon(0,icon);
|
|||
|
newItem->setTextAlignment(0, Qt::AlignLeft);
|
|||
|
newItem->setText(0, name);
|
|||
|
return newItem;
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ӽڵ㣬<DAB5><E3A3AC><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD> nullptr
|
|||
|
QTreeWidgetItem* RasterProcessTool::findChildItemByName(QTreeWidgetItem* parentItem, QString& name) {
|
|||
|
for (int i = 0; i < parentItem->childCount(); ++i) {
|
|||
|
QTreeWidgetItem* childItem = parentItem->child(i);
|
|||
|
if (childItem->text(0) == name) {
|
|||
|
return childItem;
|
|||
|
}
|
|||
|
}
|
|||
|
return nullptr;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|