本文整理汇总了C++中BasicBox类的典型用法代码示例。如果您正苦于以下问题:C++ BasicBox类的具体用法?C++ BasicBox怎么用?C++ BasicBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BasicBox类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_UNUSED
void
TriggerPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
QRectF rect = boundingRect();
painter->save();
BasicBox *box = NULL;
if (_abstract->boxID() != NO_ID) {
if ((box = _scene->getBox(_abstract->boxID())) != NULL) {
QPen pen = painter->pen();
QBrush brush = painter->brush();
pen.setColor(box->color().darker());
pen.setWidth(isSelected() ? 1.5 * BasicBox::LINE_WIDTH : BasicBox::LINE_WIDTH / 2);
painter->setPen(pen);
if (_scene->playing()) {
if (!isWaiting()) {
drawFlag(painter, QColor("red"));
}
else {
if(!_scene->triggersQueueList()->isEmpty())
if (_scene->triggersQueueList()->first() == this) {
drawFlag(painter, QColor("green"));
this->setFocus();
}
else {
// brush.setColor(QColor("orange"));
// painter->setBrush(brush);
drawFlag(painter, QColor("orange"));
}
}
if (_abstract->waiting()) {
BasicBox *box = _scene->getBox(_abstract->boxID());
box->update();
switch (_abstract->boxExtremity()) {
case BOX_START:
painter->drawText(rect.topRight() + QPointF(0, rect.height() / 2), QString::fromStdString(_abstract->message()));
break;
case BOX_END:
painter->drawText(rect.topLeft() + QPointF(-QString::fromStdString(_abstract->message()).length() * 7, rect.height() / 2), QString::fromStdString(_abstract->message()));
break;
default:
break;
}
}
}
else {
drawFlag(painter, QColor(Qt::darkGray));
}
}
}
painter->restore();
}
示例2:
void
ConditionalRelation::updateBoxesCoordinates(unsigned int boxId)
{
// Move related boxes, except boxId's box (already moved by user)
QList<BasicBox *>::iterator it;
BasicBox *box = _scene->getBox(boxId),
*curBox;
float curBoxX,
boxX = box->getLeftGripPoint().x();
for(it=_boxesAttached.begin() ; it!=_boxesAttached.end() ; it++)
{
curBox = *it;
if(curBox->ID() != box->ID())
{
curBoxX = curBox->getLeftGripPoint().x();
if(boxX != curBoxX)
{
curBox->moveBy(boxX - curBoxX, 0.);
_scene->boxMoved(curBox->ID());
}
}
}
}
示例3:
void
AttributesEditor::startChanged()
{
// std::cout<<"--- startChanged ---"<<std::endl;
BasicBox * box = _scene->getBox(_boxEdited);
if (box != NULL) {
box->moveBy(_boxStartValue->value() * S_TO_MS / MaquetteScene::MS_PER_PIXEL - box->getTopLeft().x(), 0);
_scene->boxMoved(_boxEdited);
}
}
示例4: mouseReleaseEvent
void GenLineMode::mouseReleaseEvent(QGraphicsSceneMouseEvent * event){
QTransform transform;
BasicBox* begin = dynamic_cast<BasicBox*>(canvas->itemAt(event->scenePos(), transform));
BasicBox* end = dynamic_cast<BasicBox*>(canvas->itemAt(event->buttonDownScenePos(Qt::LeftButton), transform));
if(begin && end){
GenLine* line = new GenLine();
line->setPorts(begin->getPort(event->scenePos()), end->getPort(event->buttonDownScenePos(Qt::LeftButton)));
canvas->addItem(line);
}
std::cout<<"genline released"<<std::endl;
}
示例5: QSizeF
void
AttributesEditor::lengthChanged()
{
// std::cout<<"--- length changed ---"<<std::endl;
BasicBox * box = _scene->getBox(_boxEdited);
if (box != NULL) {
box->resizeWidthEdition(_boxLengthValue->value() * S_TO_MS / MaquetteScene::MS_PER_PIXEL);
QPainterPath nullPath;
nullPath.addRect(QRectF(QPointF(0., 0.), QSizeF(0., 0.)));
_scene->setSelectionArea(nullPath);
box->setSelected(true);
_scene->setResizeBox(_boxEdited);
_scene->boxResized();
}
}
示例6: if
void
TriggerPoint::updatePosition()
{
if (_abstract->boxID() != NO_ID) {
BasicBox *box = _scene->getBox(_abstract->boxID());
if (box != NULL) {
if (_abstract->boxExtremity() == BOX_START) {
setPos(QPointF(box->getShapeTopLeft().x() + WIDTH / 2., box->getShapeTopLeft().y() - HEIGHT / 2.));
}
else if (_abstract->boxExtremity() == BOX_END) {
setPos(QPointF(box->getShapeTopRight().x() - WIDTH / 2., box->getShapeTopRight().y() - HEIGHT / 2.));
}
// setZValue(box->currentZvalue()-1);
}
}
update();
}
示例7:
void
CurvesWidget::removeCurve(const string &address)
{
map<string, CurveWidget *>::iterator curveIt = _curveMap.find(address);
QString curveAddress = QString::fromStdString(address);
int index;
if (curveIt != _curveMap.end()) {
_curveMap.erase(curveIt);
index = _comboBox->findText(curveAddress);
if (index > -1) {
_comboBox->removeItem(index);
}
BasicBox *curveBox = Maquette::getInstance()->getBox(_boxID);
if (curveBox != NULL) {
curveBox->removeCurve(address);
}
}
}
示例8:
void
ParentBox::updateDisplay(QString displayMode)
{
BasicBox *curBox;
std::map<unsigned int, BasicBox*>::iterator it;
if (displayMode == SCENARIO_MODE_TEXT) {
for (it = _children.begin(); it != _children.end(); ++it) {
curBox = it->second;
curBox->lower(false);
curBox->setEnabled(true);
}
}
else {
for (it = _children.begin(); it != _children.end(); ++it) {
curBox = it->second;
curBox->lower(true);
curBox->setEnabled(false);
}
}
}
示例9: mapFromScene
void
Relation::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
{
QGraphicsItem::mouseMoveEvent(event);
double eventPosX = mapFromScene(event->scenePos()).x();
double startX = mapFromScene(_start).x();
if (_leftHandleSelected) {
changeBounds(_abstract->maxBound() == NO_BOUND ? std::max(eventPosX - startX, 0.) : std::min((float)std::max(eventPosX - startX, 0.), _abstract->maxBound()), _abstract->maxBound());
_scene->changeRelationBounds(_abstract->ID(), NO_LENGTH, _abstract->minBound(), _abstract->maxBound());
update();
}
else if (_rightHandleSelected) {
_scene->changeRelationBounds(_abstract->ID(), NO_LENGTH, _abstract->minBound(), std::max((float)std::max(eventPosX - startX, 0.), _abstract->minBound()));
update();
}
else if (_middleHandleSelected) {
BasicBox *rightBox = _scene->getBox(_abstract->secondBox());
_scene->changeRelationBounds(_abstract->ID(), NO_LENGTH, NO_BOUND, NO_BOUND);
qreal factorX = 2 * (eventPosX - _mouseClickPosSave.x());
rightBox->moveBy(factorX, 0.);
rightBox->setTopLeft(rightBox->getTopLeft() + QPointF(factorX, 0.));
rightBox->updateStuff();
_scene->boxMoved(rightBox->ID());
}
}
示例10: switch
void
Relation::updateCoordinates()
{
BasicBox *box = _scene->getBox(_abstract->firstBox());
if (box != NULL) {
switch (_abstract->firstExtremity()) {
case BOX_START:
_start = box->getLeftGripPoint();
break;
case BOX_END:
_start = box->getRightGripPoint();
break;
case NO_EXTREMITY:
_start = box->getCenter();
break;
}
}
box = _scene->getBox(_abstract->secondBox());
if (box != NULL) {
switch (_abstract->secondExtremity()) {
case BOX_START:
if (box != NULL) {
_end = box->getLeftGripPoint();
}
break;
case BOX_END:
if (box != NULL) {
_end = box->getRightGripPoint();
}
break;
case NO_EXTREMITY:
if (box != NULL) {
_end = box->getCenter();
}
break;
}
}
// std::cout<<"\t start = "<<_start.x()*MaquetteScene::MS_PER_PIXEL<<std::endl;
// std::cout<<"\t end = "<<_end.x()*MaquetteScene::MS_PER_PIXEL<<std::endl;
// std::cout<<"\t Length = "<<_abstract->_length*MaquetteScene::MS_PER_PIXEL<<std::endl;
_abstract->_length = _end.x() - _start.x();
setPos(getCenter());
}
示例11: Q_UNUSED
void
AttributesEditor::updateWidgets(bool boxModified)
{
Q_UNUSED(boxModified);
BasicBox * box = _scene->getBox(_boxEdited);
if (box != NULL) {
box->update();
box->centerWidget();
_boxStartValue->setValue(box->beginPos() * MaquetteScene::MS_PER_PIXEL / S_TO_MS);
_boxLengthValue->setValue(box->width() * MaquetteScene::MS_PER_PIXEL / S_TO_MS);
_boxName->setText(box->name());
_colorButtonPixmap->fill(box->currentColor());
_generalColorButton->setIcon(QIcon(*_colorButtonPixmap));
}
update();
}
示例12: CurveWidget
bool
CurvesWidget::updateCurve(const string &address, bool forceUpdate)
{
BasicBox *box = Maquette::getInstance()->getBox(_boxID);
if (box != NULL) { // Box Found
AbstractCurve *abCurve = box->getCurve(address);
map<string, CurveWidget *>::iterator curveIt2 = _curveMap.find(address);
bool curveFound = (curveIt2 != _curveMap.end());
unsigned int curveTabIndex = 0;
CurveWidget *curveTab = NULL;
if (curveFound) {
curveTab = curveIt2->second;
}
static const bool FORCE_SHOW = true;
static const bool FORCE_HIDE = false;
unsigned int sampleRate;
bool redundancy, interpolate;
vector<float> values, xPercents, yValues, coeff;
vector<string> argTypes;
vector<short> sectionType;
if (abCurve != NULL) { // Abstract Curve found
if (abCurve->_show) { // Abstract curve showing
if (curveFound) { // Curve tab existing
if (forceUpdate) { // Force updating through engines
bool getCurveSuccess = Maquette::getInstance()->getCurveAttributes(_boxID, address, 0, sampleRate, redundancy, interpolate, values, argTypes, xPercents, yValues, sectionType, coeff);
if (getCurveSuccess) {
curveTab->setAttributes(_boxID, address, 0, values, sampleRate, redundancy, FORCE_SHOW, interpolate, argTypes, xPercents, yValues, sectionType, coeff);
box->setCurve(address, curveTab->abstractCurve());
if (!_interpolation->updateLine(address, interpolate, sampleRate, redundancy, FORCE_SHOW)) {
_interpolation->addLine(address, interpolate, sampleRate, redundancy, FORCE_SHOW);
}
}
}
else { // No forcing : updating through abstract curve
curveTab->setAttributes(abCurve);
if (!_interpolation->updateLine(address, abCurve->_interpolate, abCurve->_sampleRate, abCurve->_redundancy, abCurve->_show)) {
_interpolation->addLine(address, abCurve->_interpolate, abCurve->_sampleRate, abCurve->_redundancy, abCurve->_show);
}
}
}
else { // Curve tab not existing
if (forceUpdate) { // Force creating through engines
bool getCurveSuccess = Maquette::getInstance()->getCurveAttributes(_boxID, address, 0, sampleRate, redundancy, interpolate, values, argTypes, xPercents, yValues, sectionType, coeff);
if (getCurveSuccess) {
// Create and set
curveTab = new CurveWidget(NULL);
_tabWidget->clear();
curveTab->setAttributes(_boxID, address, 0, values, sampleRate, redundancy, FORCE_SHOW, interpolate, argTypes, xPercents, yValues, sectionType, coeff);
QString curveAddressStr = QString::fromStdString(address);
// Add tab and store
addCurve(curveAddressStr, curveTab);
addToComboBox(curveAddressStr);
_curveMap[address] = curveTab;
displayCurve(_comboBox->currentText());
// Set box curve
box->setCurve(address, curveTab->abstractCurve());
if (!_interpolation->updateLine(address, interpolate, sampleRate, redundancy, FORCE_SHOW)) {
_interpolation->addLine(address, interpolate, sampleRate, redundancy, FORCE_SHOW);
}
}
}
else { // No forcing : create through abstract curve
// Create and set
curveTab = new CurveWidget(NULL);
curveTab->setAttributes(abCurve);
QString curveAddressStr = QString::fromStdString(address);
// Add tab and store
addCurve(curveAddressStr, curveTab);
_curveMap[address] = curveTab;
addToComboBox(curveAddressStr);
displayCurve(_comboBox->currentText());
if (!_interpolation->updateLine(address, abCurve->_interpolate, abCurve->_sampleRate, abCurve->_redundancy, abCurve->_show)) {
_interpolation->addLine(address, abCurve->_interpolate, abCurve->_sampleRate, abCurve->_redundancy, abCurve->_show);
}
}
}
}
else { // Abstract curve hiding
if (curveFound) { // Curve tab existing
if (forceUpdate) { // Force updating through engines
bool getCurveSuccess = Maquette::getInstance()->getCurveAttributes(_boxID, address, 0, sampleRate, redundancy, interpolate, values, argTypes, xPercents, yValues, sectionType, coeff);
if (getCurveSuccess) {
if (values.front() != values.back()) {
curveTab->setAttributes(_boxID, address, 0, values, sampleRate, redundancy, FORCE_SHOW, interpolate, argTypes, xPercents, yValues, sectionType, coeff);
}
else {
// Set and assign new abstract curve to box
curveTab->setAttributes(_boxID, address, 0, values, sampleRate, redundancy, FORCE_HIDE, interpolate, argTypes, xPercents, yValues, sectionType, coeff);
}
//.........这里部分代码省略.........
示例13: Q_UNUSED
bool
BoxWidget::updateCurve(const string &address, bool forceUpdate)
{
Q_UNUSED(forceUpdate);
BasicBox *box = Maquette::getInstance()->getBox(_boxID);
if (box != NULL) { // Box Found
if (box->hasCurve(address)) {
AbstractCurve *abCurve = box->getCurve(address);
QMap<string, CurveWidget *>::iterator curveIt2 = _curveMap->find(address);
QString curveAddressStr = QString::fromStdString(address);
bool curveFound = (curveIt2 != _curveMap->end());
CurveWidget *curveTab = NULL;
unsigned int sampleRate;
bool redundancy, interpolate;
vector<float> values, xPercents, yValues, coeff;
vector<string> argTypes;
vector<short> sectionType;
bool getCurveSuccess = Maquette::getInstance()->getCurveAttributes(_boxID, address, 0, sampleRate, redundancy, interpolate, values, argTypes, xPercents, yValues, sectionType, coeff);
//--- PRINT ---
// std::cout<<"values : "<<std::endl;
// for (unsigned int i = 0; i < yValues.size() ; i++) {
// std::cout<<" "<<yValues[i]<<std::endl;
// }
// std::cout<<std::endl;
//-------------
if (getCurveSuccess) {
/********** Abstract Curve found ***********/
if (abCurve != NULL) {
if (curveFound) {
curveTab = curveIt2.value();
curveTab->setAttributes(_boxID, address, 0, values, sampleRate, redundancy, abCurve->_show, interpolate, argTypes, xPercents, yValues, sectionType, coeff);
bool muteState = Maquette::getInstance()->getCurveMuteState(_boxID, address);
if (forceUpdate) {
if (!muteState) {
addCurve(curveAddressStr, curveTab);
}
else {
removeCurve(address);
}
}
}
else {
//Create
curveTab = new CurveWidget(NULL);
curveTab->setAttributes(_boxID, address, 0, values, sampleRate, redundancy, abCurve->_show, interpolate, argTypes, xPercents, yValues, sectionType, coeff);
bool muteState = Maquette::getInstance()->getCurveMuteState(_boxID, address);
if (!muteState) {
addCurve(curveAddressStr, curveTab);
}
else {
removeCurve(address);
}
}
//Set attributes
box->setCurve(address, curveTab->abstractCurve());
}
/******* Abstract Curve not found ********/
else {
bool show = true;
// interpolate = !Maquette::getInstance()->getCurveMuteState(_boxID,address);
// if (xPercents.empty() && yValues.empty() && values.size() >= 2) {
// if (values.front() == values.back()) {
// show = false;
// interpolate = false;
// }
// }
//Set attributes
curveTab = new CurveWidget(NULL);
QString curveAddressStr = QString::fromStdString(address);
curveTab->setAttributes(_boxID, address, 0, values, sampleRate, redundancy, show, interpolate, argTypes, xPercents, yValues, sectionType, coeff);
if (interpolate) {
addCurve(curveAddressStr, curveTab);
box->setCurve(address, curveTab->abstractCurve());
}
}
}
}
else {
return false;
}
}
else { // Box Not Found
return false;
}
return false;
}