/**
*  @brief
*    Constructor
*/
DockWidgetRTTIBrowser::DockWidgetRTTIBrowser(QMainWindow *pQMainWindow, DockWidgetManager *pDockWidgetManager) : DockWidget(reinterpret_cast<QWidget*>(pQMainWindow), pDockWidgetManager)
{
	// Get encapsulated Qt dock widget
	QDockWidget *pQDockWidget = GetQDockWidget();
	if (pQDockWidget) {
		// Create RTTI browser widget
		pQDockWidget->setWidget(new RTTIBrowserWidget());

		// Set window title
		pQDockWidget->setWindowTitle(pQDockWidget->tr(GetClass()->GetProperties().Get("Title")));

		// Add the created Qt dock widget to the given Qt main window and tabify it for better usability
		AddDockWidgetAndTabify(*pQMainWindow, Qt::BottomDockWidgetArea, *pQDockWidget);
	}
}
/**
*  @brief
*    Constructor
*/
DockWidgetVolumeTransferFunction::DockWidgetVolumeTransferFunction(QMainWindow *pQMainWindow, DockWidgetManager *pDockWidgetManager) : DockWidgetVolume(reinterpret_cast<QWidget*>(pQMainWindow), pDockWidgetManager),
	m_pDockWidgetVolumeTransferFunctionQObject(new DockWidgetVolumeTransferFunctionQObject(*this)),
	m_pTransferFunctionWidget(nullptr),
	m_pTransferFunctionResultWidget(nullptr)
{
	// Get encapsulated Qt dock widget
	QDockWidget *pQDockWidget = GetQDockWidget();
	if (pQDockWidget) {
		// Set window title
		pQDockWidget->setWindowTitle(pQDockWidget->tr(GetClass()->GetProperties().Get("Title")));

		// Add the created Qt dock widget to the given Qt main window and tabify it for better usability
		AddDockWidgetAndTabify(*pQMainWindow, Qt::LeftDockWidgetArea, *pQDockWidget);

		// The Qt object should receive events from the encapsulated Qt dock widget
		pQDockWidget->installEventFilter(m_pDockWidgetVolumeTransferFunctionQObject);

		// Update the volume information
		UpdateObject(GetSelectedObject());
	}
}
/**
*  @brief
*    Updates the transfer function
*/
void DockWidgetVolumeTransferFunction::UpdateObject(PLCore::Object *pObject)
{
	// Destroy previous transfer function Qt widget
	if (m_pTransferFunctionWidget) {
		delete m_pTransferFunctionWidget;
		m_pTransferFunctionWidget = nullptr;
	}
	if (m_pTransferFunctionResultWidget) {
		delete m_pTransferFunctionResultWidget;
		m_pTransferFunctionResultWidget = nullptr;
	}

	// Is there an selected object?
	if (pObject) {
		// Get encapsulated Qt dock widget
		QDockWidget *pQDockWidget = GetQDockWidget();
		if (pQDockWidget) {
			// Get the used volume resource
			PLVolume::Volume *pVolume = static_cast<PLVolume::SNVolume&>(*pObject).GetVolume();	// If we're in here, we know the cast is valid
			if (pVolume) {
				// Transfer function result widget
				m_pTransferFunctionResultWidget = new QLabel();
				m_pTransferFunctionResultWidget->setAlignment(Qt::AlignTop | Qt::AlignLeft);
				m_pTransferFunctionResultWidget->setToolTip(pQDockWidget->tr("Resulting 1D transfer function"));

				// Create transfer function Qt widget
				m_pTransferFunctionWidget = new TransferFunctionWidget(*this, *pVolume);
				QLayout *pQLayout = new QVBoxLayout();
				pQLayout->setSpacing(0);
				pQLayout->setMargin(0);
				pQLayout->setContentsMargins(0, 0, 0, 0);
				pQLayout->addWidget(m_pTransferFunctionWidget);
				pQLayout->addWidget(m_pTransferFunctionResultWidget);
				QWidget *pQWidget = new QWidget();
				pQWidget->setLayout(pQLayout);
				pQDockWidget->setWidget(pQWidget);
			}
		}
	}
}
示例#4
0
/**
*  @brief
*    Selects the given object
*/
void DockWidgetObject::SelectObject(Object *pObject)
{
	// State change?
	if (m_pObject != pObject) {
		// Disconnect event handler
		if (m_pObject)
			m_pObject->SignalDestroyed.Disconnect(SlotOnDestroyed);

		// Backup the given object pointer
		m_pObject = pObject;

		// Connect event handler
		if (m_pObject)
			m_pObject->SignalDestroyed.Connect(SlotOnDestroyed);

		// Is there a PL introspection model instance?
		if (m_pPLIntrospectionModel) {
			// Set object
			m_pPLIntrospectionModel->SetObject(m_pObject);

			{ // Usability: Resize the first tree view column given to the size of its contents
				// No need to backup current expanded state and restore it after we're done because we set new content above resulting in that all is collapsed when we're in here
				m_pQTreeView->expandAll();
				m_pQTreeView->resizeColumnToContents(0);
				m_pQTreeView->collapseAll();
			}

			// Get encapsulated Qt dock widget and set a decent window title
			QDockWidget *pQDockWidget = GetQDockWidget();
			if (pQDockWidget) {
				// Set window title
				QString sQStringWindowTitle = pQDockWidget->tr(GetClass()->GetProperties().Get("Title"));
				if (m_pObject) { 
					// Append class name
					sQStringWindowTitle += ": ";
					sQStringWindowTitle += QtStringAdapter::PLToQt('\"' + m_pObject->GetClass()->GetClassName() + '\"');	// Put it into quotes to make it possible to see e.g. trailing spaces

					// An "PLCore::Object" itself has no "name", we could show the memory address but this wouldn't be that useful to the user
					// -> Try "GetAbsoluteName()"-method to get an absolute name
					// -> In case there's no name, check whether there's an name attribute
					// -> In case there's still no name, check whether or not there's an filename attribute
					String sName;
					{ // Try "GetAbsoluteName()"-method to get an absolute name
						// Get the typed dynamic parameters
						Params<String> cParams;

						// Call the RTTI method
						m_pObject->CallMethod("GetAbsoluteName", cParams);

						// Get the result
						sName = cParams.Return;
						if (sName.GetLength())
							sName = "Name = \"" + sName + '\"';	// Put it into quotes to make it possible to see e.g. trailing spaces
					}

					// Do we already have a name?
					if (!sName.GetLength()) {
						// Check whether there's an name attribute
						DynVar *pDynVar = m_pObject->GetAttribute("Name");
						if (pDynVar)
							sName = "Name = \"" + pDynVar->GetString() + '\"';	// Put it into quotes to make it possible to see e.g. trailing spaces

						// In case there's still no name, check whether or not there's an filename attribute
						if (!sName.GetLength()) {
							DynVar *pDynVar = m_pObject->GetAttribute("Filename");
							if (pDynVar)
								sName = "Filename = \"" + pDynVar->GetString() + '\"';	// Put it into quotes to make it possible to see e.g. trailing spaces
						}
					}

					// Use the name, if we have one
					if (sName.GetLength()) {
						// We have a representable name, show it to the user
						sQStringWindowTitle += ": ";
						sQStringWindowTitle += QtStringAdapter::PLToQt(sName);
					}
				}
				pQDockWidget->setWindowTitle(sQStringWindowTitle);
			}
		}
	}
}