Exemplo n.º 1
0
//===========================================
// Polygon::Polygon
//===========================================
Polygon::Polygon(const XmlNode data)
   : Asset(internString("Polygon")),
     m_outlineModel(Renderer::LINES),
     m_interiorModel(Renderer::TRIANGLES),
     m_renderer(Renderer::getInstance()) {

   try {
      XML_NODE_CHECK(data, Polygon);

      clear();

      XmlNode node = data.firstChild();
      while (!node.isNull() && node.name() == "Vec2f") {
         boost::shared_ptr<Vec2f> vert(new Vec2f(node));
         m_verts.push_back(vert);

         ++m_nVerts;
         node = node.nextSibling();
      }
   }
   catch (XmlException& e) {
      e.prepend("Error parsing XML for instance of class Polygon; ");
      throw;
   }

   restructure();
   updateModels();
}
Exemplo n.º 2
0
void ModelMgrWidget::setCurrentModel(const QString &model, bool notify)
{
    if (!q_modelStack.isEmpty()) {
        if (q_modelStack.last() == model) {
            return;     // 模式未改变
        }
    }

    //
    q_modelStack.clear();
    if (model == QStringLiteral("数据管理")) {
        q_modelStack << QStringLiteral("数据管理");
    } else if (model == QStringLiteral("数据查询")) {
        q_modelStack << QStringLiteral("数据管理")
                     << QStringLiteral("数据查询");
    } else if (model == QStringLiteral("数据分析")) {
        q_modelStack << QStringLiteral("数据管理")
                     << QStringLiteral("数据查询")
                     << QStringLiteral("数据分析");
    }

    //
    updateModels();

    //
    if (notify) {
        Q_EMIT currentModelChanged(model);
    }
}
Exemplo n.º 3
0
//===========================================
// Polygon::scale
//===========================================
void Polygon::scale(const Vec2f& sv) {
   if (sv.x == 1.0 && sv.y == 1.0) return;

   for (int i = 0; i < m_nVerts; ++i) {
      m_verts[i]->x = m_verts[i]->x * sv.x;
      m_verts[i]->y = m_verts[i]->y * sv.y;
   }

   updateModels();
}
Exemplo n.º 4
0
//===========================================
// Polygon::removeVertex
//===========================================
void Polygon::removeVertex(int idx) {
   if (idx > m_nVerts - 1 || idx < 0)
      throw Exception("Index out of range", __FILE__, __LINE__);

   for (int i = idx; i < m_nVerts - 1; ++i)
      m_verts[i] = m_verts[i + 1];

   --m_nVerts;

   restructure();
   updateModels();
}
Exemplo n.º 5
0
//===========================================
// Polygon::addVertex
//===========================================
void Polygon::addVertex(const Vec2f& vert) {
   if (m_nVerts >= MAX_VERTS) {
      stringstream msg;
      msg << "Error adding vertex; MAX_VERTS = " << MAX_VERTS;
      throw Exception(msg.str(), __FILE__, __LINE__);
   }

   m_verts.push_back(boost::shared_ptr<Vec2f>(new Vec2f(vert)));
   ++m_nVerts;

   restructure();
   updateModels();
}
Exemplo n.º 6
0
//===========================================
// Polygon::insertVertex
//===========================================
void Polygon::insertVertex(int idx, const Vec2f& vert) {
   if (idx > m_nVerts - 1 || idx < 0)
      throw Exception("Index out of range", __FILE__, __LINE__);

   ++m_nVerts;

   for (int i = m_nVerts - 1; i > idx; --i)
      m_verts[i] = m_verts[i - 1];

   *m_verts[idx] = vert;

   restructure();
   updateModels();
}
Exemplo n.º 7
0
void XxxForm::removeAction(void) {
	QMessageBox msgBox;
	msgBox.setText(qApp->tr("Are you sure?"));
	msgBox.setInformativeText(QString(qApp->tr(
			"Are you sure you want to delete the selected xxx objects?\n"
				"All of the following objects and their related items will be "
				"deleted:\n\nXxx: %1\n").arg(xXxModel->getName())));
	msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No
			| QMessageBox::Cancel);
	msgBox.setDefaultButton(QMessageBox::Yes);
	int ret = msgBox.exec();
	if (ret == QMessageBox::Cancel) {
		updateModels();
		updateForms();
		close();
		return;
	} else if (ret == QMessageBox::No)
		return;
	if (!remove()) {
		errorStatus(qApp->tr("Fails to remove the record."));
	} else {
		QMessageBox::information(0, qApp->tr("Xxx deleted"), QString(
				qApp->tr("Successfully deleted %1 xxx.")).arg("1"),
				QMessageBox::Ok);
		emit
		formDeleted();
		emit
				sendStatus(
						QString(qApp->tr("Successfully deleted %1 xxx.")).arg(
								"1"), 0);

		updateModels();
		updateForms();
		close();
	}
}
Exemplo n.º 8
0
void XxxForm::saveAndContinueSavingAction(void) {
	if (!save()) {
		errorStatus(qApp->tr("Failure trying to register the record."));
	} else {
		if (xXxModel->getId() > 0) {
			emit formChanged();
			okStatus(QString(qApp->tr(
					"The xxx \"%1\" was changed successfully.")).arg(
					xXxModel->getName()));
		} else {
			emit formAdded();
			okStatus(QString(qApp->tr(
					"The xxx \"%1\" was added successfully.")).arg(
					xXxModel->getName()));
		}
		updateModels();
		updateForms();
	}
}
Exemplo n.º 9
0
void TransactionProcessor::insert(Transaction *_transaction)
{
    if(_transaction->type() == Transaction::Buy)
    {
        int i = 0;
        while(i < m_buy.size() && _transaction->cost() < m_buy[i]->cost())
            ++i;
        m_buy.insert(i, _transaction);
    }
    else if(_transaction->type() == Transaction::Sell)
    {
        int i = 0;
        while(i > m_sell.size() && _transaction->cost() > m_sell[i]->cost())
            ++i;
        m_sell.insert(i, _transaction);
    }
    else
        qDebug() << "Invalid Transaction passed in model!" << Q_FUNC_INFO;

    updateModels();
}
Exemplo n.º 10
0
void TransactionProcessor::process()
{
    while(!m_buy.isEmpty() && !m_sell.isEmpty())
    {
        Transaction* buy = m_buy.first();
        Transaction* sell = m_sell.first();

        if(buy->cost() < sell->cost())
            break;

        qreal dealCost = (buy->time() < sell->time()) ? buy->cost() : sell->cost();

        Transaction* forHistory = new Transaction(dealCost, qMin(buy->volume(), sell->volume()));
        m_log << forHistory;

        if(buy->volume() < sell->volume())
        {
            sell->setVolume(sell->volume() - buy->volume());
            m_buy.removeFirst();
            delete buy;
        }
        else if(buy->volume() > sell->volume())
        {
            buy->setVolume(buy->volume() - sell->volume());
            m_sell.removeFirst();
            delete sell;
        }
        else // (buy->volume() == sell->volume())
        {
            m_sell.removeFirst();
            m_buy.removeFirst();
            delete buy;
            delete sell;
        }
    }
    updateModels();
    debugReport();
}
Exemplo n.º 11
0
ScriptDebugger::ScriptDebugger(const MODELMAP &models, QStandardItemModel *triggerModel) : QDialog(NULL, Qt::Window)
{
	modelMap = models;
	QSignalMapper *signalMapper = new QSignalMapper(this);

	// Add main page
	QWidget *mainWidget = new QWidget(this);
	QVBoxLayout *mainLayout = new QVBoxLayout();
	QHBoxLayout *placementLayout = new QHBoxLayout();
	placementLayout->addWidget(createButton("Add droids", SLOT(droidButtonClicked()), this));
	placementLayout->addWidget(createButton("Add structures", SLOT(structButtonClicked()), this));
	placementLayout->addWidget(createButton("Add features", SLOT(featButtonClicked()), this));
	mainLayout->addLayout(placementLayout);
	QHBoxLayout *miscLayout = new QHBoxLayout();
	miscLayout->addWidget(createButton("Research all", SLOT(researchButtonClicked()), this));
	miscLayout->addWidget(createButton("Show sensors", SLOT(sensorsButtonClicked()), this));
	miscLayout->addWidget(createButton("Shadows", SLOT(shadowButtonClicked()), this));
	miscLayout->addWidget(createButton("Fog", SLOT(fogButtonClicked()), this));
	mainLayout->addLayout(miscLayout);
	QHBoxLayout *worldLayout = new QHBoxLayout();
	worldLayout->addWidget(createButton("Show all", SLOT(deityButtonClicked()), this));
	worldLayout->addWidget(createButton("Weather", SLOT(weatherButtonClicked()), this));
	worldLayout->addWidget(createButton("Reveal mode", SLOT(revealButtonClicked()), this));
	mainLayout->addLayout(worldLayout);
	QHBoxLayout *selectedPlayerLayout = new QHBoxLayout();
	QLabel *selectPlayerLabel = new QLabel("Selected Player:");
	QComboBox *playerComboBox = new QComboBox;
	for (int i = 0; i < game.maxPlayers; i++)
	{
		playerComboBox->addItem(QString::number(i));
	}
	connect(playerComboBox, SIGNAL(activated(int)), this, SLOT(playerButtonClicked(int)));
	selectedPlayerLayout->addWidget(selectPlayerLabel);
	selectedPlayerLayout->addWidget(playerComboBox);
	mainLayout->addLayout(selectedPlayerLayout);
	QHBoxLayout *powerLayout = new QHBoxLayout();
	QLabel *powerLabel = new QLabel("Power:");
	QLineEdit *powerLineEdit = new QLineEdit;
	powerLineEdit->setText(QString::number(getPower(selectedPlayer)));
	connect(powerLineEdit, SIGNAL(textEdited(const QString&)), this, SLOT(powerEditing(const QString&)));
	connect(powerLineEdit, SIGNAL(returnPressed()), this, SLOT(powerEditingFinished()));
	powerLayout->addWidget(powerLabel);
	powerLayout->addWidget(powerLineEdit);
	mainLayout->addLayout(powerLayout);
	mainWidget->setLayout(mainLayout);
	tab.addTab(mainWidget, "Main");

	// Add globals
	for (MODELMAP::const_iterator i = models.constBegin(); i != models.constEnd(); ++i)
	{
		QWidget *dummyWidget = new QWidget(this);
		QScriptEngine *engine = i.key();
		QStandardItemModel *m = i.value();
		m->setParent(this); // take ownership to avoid memory leaks
		QTreeView *view = new QTreeView(this);
		view->setSelectionMode(QAbstractItemView::NoSelection);
		view->setModel(m);
		QString scriptName = engine->globalObject().property("scriptName").toString();
		int player = engine->globalObject().property("me").toInt32();
		QLineEdit *lineEdit = new QLineEdit(this);
		QVBoxLayout *layout = new QVBoxLayout();
		QHBoxLayout *layout2 = new QHBoxLayout();
		QPushButton *updateButton = new QPushButton("Update", this);
		QPushButton *button = new QPushButton("Run", this);
		connect(button, SIGNAL(pressed()), signalMapper, SLOT(map()));
		connect(updateButton, SIGNAL(pressed()), this, SLOT(updateModels()));
		signalMapper->setMapping(button, engine);
		editMap.insert(engine, lineEdit); // store this for slot
		layout->addWidget(view);
		layout2->addWidget(updateButton);
		layout2->addWidget(lineEdit);
		layout2->addWidget(button);
		layout->addLayout(layout2);

		dummyWidget->setLayout(layout);
		tab.addTab(dummyWidget, scriptName + ":" + QString::number(player));
	}
	connect(signalMapper, SIGNAL(mapped(QObject *)), this, SLOT(runClicked(QObject *)));

	// Add triggers
	triggerModel->setParent(this); // take ownership to avoid memory leaks
	triggerView.setModel(triggerModel);
	triggerView.resizeColumnToContents(0);
	triggerView.setSelectionMode(QAbstractItemView::NoSelection);
	triggerView.setSelectionBehavior(QAbstractItemView::SelectRows);
	tab.addTab(&triggerView, "Triggers");

	// Add labels
	labelModel = createLabelModel();
	labelModel->setParent(this); // take ownership to avoid memory leaks
	labelView.setModel(labelModel);
	labelView.resizeColumnToContents(0);
	labelView.setSelectionMode(QAbstractItemView::SingleSelection);
	labelView.setSelectionBehavior(QAbstractItemView::SelectRows);
	connect(&labelView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(labelClickedIdx(const QModelIndex &)));
	QPushButton *button = new QPushButton("Show", this);
	connect(button, SIGNAL(pressed()), this, SLOT(labelClicked()));
	QVBoxLayout *labelLayout = new QVBoxLayout(this);
	labelLayout->addWidget(&labelView);
	labelLayout->addWidget(button);
	QWidget *dummyWidget = new QWidget(this);
	dummyWidget->setLayout(labelLayout);
	tab.addTab(dummyWidget, "Labels");

	// Set up dialog
	QHBoxLayout *layout = new QHBoxLayout(this);
	layout->addWidget(&tab);
	setLayout(layout);
	resize(400, 500);
	setSizeGripEnabled(true);
	show();
	raise();
	powerLineEdit->setFocusPolicy(Qt::StrongFocus);
	powerLineEdit->setFocus();
	activateWindow();
}
Exemplo n.º 12
0
	void TextArea::setText(std::string const & text_)
	{
		text = text_;
		updateModels();
	}
