You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
5.5 KiB
C++

#include "FITKAbstractGraphObject.h"
#include "FITKAbstractGraphWidget.h"
namespace Core
{
/**
* @brief
* @param data
*/
FITKAbstractGraphObject::FITKAbstractGraphObject(FITKAbstractDataObject* data)
:_dataObj(data)
{
}
/**
* @brief
*/
FITKAbstractGraphObject::~FITKAbstractGraphObject()
{
emit this->graphObjDestroyedSig(this); // 发出图形对象销毁的信号
}
/**
* @brief
* @param dataobj
*/
void FITKAbstractGraphObject::setDataObject(FITKAbstractDataObject* dataobj)
{
_dataObj = dataobj;
}
/**
* @brief
* @param gwidget
*/
void FITKAbstractGraphObject::setGraphWidget(FITKAbstractGraphWidget* gwidget)
{
_graphWidget = gwidget;
}
/**
* @brief
* @return
*/
Core::FITKAbstractGraphWidget* FITKAbstractGraphObject::getGraphWidget()
{
return _graphWidget;
}
/**
* @brief
* @return
*/
Core::FITKAbstractDataObject* FITKAbstractGraphObject::getDataOject()
{
return _dataObj;
}
/**
* @brief
*
*/
void FITKAbstractGraphObject::removeFromGraphWidget()
{
if (_graphWidget == nullptr) return;
_graphWidget->removeGraphObj(this);
_graphWidget = nullptr;
}
void FITKAbstractGraphObject::update(bool mandatory /*= false*/)
{
}
/**
* @brief
*/
FITKGraphObjManager::~FITKGraphObjManager()
{
this->clear(); // 清除管理的所有图形对象
}
/**
* @brief
*/
void FITKGraphObjManager::clear()
{
_graphObjList.clear(); // 清除图形对象列表
}
/**
* @brief
* @param gobj
*
*
* 便
*/
void FITKGraphObjManager::appendGraphObj(FITKAbstractGraphObject* gobj)
{
if (gobj == nullptr) return;
_graphObjList.append(gobj);
connect(gobj, SIGNAL(graphObjDestroyedSig(FITKAbstractGraphObject*)),
this, SLOT(removeGraphObjSlot(FITKAbstractGraphObject*)));
}
/**
* @brief
* @param obj
*
*
*/
void FITKGraphObjManager::removeGraphObj(FITKAbstractGraphObject* obj)
{
if (!_graphObjList.contains(obj)) return;
_graphObjList.removeOne(obj);
disconnect(obj, SIGNAL(graphObjDestroyedSig(FITKAbstractGraphObject*)),
this, SLOT(removeGraphObjSlot(FITKAbstractGraphObject*)));
}
/**
* @brief
* @param index
*
*/
void FITKGraphObjManager::removeGraphObj(const int index)
{
if (index < 0 || index >= _graphObjList.size())
{
this->removeGraphObj(_graphObjList.at(index));
}
}
/**
* @brief
* @param gobj
* @return true false
*/
bool FITKGraphObjManager::isContains(FITKAbstractGraphObject* gobj)
{
return _graphObjList.contains(gobj);
}
/**
* @brief
* @return
*/
int FITKGraphObjManager::getGraphObjCount()
{
return _graphObjList.size();
}
/**
* @brief
* @param index
* @return nullptr
*/
FITKAbstractGraphObject* FITKGraphObjManager::getGraphObjAt(const int index)
{
if (index < 0 || index >= _graphObjList.size())
return nullptr;
return _graphObjList.at(index);
}
/**
* @brief
* @param obj
*/
void FITKGraphObjManager::removeGraphObjSlot(FITKAbstractGraphObject* obj)
{
this->removeGraphObj(obj);
}
}