示例#1
0
	void SkinItem::deserialization(MyGUI::xml::Element* _node, MyGUI::Version _version)
	{
		mName = _node->findAttribute("name");

		mStates.destroyAllChilds();
		mSeparators.destroyAllChilds();
		mRegions.destroyAllChilds();

		MyGUI::xml::ElementEnumerator nodes = _node->getElementEnumerator();
		while (nodes.next())
		{
			MyGUI::xml::Element* node = nodes.current();

			if (node->getName() == "PropertySet")
			{
				mPropertySet->deserialization(node, _version);
			}
			else if (node->getName() == "StateItem")
			{
				StateItem* item = mStates.createChild();
				item->deserialization(node, _version);
			}
			else if (node->getName() == "SeparatorItem")
			{
				SeparatorItem* item = mSeparators.createChild();
				item->deserialization(node, _version);
			}
			else if (node->getName() == "RegionItem")
			{
				RegionItem* item = mRegions.createChild();
				item->deserialization(node, _version);
			}
		}
	}
	void StatePropertyControl::updateStateProperties()
	{
		StateItem* state = getCurrentState();
		mPropertyVisibleControl->setProperty(state != nullptr ? state->getPropertySet()->getChild("Visible") : nullptr);
		mPropertyPositionControl->setProperty(state != nullptr ? state->getPropertySet()->getChild("Position") : nullptr);
		mPropertyColourControl->setProperty(state != nullptr ? state->getPropertySet()->getChild("TextColour") : nullptr);
		mPropertyOffsetControl->setProperty(state != nullptr ? state->getPropertySet()->getChild("TextShift") : nullptr);
	}
示例#3
0
void BodyStateViewImpl::updateDeviceStates(DevicePtr device, int rowIndex)
{
    if(currentBody){
        StateItem* item = static_cast<StateItem*>(stateTreeWidget.topLevelItem(rowIndex));
        int size = device->stateSize();
        buf.resize(size);
        device->writeState(&buf.front());
        int i;
        for(i=0; i < size; ++i){
            item->setText(i + 1, QString::number(buf[i], 'f', 2));
        }
        for(   ; i < item->lastNumValidColumns; ++i){
            item->setText(i + 1, "");
        }
        item->lastNumValidColumns = size;
    }
}
示例#4
0
	void StatesListControl::updatePreset()
	{
		mPresets->setEnabled(getCurrentSkin() != nullptr);

		if (getCurrentSkin() != nullptr)
		{
			int currentPreset = 0;
			int bitIndex = 0;

			ItemHolder<StateItem>::EnumeratorItem states = getCurrentSkin()->getStates().getChildsEnumerator();
			while (states.next())
			{
				StateItem* item = states.current();
				bool visible = item->getPropertySet()->getPropertyValue("Visible") == "True";
				if (visible)
					currentPreset |= (1 << bitIndex);

				++ bitIndex;
			}

			size_t indexSelected = MyGUI::ITEM_NONE;

			size_t count = mPresets->getItemCount();
			for (size_t index = 0; index < count; ++index)
			{
				PresetEnum preset = *mPresets->getItemDataAt<PresetEnum>(index);
				if (preset == currentPreset)
				{
					indexSelected = index;
					break;
				}
			}

			mPresets->setIndexSelected(indexSelected);

			mPresets->setEnabled(true);
		}
		else
		{
			mPresets->setEnabled(false);
		}

	}
示例#5
0
	void StatesListControl::updateList()
	{
		if (getCurrentSkin() != nullptr)
		{
			StateItem* selectedItem = getCurrentSkin()->getStates().getItemSelected();
			size_t selectedIndex = MyGUI::ITEM_NONE;

			size_t index = 0;
			ItemHolder<StateItem>::EnumeratorItem states = getCurrentSkin()->getStates().getChildsEnumerator();
			while (states.next())
			{
				StateItem* item = states.current();

				MyGUI::UString name;
				if (item->getPropertySet()->getPropertyValue("Visible") != "True")
					name = replaceTags("ColourDisabled") + item->getName();
				else
					name = item->getName();

				if (index < mList->getItemCount())
				{
					mList->setItemNameAt(index, name);
					mList->setItemDataAt(index, item);
				}
				else
				{
					mList->addItem(name, item);
				}

				if (item == selectedItem)
					selectedIndex = index;

				index ++;
			}

			while (index < mList->getItemCount())
				mList->removeItemAt(mList->getItemCount() - 1);

			mList->setIndexSelected(selectedIndex);
		}
	}