Exemplo n.º 13
0
	void TextArea::setFont(Ptr<render::Font> const & font_)
	{
		font = font_;
		updateModels();
	}
Exemplo n.º 14
0
ScriptDebugger::ScriptDebugger(const MODELMAP &models, QStandardItemModel *triggerModel) : QDialog(NULL, Qt::Window)
{
	modelMap = models;
	QSignalMapper *signalMapper = new QSignalMapper(this);

	// Add globals
	for (MODELMAP::const_iterator i = models.constBegin(); i != models.constEnd(); ++i)
	{
		QWidget *dummyWidget = new QWidget(this);
		QScriptEngine *engine = i.key();
		QStandardItemModel *m = i.value();
		m->setParent(this); // take ownership to avoid memory leaks
		QTreeView *view = new QTreeView(this);
		view->setSelectionMode(QAbstractItemView::NoSelection);
		view->setModel(m);
		QString scriptName = engine->globalObject().property("scriptName").toString();
		int player = engine->globalObject().property("me").toInt32();
		QLineEdit *lineEdit = new QLineEdit(this);
		QVBoxLayout *layout = new QVBoxLayout();
		QHBoxLayout *layout2 = new QHBoxLayout();
		QPushButton *updateButton = new QPushButton("Update", this);
		QPushButton *button = new QPushButton("Run", this);
		connect(button, SIGNAL(pressed()), signalMapper, SLOT(map()));
		connect(updateButton, SIGNAL(pressed()), this, SLOT(updateModels()));
		signalMapper->setMapping(button, engine);
		editMap.insert(engine, lineEdit); // store this for slot
		layout->addWidget(view);
		layout2->addWidget(updateButton);
		layout2->addWidget(lineEdit);
		layout2->addWidget(button);
		layout->addLayout(layout2);

		dummyWidget->setLayout(layout);
		tab.addTab(dummyWidget, scriptName + ":" + QString::number(player));
	}
	connect(signalMapper, SIGNAL(mapped(QObject *)), this, SLOT(runClicked(QObject *)));

	// Add triggers
	triggerModel->setParent(this); // take ownership to avoid memory leaks
	triggerView.setModel(triggerModel);
	triggerView.resizeColumnToContents(0);
	triggerView.setSelectionMode(QAbstractItemView::NoSelection);
	triggerView.setSelectionBehavior(QAbstractItemView::SelectRows);
	tab.addTab(&triggerView, "Triggers");

	// Add labels
	labelModel = createLabelModel();
	labelModel->setParent(this); // take ownership to avoid memory leaks
	labelView.setModel(labelModel);
	labelView.resizeColumnToContents(0);
	labelView.setSelectionMode(QAbstractItemView::SingleSelection);
	labelView.setSelectionBehavior(QAbstractItemView::SelectRows);
	connect(&labelView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(labelClickedIdx(const QModelIndex &)));
	QPushButton *button = new QPushButton("Show", this);
	connect(button, SIGNAL(pressed()), this, SLOT(labelClicked()));
	QVBoxLayout *labelLayout = new QVBoxLayout(this);
	labelLayout->addWidget(&labelView);
	labelLayout->addWidget(button);
	QWidget *dummyWidget = new QWidget(this);
	dummyWidget->setLayout(labelLayout);
	tab.addTab(dummyWidget, "Labels");

	// Set up dialog
	QHBoxLayout *layout = new QHBoxLayout(this);
	layout->addWidget(&tab);
	setLayout(layout);
	setSizeGripEnabled(true);
	show();
	raise();
	activateWindow();
}
Exemplo n.º 15
0
//===========================================
// Polygon::rotate
//===========================================
void Polygon::rotate(float32_t deg, const Vec2f& p) {
   for (int i = 0; i < m_nVerts; ++i)
      m_verts[i]->rotate(p, deg);

   updateModels();
}
Exemplo n.º 16
0
void WIView::onReloadIconClicked()
{
    updateModels(m_Obs);
}
Exemplo n.º 17
0
//--------------------------------------------------------------
void ofApp::update(){
    ofBackground(1, 1, 1);
	
	kinect.update();
	
	// there is a new frame and we are connected
	if(kinect.isFrameNew()) {
		
		// load grayscale depth image from the kinect source
		grayImage.setFromPixels(kinect.getDepthPixels(), kinect.width, kinect.height);
		
		// we do two thresholds - one for the far plane and one for the near plane
		// we then do a cvAnd to get the pixels which are a union of the two thresholds
		if(bThreshWithOpenCV) {
			grayThreshNear = grayImage;
			grayThreshFar = grayImage;
			grayThreshNear.threshold(nearThreshold, true);
			grayThreshFar.threshold(farThreshold);
			cvAnd(grayThreshNear.getCvImage(), grayThreshFar.getCvImage(), grayImage.getCvImage(), NULL);
		} else {
			
			// or we do it ourselves - show people how they can work with the pixels
			unsigned char * pix = grayImage.getPixels();
			
			int numPixels = grayImage.getWidth() * grayImage.getHeight();
			for(int i = 0; i < numPixels; i++) {
				if(pix[i] < nearThreshold && pix[i] > farThreshold) {
					pix[i] = 255;
				} else {
					pix[i] = 0;
				}
			}
		}
		
		// update the cv images
		grayImage.flagImageChanged();
        grayImage.mirror(false, true);
		
		// find contours which are between the size of 20 pixels and 1/3 the w*h pixels.
		// also, find holes is set to true so we will get interior contours as well....
		contourFinder.findContours(grayImage, 10, (kinect.width*kinect.height)/2, 20, false);
	}
    
    int count = 0;

    for(int y = 0; y < kinect.height; y++) {
		for(int x = 0; x < kinect.width; x++) {
			if(/*kinect.getDistanceAt(x, y) > 472 && kinect.getDistanceAt(x, y) < 600
               &&*/ (int)kinect.getColorAt(x, y).r < 10
               && (int)kinect.getColorAt(x, y).g > 100
               && (int)kinect.getColorAt(x, y).b < 10
               )
            {
                count++;
                particlePos.push_back(ofPoint(1024 - x*2, y*2));
                if (!bInProgress) {
                    bInProgress = true;
                    cout << "bang! " << kinect.getDistanceAt(1024-x, y) << endl;
                    ofxAssimpModelLoader *mod = new ofxAssimpModelLoader;
                    //addModel();
                    //setupModel(mod);
                    cout << "x: " << x << endl;
                    cout << "y: " << y << endl;
                    cout << "color" << kinect.getColorAt(x, y) << endl;
                }
			}

		}
	}
    if (count == 0) {
        bInProgress = false;
    }
    
    //cout << "distance " << least << endl;    
    
    updateModels();
    updateSPK();
    
}
Exemplo n.º 18
0
// ***************************************************************************
void	CScene::renderPart(UScene::TRenderPart rp, bool	doHrcPass, bool doTrav, bool keepTrav)
{
	nlassert(_IsRendering);

	// if nothing (????), abort
	if(rp==UScene::RenderNothing)
		return;

	// If part asked already rendered, abort
	nlassert((rp & _RenderedPart) == 0); // cannot render the same part twice during a render

	// if first part to be rendered, do the start stuff
	if (_RenderedPart == UScene::RenderNothing)
	{
		RenderTrav.clearWaterModelList();

		if (doTrav)
		{
			// update water envmap
			//updateWaterEnvmap();
			_FirstFlare = NULL;

			double fNewGlobalSystemTime = NLMISC::CTime::ticksToSecond(NLMISC::CTime::getPerformanceTime());
			if(_GlobalSystemTime==0)
				_DeltaSystemTimeBetweenRender= 0.020;
			else
				_DeltaSystemTimeBetweenRender= fNewGlobalSystemTime - _GlobalSystemTime;
			_GlobalSystemTime = fNewGlobalSystemTime;
		}
		//
		++ _NumRender;
		//
		nlassert(CurrentCamera);

		// update models.
		updateModels();

		// Use the camera to setup Clip / Render pass.
		float left, right, bottom, top, znear, zfar;
		CurrentCamera->getFrustum(left, right, bottom, top, znear, zfar);

		// setup basic camera.
		ClipTrav.setFrustum(left, right, bottom, top, znear, zfar, CurrentCamera->isPerspective());

		RenderTrav.setFrustum (left, right, bottom, top, znear, zfar, CurrentCamera->isPerspective());
		RenderTrav.setViewport (_Viewport);

		LoadBalancingTrav.setFrustum (left, right, bottom, top, znear, zfar, CurrentCamera->isPerspective());


		// Set Infos for cliptrav.
		ClipTrav.Camera = CurrentCamera;
		ClipTrav.setQuadGridClipManager (_QuadGridClipManager);


		// **** For all render traversals, traverse them (except the Hrc one), in ascending order.
		if( doHrcPass )
			HrcTrav.traverse();
		else
			HrcTrav._MovingObjects.clear();

		// Set Cam World Matrix for all trav that need it
		ClipTrav.setCamMatrix(CurrentCamera->getWorldMatrix());
		RenderTrav.setCamMatrix (CurrentCamera->getWorldMatrix());
		LoadBalancingTrav.setCamMatrix (CurrentCamera->getWorldMatrix());

		// clip
		ClipTrav.traverse();

		// animDetail
		AnimDetailTrav.traverse();

		// loadBalance
		LoadBalancingTrav.traverse();

		if (doTrav)
		{
			//
			if (_RequestParticlesAnimate)
			{
				_ParticleSystemManager.processAnimate(_EllapsedTime); // deals with permanently animated particle systems
				_RequestParticlesAnimate = false;
			}
		}

		// Light
		LightTrav.traverse();
	}

	// render
	RenderTrav.traverse(rp, (_RenderedPart == UScene::RenderNothing), doTrav);
	if (!keepTrav)
	{
		// Always must clear shadow caster (if render did not work because of IDriver::isLost())
		RenderTrav.getShadowMapManager().clearAllShadowCasters();
	}

	// render flare
	if (rp & UScene::RenderFlare)
	{
		if (doTrav)
		{
			if (_FirstFlare)
			{
				IDriver *drv = getDriver();
				CFlareModel::updateOcclusionQueryBegin(drv);
				CFlareModel	*currFlare = _FirstFlare;
				do
				{
					currFlare->updateOcclusionQuery(drv);
					currFlare = currFlare->Next;
				}
				while(currFlare);
				CFlareModel::updateOcclusionQueryEnd(drv);
			}
		}
		else
		{
			_FirstFlare = NULL;
		}
	}
	_RenderedPart = (UScene::TRenderPart) (_RenderedPart | rp);
}