#include "FITKGraph3DWindowInterface.h" #include "FITKGraph3DWindowVTK.h" #include "FITKGraphInteractionStyle.h" #include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h" #include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h" #include "FITK_Kernel/FITKAppFramework/FITKRunTimeSetting.h" namespace Comp { FITKGraph3DWindowInterface::~FITKGraph3DWindowInterface() { //释放初始化器 QList inis = _initilizerList.values(); for (auto iner : inis) { delete iner; } _initilizerList.clear(); } QWidget* FITKGraph3DWindowInterface::getWidget(const int indexPort) { //获取初始化器 auto initer = _initilizerList.value(indexPort); if (initer == nullptr) initer = new Graph3DWindowInitializer; //创建三维渲染窗口 auto w = new FITKGraph3DWindowVTK(initer); //获取 AppFrame::FITKRunTimeSetting* runTimeSetting = FITKAPP->getGlobalData()->getRunTimeSetting(); QVariant vtc = runTimeSetting->getValue(BackGroundColorTop); QVariant vbc = runTimeSetting->getValue(BackGroundColorButtom); //程序运行参数获取不到,则获取默认颜色 if ((!vbc.isValid()) && (!vtc.isValid())) { //设置背景色 vtc = initer->getValue(BackGroundColorTop); vbc = initer->getValue(BackGroundColorButtom); } //无效值不操作 if (vbc.isValid() && vtc.isValid()) { //top QColor c = vtc.value(); float t[3] = { c.redF(),c.greenF(),c.blueF() }; //buttom c = vbc.value(); float b[3] = { c.redF(),c.greenF(),c.blueF() }; if (w) w->setBackgroundColor(t, b); } return w; } QString FITKGraph3DWindowInterface::getComponentName() { //返回三维渲染组件在组件管理类中的标识 return "Graph3DWindowVTK"; } void FITKGraph3DWindowInterface::addInitializer(int key, Graph3DWindowInitializer* info) { //添加初始化器 if(_initilizerList.contains(key)) { auto iner = _initilizerList.value(key); //释放旧的初始化器 if (iner) delete iner; } _initilizerList[key] = info; } FITKGraphInteractionStyle* Graph3DWindowInitializer::getStyle() { //创建默认交互样式 return FITKGraphInteractionStyle::New(); } void Graph3DWindowInitializer::setLayerCount(const int nc) { _layerCount = nc; } int Graph3DWindowInitializer::getLayerCount() const { return _layerCount; } }