示例#6
0
	void StateTextureControl::updateUnselectedStates()
	{
		std::vector<MyGUI::IntCoord> coords;

		if (getCurrentSkin() != nullptr)
		{
			ItemHolder<StateItem>::EnumeratorItem states = getCurrentSkin()->getStates().getChildsEnumerator();
			while (states.next())
			{
				StateItem* item = states.current();
				if (item != getCurrentSkin()->getStates().getItemSelected())
				{
					if (item->getPropertySet()->getPropertyValue("Visible") == "True")
						addCoord(coords,
							getCurrentSkin()->getPropertySet()->getPropertyValue("Coord"),
							item->getPropertySet()->getPropertyValue("Position"));
				}
			}
		}

		drawUnselectedStates(coords);
	}
示例#7
0
	void StatesListControl::notifyComboChangePosition(MyGUI::ComboBox* _sender, size_t _index)
	{
		if (getCurrentSkin() == nullptr)
			return;

		if (_index == MyGUI::ITEM_NONE)
			return;

		PresetEnum preset = *_sender->getItemDataAt<PresetEnum>(_index);

		size_t index = 0;
		ItemHolder<StateItem>::EnumeratorItem states = getCurrentSkin()->getStates().getChildsEnumerator();
		while (states.next())
		{
			StateItem* item = states.current();
			MyGUI::UString value = ((preset & (1 << index)) != 0) ? "True" : "False";
			item->getPropertySet()->setPropertyValue("Visible", value, mTypeName);

			++index;
		}

		updateList();
	}
