QVariant LocalsTreeItem::data(int column, int role) const { switch (role) { case Qt::DisplayRole: switch (column) { case 0: return getDisplayName(); case 1: return getDisplayType(); case 2: return getDisplayValue(); default: break; } case Qt::ToolTipRole: switch (column) { case 0: return getDisplayName(); case 1: return getDisplayType(); case 2: return getDisplayValue(); default: break; } case Qt::BackgroundRole: return valueChanged() ? QColor(Qt::yellow) : QVariant(); default: break; } return QVariant(); }
/*! * \brief LocalsTreeItem::isCoreTypeExceptString * Returns true if is core type except STRING. * \return */ bool LocalsTreeItem::isCoreTypeExceptString() { if ((getDisplayType().compare(Helper::BOOLEAN) == 0) || (getDisplayType().compare(Helper::INTEGER) == 0) || (getDisplayType().compare(Helper::REAL) == 0)) { return true; } else { return false; } }
void LocalsTreeItem::setValue(QString value) { if (mpModelicaValue) { QString previousValue = mpModelicaValue->getValueString(); mpModelicaValue->setValue(value); setDisplayValue(mpModelicaValue->getValueString()); /* if value is changed then set the value changed flag. */ if (getDisplayValue().compare(previousValue) == 0) { setValueChanged(false); } else { setValueChanged(true); } } else if (isCoreType()) { mpModelicaValue = new ModelicaCoreValue(this); mpModelicaValue->setValue(value); setDisplayValue(mpModelicaValue->getValueString()); } else if (getDisplayType().startsWith(Helper::RECORD)) { mpModelicaValue = new ModelicaRecordValue(this); mpModelicaValue->setValue(value); setDisplayValue(mpModelicaValue->getValueString()); /* get the record elements size */ mpModelicaValue->retrieveChildrenSize(); } else if (getDisplayType().startsWith(Helper::LIST)) { mpModelicaValue = new ModelicaListValue(this); setDisplayValue(mpModelicaValue->getValueString()); /* get the list items size */ mpModelicaValue->retrieveChildrenSize(); } else if (getDisplayType().startsWith(Helper::OPTION)) { mpModelicaValue = new ModelicaOptionValue(this); setDisplayValue(mpModelicaValue->getValueString()); /* get the option item elements size */ mpModelicaValue->retrieveChildrenSize(); } else if (getDisplayType().startsWith(Helper::TUPLE)) { mpModelicaValue = new ModelicaTupleValue(this); setDisplayValue(mpModelicaValue->getValueString()); /* get the tuple elements size */ mpModelicaValue->retrieveChildrenSize(); } else if (getDisplayType().startsWith(Helper::ARRAY)) { mpModelicaValue = new MetaModelicaArrayValue(this); setDisplayValue(mpModelicaValue->getValueString()); /* get the tuple elements size */ mpModelicaValue->retrieveChildrenSize(); } /* invalidate the view so that the items show the updated values. */ mpLocalsTreeModel->getLocalsWidget()->getLocalsTreeProxyModel()->invalidate(); }
void LocalsTreeItem::retrieveModelicaMetaType() { if (getDisplayType().isEmpty() || (getDisplayType().compare(Helper::VALUE_OPTIMIZED_OUT) == 0) || (getDisplayType().compare(Helper::REPLACEABLE_TYPE_ANY) == 0)) { GDBAdapter *pGDBAdapter = mpLocalsTreeModel->getLocalsWidget()->getMainWindow()->getGDBAdapter(); StackFramesWidget *pStackFramesWidget = mpLocalsTreeModel->getLocalsWidget()->getMainWindow()->getStackFramesWidget(); if (parent() && parent()->getModelicaValue() && qobject_cast<ModelicaRecordValue*>(parent()->getModelicaValue())) { pGDBAdapter->postCommand(CommandFactory::getTypeOfAny(pStackFramesWidget->getSelectedThread(), pStackFramesWidget->getSelectedFrame(), getName(), true), GDBAdapter::BlockUntilResponse, this, &GDBAdapter::getTypeOfAnyCB); } else { pGDBAdapter->postCommand(CommandFactory::getTypeOfAny(pStackFramesWidget->getSelectedThread(), pStackFramesWidget->getSelectedFrame(), getName(), false), GDBAdapter::BlockUntilResponse, this, &GDBAdapter::getTypeOfAnyCB); } } else { retrieveValue(); } }
/*! * \brief LocalsTreeItem::setModelicaMetaType * Sets the type of the LocalsTreeItem and sends the command to retireve value. * \param type */ void LocalsTreeItem::setModelicaMetaType(QString type) { setDisplayType(type); if (getDisplayType().compare(Helper::REPLACEABLE_TYPE_ANY) == 0) { setDisplayValue(tr("<uninitialized variable>")); } else { retrieveValue(); } /* invalidate the view so that the items show the updated values. */ mpLocalsTreeModel->getLocalsWidget()->getLocalsTreeProxyModel()->invalidate(); }
/*! * \brief LocalsTreeItem::setModelicaMetaType * Sets the type of the LocalsTreeItem and sends the command to retireve value. * \param type */ void LocalsTreeItem::setModelicaMetaType(QString type) { setDisplayType(type); if (getDisplayType().compare(Helper::REPLACEABLE_TYPE_ANY) == 0) { setDisplayValue(tr("<uninitialized variable>")); } else { retrieveValue(); } /* update the view with new values of LocalsTreeItem */ mpLocalsTreeModel->updateLocalsTreeItem(this); }
QVariant LocalsTreeItem::data(int column, int role) const { switch (role) { case Qt::DisplayRole: switch (column) { case 0: return getDisplayName(); case 1: return getDisplayType(); case 2: // display the string type with quotes. if (getDisplayType().compare(Helper::STRING) == 0) { return QString("\"%1\"").arg(getDisplayValue()); } else { return getDisplayValue(); } default: break; } case Qt::ToolTipRole: switch (column) { case 0: return getDisplayName(); case 1: return getDisplayType(); case 2: return getDisplayValue(); default: break; } case Qt::BackgroundRole: return valueChanged() ? QColor(Qt::yellow) : QVariant(); default: break; } return QVariant(); }
/*! * \brief LocalsTreeItem::retrieveValue * Gets the value of the LocalsTreeItem using CommandFactory::anyString */ void LocalsTreeItem::retrieveValue() { GDBAdapter *pGDBAdapter = mpLocalsTreeModel->getLocalsWidget()->getMainWindow()->getGDBAdapter(); StackFramesWidget *pStackFramesWidget = mpLocalsTreeModel->getLocalsWidget()->getMainWindow()->getStackFramesWidget(); if (isCoreTypeExceptString()) { pGDBAdapter->postCommand(CommandFactory::dataEvaluateExpression(pStackFramesWidget->getSelectedThread(), pStackFramesWidget->getSelectedFrame(), getName()), GDBAdapter::BlockUntilResponse, this, &GDBAdapter::dataEvaluateExpressionCB); } else if (isCoreType()) { pGDBAdapter->postCommand(CommandFactory::anyString(pStackFramesWidget->getSelectedThread(), pStackFramesWidget->getSelectedFrame(), getName()), GDBAdapter::BlockUntilResponse, this, &GDBAdapter::anyStringCB); } else { setValue(getDisplayType()); } }
void EditTSCtrl::renderGrid() { if( !isOrthoDisplayType() ) return; GFXDEBUGEVENT_SCOPE( Editor_renderGrid, ColorI::WHITE ); // Calculate the displayed grid size based on view F32 drawnGridSize = mGridPlaneSize; F32 gridPixelSize = projectRadius(1.0f, mGridPlaneSize); if(gridPixelSize < mGridPlaneSizePixelBias) { U32 counter = 1; while(gridPixelSize < mGridPlaneSizePixelBias) { drawnGridSize = mGridPlaneSize * counter * 10.0f; gridPixelSize = projectRadius(1.0f, drawnGridSize); ++counter; // No infinite loops here if(counter > 1000) break; } } F32 minorTickSize = 0; F32 gridSize = drawnGridSize; U32 minorTickMax = mGridPlaneMinorTicks + 1; if(minorTickMax > 0) { minorTickSize = drawnGridSize; gridSize = drawnGridSize * minorTickMax; } // Build the view-based origin VectorF dir; smCamMatrix.getColumn( 1, &dir ); Point3F gridPlanePos = smCamPos + dir; Point2F size(mOrthoWidth + 2 * gridSize, mOrthoHeight + 2 * gridSize); GFXStateBlockDesc desc; desc.setBlend( true ); desc.setZReadWrite( true, false ); GFXDrawUtil::Plane plane = GFXDrawUtil::PlaneXY; switch( getDisplayType() ) { case DisplayTypeTop: case DisplayTypeBottom: plane = GFXDrawUtil::PlaneXY; break; case DisplayTypeLeft: case DisplayTypeRight: plane = GFXDrawUtil::PlaneYZ; break; case DisplayTypeFront: case DisplayTypeBack: plane = GFXDrawUtil::PlaneXZ; break; default: break; } GFX->getDrawUtil()->drawPlaneGrid( desc, gridPlanePos, size, Point2F( minorTickSize, minorTickSize ), mGridPlaneMinorTickColor, plane ); GFX->getDrawUtil()->drawPlaneGrid( desc, gridPlanePos, size, Point2F( gridSize, gridSize ), mGridPlaneColor, plane ); }