logplus/Workflow/WFEngine/Component/WorkflowWidget/src/WorkflowWidget.cpp
2026-01-16 17:18:41 +08:00

268 lines
7.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @file WorkflowWidget.cpp
*/
#include "WorkflowWidget.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGroupBox>
#include <QLabel>
#include <QPixmap>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QMouseEvent>
#include <QMenu>
// #include "ObjectModelService.h"
// #include "IProject.h"
// #include "PluginManager.h"
// #include "PaiWorkflowDataModel.h"
// #include "GeneralWorkflowScene.h"
#include "WorkflowGraphicsView.h"
#include "WorkflowConst.h"
// #include "SaveHelper.h"
// using namespace pai::gui;
using namespace pai::objectmodel;
using namespace pai::graphics2d;
WorkflowWidget::WorkflowWidget(pai::objectmodel::PaiWorkflowDataModel *pWorkflow, QWidget *pParent, bool jobRelated) :
QWidget(pParent)
{
m_JobRelated = jobRelated;
m_ID = QUuid::createUuid();
m_pWorkflow = pWorkflow;
QVBoxLayout * v_lyt = new QVBoxLayout();
v_lyt->setContentsMargins(0, 0, 0, 0);
v_lyt->setSpacing(0);
m_pSceneManager = NULL;
// m_pGraphicsView = new pai::graphics2d::WorkflowGraphicsView(NULL, this);
// v_lyt->addWidget(m_pGraphicsView);
this->setLayout(v_lyt);
m_pSelectedExtension.clear();
}
WorkflowWidget::~WorkflowWidget()
{
// if (m_pWorkflow != NULL)
// {
// GetObjectModelService()->GetObjectLockManager()->UnlockObject(m_pWorkflow->GetDBID(), m_LockID);
// }
//defect 32589 先释放场景才能释放m_pWorkflow不然可能导致崩溃
if(m_pSceneManager)
{
delete m_pSceneManager;
m_pSceneManager = NULL;
}
// //对于可编辑工作流,需要自己维护
// if(!m_JobRelated && m_pWorkflow &&!(m_pWorkflow->IsTemplate()))
// {
// delete m_pWorkflow;
// m_pWorkflow = NULL;
// }
}
QUuid WorkflowWidget::GetID() const
{
return m_ID;
}
void WorkflowWidget::EnableMultiSelect(bool enable)
{
// if(m_pSceneManager)
// {
// m_pSceneManager->EnableMultiSelect(m_pGraphicsView,enable);
// }
}
// void WorkflowWidget::SetWorkflow(pai::objectmodel::PaiWorkflowDataModel *wf, bool bNeedReload, bool bJobRelated)
// {
// //清空场景
// if(m_pSceneManager)
// {
// m_pSceneManager->Clear();
// }
// //更新工作流模型
// if (wf != NULL && bNeedReload == true)
// {
// wf->ReloadDataModuel();
// }
// if (m_pWorkflow != NULL && !m_LockID.isNull())
// {
// GetObjectModelService()->GetObjectLockManager()->UnlockObject(m_pWorkflow->GetDBID(), m_LockID);
// }
// if(!bJobRelated)
// {
// //如果当前的工作流为空defect 32742
// if(!m_pWorkflow)
// {
// //传过来的wf不是数据树上的
// if(wf && !wf->GetParent())
// {
// m_pWorkflow = wf;
// }
// }
// else
// {
// if(wf)
// {
// //传过来的wf不是数据树上的
// if(!wf->GetParent())
// {
// if(wf != m_pWorkflow)
// {
// //当对象不是工作流模板时释放之前的m_pWorkflow,defact 37228
// if(!m_pWorkflow->IsTemplate())
// {
// delete m_pWorkflow;
// m_pWorkflow = NULL;
// }
// }
// //赋值新的workflow
// m_pWorkflow = wf;
// }
// else
// {
// m_pWorkflow->SetDBID(wf->GetDBID());
// m_pWorkflow->SetID(wf->GetID());
// m_pWorkflow->ReloadDataModuel();
// //可以发送事件
// m_pWorkflow->SetEventEnabled(true);
// m_pWorkflow->SetModify(false);
// }
// }
// else
// {
// //当对象不是工作流模板时释放之前的m_pWorkflow,defact 37228
// if(!m_pWorkflow->IsTemplate())
// {
// delete m_pWorkflow;
// m_pWorkflow = NULL;
// }
// }
// }
// }
// else
// {
// m_pWorkflow = wf;
// }
// if (m_pWorkflow != NULL)
// {
// if (!bJobRelated)
// {
// m_LockID = GetObjectModelService()->GetObjectLockManager()->LockObject(m_pWorkflow->GetDBID(),
// PaiObjectLock(m_pWorkflow->GetDBID(), PaiObjectLock::EDIT_LOCK, tr("Workflow is editting")));
// }
// //重置模块图元
// if(m_pSceneManager != NULL)
// {
// m_pSceneManager->AddWorkflow(m_pWorkflow, bJobRelated);
// }
// }
// if (bNeedReload == true)
// {
// if(m_pSceneManager != NULL)
// {
// m_pSceneManager->ExpandSceneRect();
// }
// }
// }
pai::graphics2d::GeneralWorkflowScene* WorkflowWidget::GetScene() const
{
return m_pSceneManager;
}
pai::objectmodel::PaiWorkflowDataModel* WorkflowWidget::GetWorkflow() const
{
return m_pWorkflow;
}
QGraphicsView * WorkflowWidget::GetGrapicsView() const
{
return m_pGraphicsView;
}
void WorkflowWidget::mouseReleaseEvent(QMouseEvent * e)
{
if (e->button() == Qt::RightButton)
{
QMenu menu;
menu.addAction("SeisView the input data", this, SLOT(slotSeisViewTheInputData()));
menu.exec(QCursor::pos());
}
}
void WorkflowWidget::SetJobPrgsInfo()
{
// if(m_pSceneManager != NULL)
// {
// m_pSceneManager->SetJobPrgsInfo();
// }
}
void WorkflowWidget::SetInteractive(bool bAllowed)
{
// pai::graphics2d::WorkflowGraphicsView * pWorkflwoGraphicsView = dynamic_cast<pai::graphics2d::WorkflowGraphicsView*>(m_pGraphicsView);
// if (pWorkflwoGraphicsView != NULL)
// pWorkflwoGraphicsView->SetScenceReadOnly(!bAllowed);
}
void WorkflowWidget::SetSelectedExtension(const QString &areaName, const QString extensionID)
{
m_pSelectedExtension.remove(areaName);
m_pSelectedExtension.insert(areaName, extensionID);
}
void WorkflowWidget::GetSelectedExtensions(QMap<QString, QString> &selectedMap)
{
selectedMap = m_pSelectedExtension;
}
void WorkflowWidget::ClearSelectedExtensions()
{
m_pSelectedExtension.clear();
}
void WorkflowWidget::UpdateWorkflowLock(long long dbid)
{
// if (m_pWorkflow != NULL && !m_LockID.isNull())
// {
// //if (GetObjectModelService()->GetObjectLockManager()->UnlockObject(dbid, m_LockID))
// //TODO aiya validate this
// GetObjectModelService()->GetObjectLockManager()->UnlockObject(dbid, m_LockID);
// {
// m_LockID = GetObjectModelService()->GetObjectLockManager()->LockObject(m_pWorkflow->GetDBID(),
// PaiObjectLock(m_pWorkflow->GetDBID(), PaiObjectLock::EDIT_LOCK, tr("Workflow is editting")));
// }
// }
}
void WorkflowWidget::SetScene(pai::graphics2d::GeneralWorkflowScene* pScene)
{
if(!pScene)
{
return;
}
//目前一个GraphicsView对应一个scene
//如果设置过就不再设置
// if(!m_pSceneManager)
// {
// m_pSceneManager = pScene;
// m_pGraphicsView->setScene(m_pSceneManager);
// //m_pSceneManager->SetSubToolBarName(m_ID + g_szStyleToolBarName);
// SetWorkflow(m_pWorkflow, false, m_JobRelated);
// m_pSceneManager->SetWorkflowWidget(this);
// }
}