示例#8
0
	SkinItem::SkinItem() :
		mPropertySet(nullptr)
	{
		mPropertySet = new PropertySet();
		mPropertySet->createChild("Texture", "Texture");
		mPropertySet->createChild("Coord", "IntCoord", "0 0 32 32");

		StateItem* skin = nullptr;

		skin = mStates.createChild();
		skin->setName("Disabled");
		skin->getPropertySet()->setPropertyValue("Visible", "False", "");

		skin = mStates.createChild();
		skin->setName("Normal");
		skin->getPropertySet()->setPropertyValue("Visible", "True", "");

		skin = mStates.createChild();
		skin->setName("Over");
		skin->getPropertySet()->setPropertyValue("Visible", "False", "");

		skin = mStates.createChild();
		skin->setName("Pressed");
		skin->getPropertySet()->setPropertyValue("Visible", "False", "");

		skin = mStates.createChild();
		skin->setName("Selected Disabled");
		skin->getPropertySet()->setPropertyValue("Visible", "False", "");

		skin = mStates.createChild();
		skin->setName("Selected Normal");
		skin->getPropertySet()->setPropertyValue("Visible", "False", "");

		skin = mStates.createChild();
		skin->setName("Selected Over");
		skin->getPropertySet()->setPropertyValue("Visible", "False", "");

		skin = mStates.createChild();
		skin->setName("Selected Pressed");
		skin->getPropertySet()->setPropertyValue("Visible", "False", "");


		SeparatorItem* separator = nullptr;

		separator = mSeparators.createChild();
		separator->setName("Top");
		separator->setCorner(MyGUI::Align::Top);
		separator->getPropertySet()->setPropertyValue("Offset", "1", "");

		separator = mSeparators.createChild();
		separator->setName("Bottom");
		separator->setCorner(MyGUI::Align::Bottom);
		separator->getPropertySet()->setPropertyValue("Offset", "1", "");

		separator = mSeparators.createChild();
		separator->setName("Left");
		separator->setCorner(MyGUI::Align::Left);
		separator->getPropertySet()->setPropertyValue("Offset", "1", "");

		separator = mSeparators.createChild();
		separator->setName("Right");
		separator->setCorner(MyGUI::Align::Right);
		separator->getPropertySet()->setPropertyValue("Offset", "1", "");


		RegionItem* region = nullptr;

		region = mRegions.createChild();
		region->setName("Left Top");
		region->setSeparator(MyGUI::Align::Left | MyGUI::Align::Top);
		region->getPropertySet()->setPropertyValue("Align", "Left Top", "");
		region->getPropertySet()->setPropertyReadOnly("Enabled", true);
		region->getPropertySet()->setPropertyReadOnly("Position", true);
		region->getPropertySet()->setPropertyReadOnly("Align", true);

		region = mRegions.createChild();
		region->setName("Top");
		region->setSeparator(MyGUI::Align::Top);
		region->getPropertySet()->setPropertyValue("Align", "HStretch Top", "");
		region->getPropertySet()->setPropertyReadOnly("Enabled", true);
		region->getPropertySet()->setPropertyReadOnly("Position", true);
		region->getPropertySet()->setPropertyReadOnly("Align", true);

		region = mRegions.createChild();
		region->setName("Right Top");
		region->setSeparator(MyGUI::Align::Right | MyGUI::Align::Top);
		region->getPropertySet()->setPropertyValue("Align", "Right Top", "");
		region->getPropertySet()->setPropertyReadOnly("Enabled", true);
		region->getPropertySet()->setPropertyReadOnly("Position", true);
		region->getPropertySet()->setPropertyReadOnly("Align", true);

		region = mRegions.createChild();
		region->setName("Right");
		region->setSeparator(MyGUI::Align::Right);
		region->getPropertySet()->setPropertyValue("Align", "Right VStretch", "");
		region->getPropertySet()->setPropertyReadOnly("Enabled", true);
		region->getPropertySet()->setPropertyReadOnly("Position", true);
		region->getPropertySet()->setPropertyReadOnly("Align", true);

		region = mRegions.createChild();
		region->setName("Right Bottom");
		region->setSeparator(MyGUI::Align::Right | MyGUI::Align::Bottom);
		region->getPropertySet()->setPropertyValue("Align", "Right Bottom", "");
		region->getPropertySet()->setPropertyReadOnly("Enabled", true);
		region->getPropertySet()->setPropertyReadOnly("Position", true);
		region->getPropertySet()->setPropertyReadOnly("Align", true);

		region = mRegions.createChild();
		region->setName("Bottom");
		region->setSeparator(MyGUI::Align::Bottom);
		region->getPropertySet()->setPropertyValue("Align", "HStretch Bottom", "");
		region->getPropertySet()->setPropertyReadOnly("Enabled", true);
		region->getPropertySet()->setPropertyReadOnly("Position", true);
		region->getPropertySet()->setPropertyReadOnly("Align", true);

		region = mRegions.createChild();
		region->setName("Left Bottom");
		region->setSeparator(MyGUI::Align::Left | MyGUI::Align::Bottom);
		region->getPropertySet()->setPropertyValue("Align", "Left Bottom", "");
		region->getPropertySet()->setPropertyReadOnly("Enabled", true);
		region->getPropertySet()->setPropertyReadOnly("Position", true);
		region->getPropertySet()->setPropertyReadOnly("Align", true);

		region = mRegions.createChild();
		region->setName("Left");
		region->setSeparator(MyGUI::Align::Left);
		region->getPropertySet()->setPropertyValue("Align", "Left VStretch", "");
		region->getPropertySet()->setPropertyReadOnly("Enabled", true);
		region->getPropertySet()->setPropertyReadOnly("Position", true);
		region->getPropertySet()->setPropertyReadOnly("Align", true);

		region = mRegions.createChild();
		region->setName("Center");
		region->setSeparator(MyGUI::Align::Center);
		region->getPropertySet()->setPropertyValue("Align", "Stretch", "");
		region->getPropertySet()->setPropertyReadOnly("Enabled", true);
		region->getPropertySet()->setPropertyReadOnly("Position", true);
		region->getPropertySet()->setPropertyReadOnly("Align", true);

		region = mRegions.createChild();
		region->setName("Text");
		region->setSeparator(MyGUI::Align::Center);
		region->getPropertySet()->setPropertyValue("Align", "Stretch", "");
		region->getPropertySet()->setPropertyValue("RegionType", "SimpleText", "");
		region->getPropertySet()->setPropertyValue("Visible", "False", "");
		region->getPropertySet()->setPropertyReadOnly("Enabled", true);
	}
