logplus/OSGDataModel/src/WellLogWorkflowDataModel.cpp
2026-01-16 17:18:41 +08:00

243 lines
7.0 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.

#pragma warning( push ,0)
#include <cassert>
#include <algorithm>
#include <QDesktopServices>
#include <QDir>
#include <QTextStream>
// #include "ObjectEvent.h"
#include "WellLogWorkflowDataModel.h"
#include "ObjectID.h"
// #include "ObjProject.h"
#include "geometryutils.h"
#pragma warning( pop )
BEGIN_OSGDATAMODEL_NAMESPACE;
CWellLogWorkflowDataModel::CWellLogWorkflowDataModel(QUuid id)
{
// SetName("wellsectionwindow");
// SetIconName("workflow.png");
// isSingleModuleMode=false;
// isDefineMothodMode=false;
// m_pModule=NULL;
// m_SingleWellWindowDocument=NULL;
// m_MultiWellWindowDocument=CBaseObject::GetFatory().CreateObject(id);
// if(!m_MultiWellWindowDocument) return;
// m_MultiWellWindowDocument->GetPaiObject()->SetName( GetName() );
// dynamic_cast<CBaseObjectImpl*>(m_MultiWellWindowDocument)->Init(id);
// CObjProject::AddIDMap( m_MultiWellWindowDocument->GetPaiObject()->GetID(),m_MultiWellWindowDocument );
// isLoaded=false;
}
pai::ios::welllog::DataObject *CWellLogWorkflowDataModel::GetDbObject()
{
return NULL;
}
CWellLogWorkflowDataModel::~CWellLogWorkflowDataModel()
{
QList <PaiObject *>childs;
this->GetChildren(childs);
if (m_SingleWellWindowDocument)
{
if(!this->RemoveChild(m_SingleWellWindowDocument->GetPaiObject())) return;
delete m_SingleWellWindowDocument;
m_SingleWellWindowDocument = NULL;
}
if (m_MultiWellWindowDocument)
{
if(!this->RemoveChild(m_MultiWellWindowDocument->GetPaiObject())) return;
delete m_MultiWellWindowDocument;
m_MultiWellWindowDocument = NULL;
}
DeleteAllChild();
}
QUuid CWellLogWorkflowDataModel::GetTypeID()const
{
return GetClassID_WorkflowDataModel();
}
void CWellLogWorkflowDataModel::Delete()
{
DeleteAllChild();
delete this;
}
void CWellLogWorkflowDataModel::ReloadDataModuel()
{
}
// bool CWellLogWorkflowDataModel::Serialize( CObjectArchive &ar )
// {
// if(ar.IsStoring())
// {
// BEGIN_WRITE_OBJECT( ar,1 );
// BEGIN_WRITE_BLOCK( ar, 1);
// /*保存自己的信息*/
// std::string strHomeLocation = QDesktopServices::storageLocation(QDesktopServices::HomeLocation).toStdString();
// std::string strSeparator = QString(QDir::separator()).toStdString();
// std::string strName = GetName().toStdString();
// std::string strID = GetID().toString().toStdString();
// std::string strFilepath = strHomeLocation + strSeparator;
// std::string strJsonFileName = strName + strID + ".json";
// std::string strJsonStyleFileName = strName +strID + "_style.json";
// this->Save(strFilepath + strName + strID );
// QFile fJson(QString::fromStdString(strFilepath +strJsonFileName));
// QFile fJsonStyle(QString::fromStdString(strFilepath + strJsonStyleFileName));
// if (fJson.open(QFile::ReadOnly | QFile::Truncate))
// {
// QTextStream inJsonStream(&fJson);
// ar<<inJsonStream.readAll();
// }
// fJson.close();
// if (fJsonStyle.open(QFile::ReadOnly | QFile::Truncate))
// {
// QTextStream inJsonStyleStream(&fJsonStyle);
// ar<<inJsonStyleStream.readAll();
// }
// fJsonStyle.close();
// ar << QString::fromStdString(strName);
// ar << QString::fromStdString(strID);
// ar <<isSingleModuleMode;
// ar <<isDefineMothodMode;
// ar <<CurrentWellRoundPath;
// fJson.remove();
// fJsonStyle.remove();
// //保存工作流里面的单井窗口
// if(m_SingleWellWindowDocument)m_SingleWellWindowDocument->Serialize(ar);
// m_MultiWellWindowDocument->Serialize(ar);
// END_WRITE_BLOCK( ar, 1 );
// END_WRITE_OBJECT( ar );
// }
// else
// {
// BEGIN_READ_OBJECT( ar,1 );
// BEGIN_READ_BLOCK( 1 );
// /*加载自己的信息*/
// QString strTmpJson;
// ar >> strTmpJson;
// QString strTempJsonSytyle;
// ar>>strTempJsonSytyle;
// QString strName;
// ar>>strName;
// QString strID;
// ar>>strID;
// ar>>isSingleModuleMode;
// if(isSingleModuleMode)
// SetIconName("icon/ModuleOne.png");
// ar >>isDefineMothodMode;
// ar >>CurrentWellRoundPath;
// std::string json(strTmpJson.toStdString());
// std::string jsonstyle(strTempJsonSytyle.toStdString());
// std::string error;
// this->ParseJsonText(json,jsonstyle,error);
// this->SetID(strID);
// this->SetName(strName);
// if(m_SingleWellWindowDocument)m_SingleWellWindowDocument->Serialize(ar);
// m_MultiWellWindowDocument->Serialize(ar);
// END_READ_BLOCK( 1 );
// END_READ_OBJECT( ar );
// }
// return true;
// }
bool CWellLogWorkflowDataModel::AddChild(PaiObject* pChild, bool mountNow )
{
return true;
// CObjProject::AddIDMap( pChild->GetID(),dynamic_cast<CBaseObject *>( pChild) );
// if(mountNow)
// return PaiWorkflowDataModel::AddChild( pChild, MountOnTree);
// else
// return PaiWorkflowDataModel::AddChild( pChild, MountNoTree);
}
bool CWellLogWorkflowDataModel::InsertChild(int iIndex,PaiObject* pChild)
{
return true;
// CObjProject::AddIDMap( pChild->GetID(), dynamic_cast<CBaseObject *>( pChild));
// return PaiWorkflowDataModel::InsertChild( iIndex, pChild );
}
bool CWellLogWorkflowDataModel::RemoveChild(PaiObject* pChild, bool bDelete )
{
return true;
// if(pChild==(PaiObject*)0xfeeefeeefeeefeee) return false;
// CObjProject::RemoveIDMap( dynamic_cast<CBaseObject*>(pChild ) );
// return PaiWorkflowDataModel::RemoveChild( pChild,bDelete );
}
void CWellLogWorkflowDataModel::DeleteAllChild()
{
// QList<PaiObject*>::iterator it = m_children.begin();
// while ( it != m_children.end() )
// {
// PaiObject* pChild = (*it);
// // m_EventAgent.RemoveObjectChild(this, pChild );
// CObjProject::RemoveIDMap( dynamic_cast<CBaseObject*>( pChild ) );
// pChild->Delete();
// ++it;
// }
// m_children.clear();
}
bool CWellLogWorkflowDataModel::GetWorkflowTemplates(QList< CWellLogWorkflowDataModel* > & workflows)
{
// QString workflowtplPath=GetWorkflowTemplatePath();
// QDir dir(workflowtplPath);
// QFileInfoList list = dir.entryInfoList();
// for(int i=0;i<list.size();i++)
// {
// if(list.at(i).isDir()) continue;
// QString afilename=list.at(i).fileName();
// if(afilename.indexOf("_style.json")<0)
// {
// CWellLogWorkflowDataModel* amodel=new CWellLogWorkflowDataModel(GetWindowTypeID_QtMultiWellSection());
// amodel->SetName(list.at(i).completeBaseName());
// workflows.append(amodel);
// }
// }
return true;
}
void CWellLogWorkflowDataModel::LoadFromTemplateFile()
{
// if(!isLoaded){//此时名字已经加载了参考GetWorkflowTemplates实现
// QString workflowtplPath=GetWorkflowTemplatePath();
// std::string filename=workflowtplPath.toStdString()+GetName().toStdString()+".json";
// std::string stylefilename=workflowtplPath.toStdString()+GetName().toStdString()+"_style.json";
// std::string error;
// Parse(filename,stylefilename,error);
// isLoaded=true;
// }
}
BEGIN_REGISTER_OBJECT(CWellLogWorkflowDataModel)
QUuid(GetClassID_WorkflowDataModel())
END_REGISTER_OBJECT( CWellLogWorkflowDataModel );
END_OSGDATAMODEL_NAMESPACE