示例#9
0
void MainWindow::mousePressEvent(QMouseEvent * e)
{

    if (ui->EditButton->isChecked()){}

    else{
        //partie commune à la création des etats
        // creation des deux éléments: l'ellipse etat (item) et son numero (text)
        StateItem *item = new StateItem(0,0,40,40,0,scene );

        item->setStateNumber(state_compteur);
        item->setAcceptTouchEvents(true);
        item->setAcceptsHoverEvents(true);
        item->setFlag(QGraphicsItem::ItemIsSelectable,true);
        item->setFlag(QGraphicsItem::ItemIsMovable,true);

        char text[50];
        sprintf(text,"%d",item->getStateNumber());
        QGraphicsTextItem *state=new QGraphicsTextItem(text,0,scene);

        //reglage tres sale de la position, voir si on ne peut pas faire mieux
        state->setPos(10,10);

        // incrementation du compteur d'etat de 1
        state_compteur++;


        //lien entre les deux elements: creation d'un groupe, avec les propriete selectionnable et movable
        QGraphicsItemGroup *group=new QGraphicsItemGroup(0);
        item->setParentItem(group);
        group->addToGroup(item);
        group->addToGroup(state);
        group->setFlag(QGraphicsItem::ItemIsMovable,true);
        group->setFlag(QGraphicsItem::ItemIsSelectable,true);
        group->setHandlesChildEvents(false);


        //ajout de l'element a la liste des transitions
        state_list.append(item);

        //ajout du groupe a la scene
        scene->addItem(group);
        group->setPos(e->x(),e->y());

        if (ui->StateButton->isChecked()){//le stylo est noir par défaut
            item->setStateProperty(0);
        }

        else{

            if (ui->AcceptButton->isChecked())
            {

                //identification de l'état accepteur
                item->setStateProperty(1);
                //creation du crayon vert
                QPen greenpen(Qt::green);
                item->setPen(greenpen);
            }
            else
            {
                if (ui->RejectButton->isChecked())
                {
                    //identification de l'état rejecteur
                    item->setStateProperty(-1);
                    //creation du crayon rouge
                    QPen redpen(Qt::red);
                    item->setPen(redpen);

                }
                else{
                    if (ui->InitStateButton->isChecked()){
                        //identification de l'état rejecteur
                        item->setStateProperty(2);
                        //creation du crayon rouge
                        QPen bluepen(Qt::blue);
                        item->setPen(bluepen);

                    }
                }

            }

        }

    }

}
示例#10
0
void BodyStateViewImpl::updateExtraStates()
{
    if(!currentBody){
        return;
    }
    const int prec = 3;
    
    for(int i=0 ;i < accessors.size(); ++i){
        const ExtraBodyStateAccessor& accessor = *accessors[i];
        const vector<int>& itemMap = extraStateItemMap[i];
        accessor.getState(extraState);
        for(int j=0; j < extraState.size(); ++j){
            const ExtraBodyStateAccessor::Value& s = extraState[j];
            StateItem* item = static_cast<StateItem*>(stateTreeWidget.topLevelItem(itemMap[j]));
            int column = 1;
            switch(s.which()){
            case ExtraBodyStateAccessor::BOOL:
                item->setText(column++, s.getBool() ? _("ON") : _("OFF"));
                break;
            case ExtraBodyStateAccessor::INT:
                item->setText(column++, QString::number(s.getInt(), 'f', prec));
                break;
            case ExtraBodyStateAccessor::DOUBLE:
                item->setText(column++, QString::number(s.getDouble(), 'f', prec));
                break;
            case ExtraBodyStateAccessor::ANGLE:
                item->setText(column++, QString::number(s.getAngle(), 'f', prec));
                break;
            case ExtraBodyStateAccessor::STRING:
                item->setText(column++, s.getString().c_str());
                break;
                /*
                  case ExtraBodyStateAccessor::VECTOR2:
                  {
                  const Vector2& v = get<Vector2>(s);
                  item->setText(column++, QString::number(v[0], 'f', prec));
                  item->setText(column++, QString::number(v[1], 'f', prec));
                  break;
                  }
                */
            case ExtraBodyStateAccessor::VECTOR3:
            {
                const Vector3f& v = s.getVector3f();
                item->setText(column++, QString::number(v[0], 'f', prec));
                item->setText(column++, QString::number(v[1], 'f', prec));
                item->setText(column++, QString::number(v[2], 'f', prec));
                break;
            }
            case ExtraBodyStateAccessor::VECTORX:
            {
                const VectorX& v = s.getVectorX();
                for(int i=0; i < v.size(); ++i){
                    item->setText(column++, QString::number(v[i], 'f', prec));
                }
                break;
            }
            default:
                break;
            }
            for(int i=column; i < item->lastNumValidColumns; ++i){
                item->setText(i, "");
            }
            item->lastNumValidColumns = column;
        }
    }
}
示例#11
0
void BodyStateViewImpl::updateStateList(BodyItem* bodyItem)
{
    stateConnections.disconnect();
    DeviceList<Sensor> devices;

    extraStateItemMap.clear();
    stateTreeWidget.clear();
    int maxNumStateElements = 0;

    if(currentBody){
        devices = currentBody->devices();

        for(int i=0; i < devices.size(); ++i){
            Device* device = devices.get(i);
            StateItem* deviceItem = new StateItem();
        
            deviceItem->setText(0, QString(" %1 ").arg(device->name().c_str()));
            stateTreeWidget.addTopLevelItem(deviceItem);

            if(device->stateSize() > maxNumStateElements){
                maxNumStateElements = device->stateSize();
            }
            stateConnections.add(
                device->sigStateChanged().connect(
                    boost::bind(&BodyStateViewImpl::updateDeviceStates, this, device, i)));
        }

        vector<string> names;
        currentBody->getCaches(accessors, names);
        for(int i=0; i < accessors.size(); ++i){
            ExtraBodyStateAccessor& accessor = *accessors[i];
            vector<int> itemMap;
            accessor.getState(extraState);
            if(!extraState.empty()){
                for(int j=0; j < extraState.size(); ++j){
                    QTreeWidgetItem* stateItem = new StateItem();
                    stateItem->setText(0, QString(" %1 ").arg(accessor.getStateItemLabel(j)));
                    itemMap.push_back(stateTreeWidget.topLevelItemCount());
                    stateTreeWidget.addTopLevelItem(stateItem);
                    int m = ExtraBodyStateAccessor::getNumValueElements(extraState[j]);
                    if(m > maxNumStateElements){
                        maxNumStateElements = m;
                    }
                }
                stateConnections.add(
                    accessor.sigStateChanged().connect(
                        boost::bind(&BodyStateViewImpl::updateExtraStates, this)));
            }
            extraStateItemMap.push_back(itemMap);
        }
    }
    
    int lastColumn = maxNumStateElements + 1;
    stateTreeWidget.setColumnCount(lastColumn + 1);
    stateTreeWidget.setHeaderSectionResizeMode(0, QHeaderView::ResizeToContents);
    for(int i=0; i < maxNumStateElements; ++i){
        stateTreeWidget.setHeaderSectionResizeMode(i+1, QHeaderView::Stretch);
    }
    stateTreeWidget.setHeaderSectionResizeMode(lastColumn, QHeaderView::Fixed);
    stateTreeWidget.header()->resizeSection(lastColumn, 0);

    const int n = stateTreeWidget.topLevelItemCount();
    for(int i=0; i < n; ++i){
        QTreeWidgetItem* item = stateTreeWidget.topLevelItem(i);
        item->setTextAlignment(0, Qt::AlignHCenter);
        for(int j=0; j < maxNumStateElements; ++j){
            //item->setTextAlignment(j + 1, Qt::AlignHCenter);
            item->setTextAlignment(j + 1, Qt::AlignRight);
        }
    }
}