Ejemplo n.º 1
0
bool EditorData::loadTrackData(QString fileName)
{
    clearScene();

    m_trackData = TrackIO::open(fileName);
    return static_cast<bool>(m_trackData);
}
Ejemplo n.º 2
0
int main(int argc, const char *argv[])
{
  // Init global server shared memory segment
  init_shared_memory_segment(); 

  // Init shared memory segment for current process's client
  if ((local_memory = init_client_shared_memory(getpid())) == NULL) {
    perror("Can't locate client memory");
    return SHM_CREAT_ERROR;
  }

  if (make_auth() == AUTH_FAIL) {
    printf("Auth error. Check if server is running.\n");
    return AUTH_FAIL;
  }
  
  clearScene();

  do {
    usleep(CLIENT_WAIT);
    if (send_sync_request() == _SYNC_DONE) {
      make_some_job();
    } else {
      printf("There is problem with server connection. Check if server is running.\n");
      return 1;
    }
  } while (1);

  return 0;
}
void LabelToolPlugin::drawRect(QPointF point_a, QPointF point_b)
{
  clearScene();
  drawImage();

  qreal width = point_b.x() - point_a.x();
  qreal height = point_b.y() - point_a.y();
  QPen pen_line(Qt::red);
  pen_line.setWidth(4);
  scene_->addRect(point_a.x(), point_a.y(), width, height, pen_line);
}
Ejemplo n.º 4
0
	// добавл¤ет ?сцен?объект, старый удал¤етьс¤
	void RenderBoxScene::injectObject(const Ogre::String& _meshName, const Ogre::Vector3 & _position, const Ogre::Quaternion & _orientation, const Ogre::Vector3 & _scale)
	{
		clearScene();

		static size_t num = 0;
		mEntity = mScene->createEntity(MyGUI::utility::toString(this, "_RenderBoxMesh_", _meshName, num++), _meshName);
		Ogre::SceneNode * node = mNode->createChildSceneNode(_position, _orientation);
		node->attachObject(mEntity);
	
		updateViewport();
	}
Ejemplo n.º 5
0
	void RenderBoxScene::injectObject( Ogre::Entity* pEnt, const Ogre::Vector3 & _position /*= Ogre::Vector3::ZERO*/, const Ogre::Quaternion & _orientation /*= Ogre::Quaternion::IDENTITY*/, const Ogre::Vector3 & _scale /*= Ogre::Vector3::UNIT_SCALE*/ )
	{
		clearScene();

		static size_t num = 0;
		mEntity = pEnt->clone(pEnt->getName() + "_render_obj_of_gui");
		Ogre::SceneNode * node = mNode->createChildSceneNode(_position, _orientation);
		node->attachObject(mEntity);

		updateViewport();
	}
void
MImRotationAnimation::cancelAnimation()
{
    // disableAnimation() slot is connected to passThruWindowUnmapped()
    // So, in order to be on the safe side. We clean the scene.
    if (rotationAnimationGroup.state() != QAbstractAnimation::Stopped) {
        rotationAnimationGroup.stop();
    }

    damageMonitor->cancel();
    clearScene();

    aboutToChangeReceived = false;
}
void LabelToolPlugin::visualizeImg()
{
  checkIndex();

  std::stringstream ss;
  ss << (current_index_ + 1) << " of " << img_with_polygons_.size();
  ui_.imgShowLabel->setText(QString::fromStdString(ss.str()));

  clearScene();

  drawImgWithPolygon();

  ui_.graphicsView->show();
  ui_.graphicsView->viewport()->repaint();
}
MImRotationAnimation::MImRotationAnimation(QWidget* snapshotWidget) :
        QGraphicsView(new QGraphicsScene()),
        snapshotWidget(snapshotWidget),
        remoteWindow(0),
        animationStartPixmapItem(0),
        animationEndPixmapItem(0),
        startOrientationAngle(0),
        currentOrientationAngle(0),
        aboutToChangeReceived(false),
        damageMonitor(0)
{
    // Animation plays on top of a black backround,
    // covering up the underlying application.
    setBackgroundBrush(QBrush(Qt::black));

    // Get rid of Meegotouch decorations.
    setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);

    // Avoid drawing transparent pixel borders.
    setFrameShape(QFrame::NoFrame);

    // We do not want input focus for that window.
    setAttribute(Qt::WA_X11DoNotAcceptFocus);

    // Avoid a white flicker when popping up our
    // extra window for the animation.
    setAttribute(Qt::WA_NoSystemBackground);
    setAttribute(Qt::WA_OpaquePaintEvent);
    viewport()->setAttribute(Qt::WA_NoSystemBackground);
    viewport()->setAttribute(Qt::WA_OpaquePaintEvent);

    // Remove all animation elements from scene and hide.
    connect(&rotationAnimationGroup, SIGNAL(finished()),
            this, SLOT(clearScene()));

    connect(mApp, SIGNAL(remoteWindowChanged(MImRemoteWindow*)),
            this, SLOT(remoteWindowChanged(MImRemoteWindow*)), Qt::UniqueConnection);

    damageMonitor = new MImDamageMonitor(remoteWindow, this);
    connect(damageMonitor, SIGNAL(damageReceivedOrTimeout()),
            this, SLOT(startAnimation()));

    hide();

    if (mApp) {
        resize(mApp->desktop()->screenGeometry().size());
    }
}
Ejemplo n.º 9
0
void Facade::clearScene()
{
    try
    {
        ClearScene clearScene(this->action);
        clearScene.execute();

        DrawScene drawScene(this->action);
        drawScene.execute();

    }
    catch(BaseException& exc)
    {
        this->alertWindowService->showErrorMessage(exc.what());
    }
}
int FloorMeshAnalizer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: openFloorMesh(); break;
        case 1: openMeshAppearance(); break;
        case 2: clearScene(); break;
        case 3: openPortalLayout(); break;
        case 4: draw2dScene((*reinterpret_cast< FloorMesh*(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 5;
    }
    return _id;
}
Ejemplo n.º 11
0
void Painter::synchronizeScene(Scene *scene)
{
    if (!scene) {
        clearScene();
        return;
    }
    if (!m_sceneRenderer) {
        m_sceneRenderer = new SceneRenderer();
        connect(m_sceneRenderer, &SceneRenderer::initalizationDone, this, &Painter::handleInitializeDone);
    }
    delete m_camera;
    m_camera = new Camera(*scene->camera());

    delete m_previewCamera;
    m_previewCamera = new Camera(*scene->previewCamera());

    m_sceneRenderer->synchronizeGeometries(scene->geometries());
    m_sceneRenderer->synchronizeLightRays(scene->rootLightRay());
}
void
MImRotationAnimation::appOrientationChangeFinished(int toAngle) {
    qDebug() << __PRETTY_FUNCTION__ << " - toAngle: " << toAngle
            << " startOrientationAngle: " << startOrientationAngle;

    currentOrientationAngle = toAngle;

    if (!mApp->passThruWindow()->isVisible()
        || toAngle == startOrientationAngle
        || !aboutToChangeReceived) {
        clearScene();
        aboutToChangeReceived = false;
        return;
    }

    setupAnimation(startOrientationAngle, toAngle);

    damageMonitor->waitForDamage();
}
Ejemplo n.º 13
0
	void RenderBoxScene::destroy()
	{
		clearScene();

		if (mCanvas)
		{
			frameAdvise(false);

			mCanvas->eventMouseDrag = nullptr;
			mCanvas->eventMouseButtonPressed = nullptr;
			mCanvas->eventMouseButtonReleased = nullptr;

			Ogre::Root* root = Ogre::Root::getSingletonPtr();
			if (root && mScene)
				root->destroySceneManager(mScene);
			mScene= nullptr;
		}

		RenderBox::destroy();
	}
Ejemplo n.º 14
0
	void RenderBoxWrap::injectSceneNode(Ogre::SceneManager * _manager, Ogre::SceneNode* _sceneNode)
	{

		// очищаем
		clearScene();

		mSceneManagerForSync = _manager;

		// проверка сцен нода на валидность
		if (!checkSceneNode(_manager->getRootSceneNode(), _sceneNode)) {
			MYGUI_LOG(Error, "scene node " << _sceneNode << " was deleted");
			return;
		}

		Ogre::SceneNode * node = mNode->createChildSceneNode();

		synchronizeSceneNode(node, _sceneNode);

		mNodeForSync = _sceneNode;

		updateViewport();
	}
Ejemplo n.º 15
0
void EditorData::setTrackData(TrackDataPtr trackData)
{
    clearScene();

    m_trackData = trackData;
}
Ejemplo n.º 16
0
 /* load the file, parse the text, add the elements */
bool Scene::loadFile (std::string filename) {
    std::ifstream fs;
    fs.open (filename);
    if (!fs.is_open ()) {
        fs.close ();
        return false;
    }

    clearScene();

    int vertNum = 0;
    int lineNum = 0;
    int angleNum = 0;
    int fanoNum = 0;

    Vertex * newVerts[1024];
    Line * newLines[1024];

    int vertIdx = 0;
    int lineIdx = 0;

    std::cout<< "Reading in file " << filename << std::endl;
    std::string line;
    while(std::getline(fs, line)){

      //line that includes data
      if(line.length() > 0 && (line.at(0) == 'V' || line.at(0) == 'v')){
        char *copyLine = (char*)line.c_str();
        char *token;
        token = strtok(copyLine, " ,");
        token = strtok(NULL, " ,");
        float x, y, z;
        x = atof(token);
        token = strtok(NULL, " ,");
        y = atof(token);
        token = strtok(NULL, " ,");
        z = atof(token);

        if(vertIdx == 0)
          newVerts[vertIdx++] = addVertex3f(x, y, z, 1);
        else
          newVerts[vertIdx++] = addVertex3f(x, y, z, 0);
      }
      else if(line.length() > 0 && (line.at(0) == 'L' || line.at(0) == 'l')){
        char *copyLine = (char*)line.c_str();
        char *token;
        token = strtok(copyLine, " ,");
        token = strtok(NULL, " ,");
        int v1, v2;
        v1 = atoi(token);
        token = strtok(NULL, " ,");
        v2 = atoi(token);

        newLines[lineIdx++] = createLine(newVerts[v1], newVerts[v2]);
      }
      else if(line.length() > 0 && (line.at(0) == 'A' || line.at(0) == 'a')){
        char *copyLine = (char*)line.c_str();
        char *token;
        token = strtok(copyLine, " ,");
        token = strtok(NULL, " ,");
        int l1, l2;
        l1 = atoi(token);
        token = strtok(NULL, " ,");
        l2 = atoi(token);
        createAngle(newLines[l1], newLines[l2]);
      }
      else if(line.length() > 0 && (line.at(0) == 'F' || line.at(0) == 'f')){
        char *copyLine = (char*)line.c_str();
        char *token;
        token = strtok(copyLine, " ,");
        token = strtok(NULL, " ,");
        int a1, a2, a3;
        a1 = atoi(token);
        token = strtok(NULL, " ,");
        a2 = atoi(token);
        token = strtok(NULL, " ,");
        a3 = atoi(token);
        createFano(newLines[a1], newLines[a2], newLines[a3]);
      }
      else if(line.length()>0 && (line.at(0)=='C' || line.at(0)=='c')){
        char *copyLine = (char*)line.c_str();
        char *token;
        token = strtok(copyLine, " ,");
        token = strtok(NULL, " ,");
        int l;
        float r, g, b;
        l = atoi(token);
        token = strtok(NULL, " ,");
        r = atof(token);
        token = strtok(NULL, " ,");
        g = atof(token);
        token = strtok(NULL, " ,");
        b = atof(token);
        Line *a = newLines[l];
        a->setColor3f(r,g,b);
      }
      
    }

    //...
    return true;
}
Ejemplo n.º 17
0
void Screen::rollCredits() {
	uint32 loopingMusicId = _vm->_sound->getLoopingMusicId();

	// Prepare for the credits by fading down, stoping the music, etc.

	_vm->_mouse->setMouse(0);

	_vm->_sound->muteFx(true);
	_vm->_sound->muteSpeech(true);

	waitForFade();
	fadeDown();
	waitForFade();

	_vm->_mouse->closeMenuImmediately();

	// There are three files which I believe are involved in showing the
	// credits:
	//
	// credits.bmp  - The "Smacker" logo, stored as follows:
	//
	//     width     2 bytes, little endian
	//     height    2 bytes, little endian
	//     palette   3 * 256 bytes
	//     data      width * height bytes
	//
	//     Note that the maximum colour component in the palette is 0x3F.
	//     This is the same resolution as the _paletteMatch table. I doubt
	//     that this is a coincidence, but let's use the image palette
	//     directly anyway, just to be safe.
	//
	// credits.clu  - The credits text (credits.txt in PSX version)
	//
	//     This is simply a text file with CRLF line endings.
	//     '^' is not shown, but used to mark the center of the line.
	//     '@' is used as a placeholder for the "Smacker" logo. At least
	//     when it appears alone.
	//     Remaining lines are centered.
	//     The German version also contains character code 9 for no
	//     apparent reason. We ignore them.
	//
	// fonts.clu    - The credits font?
	//
	//     FIXME: At this time I don't know how to interpret fonts.clu. For
	//     now, let's just the standard speech font instead.

	SpriteInfo spriteInfo;
	Common::File f;
	int i;

	spriteInfo.isText = false;

	// Read the "Smacker" logo

	uint16 logoWidth = 0;
	uint16 logoHeight = 0;
	byte *logoData = NULL;
	byte palette[256 * 3];

	if (f.open("credits.bmp")) {
		logoWidth = f.readUint16LE();
		logoHeight = f.readUint16LE();

		for (i = 0; i < 256; i++) {
			palette[i * 3 + 0] = f.readByte() << 2;
			palette[i * 3 + 1] = f.readByte() << 2;
			palette[i * 3 + 2] = f.readByte() << 2;
		}

		logoData = (byte *)malloc(logoWidth * logoHeight);

		f.read(logoData, logoWidth * logoHeight);
		f.close();
	} else {
		warning("Can't find credits.bmp");
		memset(palette, 0, sizeof(palette));
		palette[14 * 3 + 0] = 252;
		palette[14 * 3 + 1] = 252;
		palette[14 * 3 + 2] = 252;
	}

	setPalette(0, 256, palette, RDPAL_INSTANT);

	// Read the credits text

	Common::Array<CreditsLine *> creditsLines;

	int lineCount = 0;
	int lineTop = 400;
	int paragraphStart = 0;
	bool hasCenterMark = false;

	if (Sword2Engine::isPsx()) {
		if (!f.open("credits.txt")) {
			warning("Can't find credits.txt");

			free(logoData);
			return;
		}
	} else {
		if (!f.open("credits.clu")) {
			warning("Can't find credits.clu");

			free(logoData);
			return;
		}
	}

	while (1) {
		char buffer[80];
		char *line = f.readLine(buffer, sizeof(buffer));

		if (line) {
			// Replace invalid character codes prevent the 'dud'
			// symbol from showing up in the credits.

			for (byte *ptr = (byte *)line; *ptr; ptr++) {
				switch (*ptr) {
				case 9:
					// The German credits contain these.
					// Convert them to spaces.
					*ptr = 32;
					break;
				case 10:
					// LF is treated as end of line.
					*ptr = 0;
					break;
				case 170:
					// The Spanish credits contain these.
					// Convert them to periods.
					*ptr = '.';
				default:
					break;
				}
			}
		}

		if (!line || *line == 0) {
			if (!hasCenterMark) {
				for (i = paragraphStart; i < lineCount; i++)
					creditsLines[i]->type = LINE_CENTER;
			}
			paragraphStart = lineCount;
			hasCenterMark = false;
			if (paragraphStart == lineCount)
				lineTop += CREDITS_LINE_SPACING;

			if (!line)
				break;

			continue;
		}

		char *center_mark = strchr(line, '^');

		if (center_mark) {
			// The current paragraph has at least one center mark.
			hasCenterMark = true;

			if (center_mark != line) {
				creditsLines.push_back(new CreditsLine);

				// The center mark is somewhere inside the
				// line. Split it into left and right side.
				*center_mark = 0;

				creditsLines[lineCount]->top = lineTop;
				creditsLines[lineCount]->height = CREDITS_FONT_HEIGHT;
				creditsLines[lineCount]->type = LINE_LEFT;
				creditsLines[lineCount]->str = strdup(line);

				lineCount++;
				*center_mark = '^';
			}

			line = center_mark;
		}

		creditsLines.push_back(new CreditsLine);

		creditsLines[lineCount]->top = lineTop;

		if (*line == '^') {
			creditsLines[lineCount]->type = LINE_RIGHT;
			line++;
		} else
			creditsLines[lineCount]->type = LINE_LEFT;

		if (strcmp(line, "@") == 0) {
			creditsLines[lineCount]->height = logoHeight;
			lineTop += logoHeight;
		} else {
			creditsLines[lineCount]->height = CREDITS_FONT_HEIGHT;
			lineTop += CREDITS_LINE_SPACING;
		}

		creditsLines[lineCount]->str = strdup(line);
		lineCount++;
	}

	f.close();

	// We could easily add some ScummVM stuff to the credits, if we wanted
	// to. On the other hand, anyone with the attention span to actually
	// read all the credits probably already knows. :-)

	// Start the music and roll the credits

	// The credits music (which can also be heard briefly in the "carib"
	// cutscene) is played once.

	_vm->_sound->streamCompMusic(309, false);

	clearScene();
	fadeUp(0);

	spriteInfo.scale = 0;
	spriteInfo.scaledWidth = 0;
	spriteInfo.scaledHeight = 0;
	spriteInfo.type = RDSPR_DISPLAYALIGN | RDSPR_NOCOMPRESSION | RDSPR_TRANS;
	spriteInfo.blend = 0;

	int startLine = 0;
	int scrollPos = 0;

	bool abortCredits = false;

	int scrollSteps = lineTop + CREDITS_FONT_HEIGHT;
	uint32 musicStart = getTick();

	// Ideally the music should last just a tiny bit longer than the
	// credits. Note that musicTimeRemaining() will return 0 if the music
	// is muted, so we need a sensible fallback for that case.

	uint32 musicLength = MAX((int32)(1000 * (_vm->_sound->musicTimeRemaining() - 3)), 25 * (int32)scrollSteps);

	while (scrollPos < scrollSteps && !_vm->shouldQuit()) {
		clearScene();

		for (i = startLine; i < lineCount; i++) {
			if (!creditsLines[i])
				continue;

			// Free any sprites that have scrolled off the screen

			if (creditsLines[i]->top + creditsLines[i]->height < scrollPos) {
				debug(2, "Freeing line %d: '%s'", i, creditsLines[i]->str);

				delete creditsLines[i];
				creditsLines[i] = NULL;

				startLine = i + 1;
			} else if (creditsLines[i]->top < scrollPos + 400) {
				if (!creditsLines[i]->sprite) {
					debug(2, "Creating line %d: '%s'", i, creditsLines[i]->str);
					creditsLines[i]->sprite = _vm->_fontRenderer->makeTextSprite((byte *)creditsLines[i]->str, 600, 14, _vm->_speechFontId, 0);
				}

				FrameHeader frame;

				frame.read(creditsLines[i]->sprite);

				spriteInfo.y = creditsLines[i]->top - scrollPos;
				spriteInfo.w = frame.width;
				spriteInfo.h = frame.height;
				spriteInfo.data = creditsLines[i]->sprite + FrameHeader::size();
				spriteInfo.isText = true;

				switch (creditsLines[i]->type) {
				case LINE_LEFT:
					spriteInfo.x = RENDERWIDE / 2 - 5 - frame.width;
					break;
				case LINE_RIGHT:
					spriteInfo.x = RENDERWIDE / 2 + 5;
					break;
				case LINE_CENTER:
					if (strcmp(creditsLines[i]->str, "@") == 0) {
						spriteInfo.data = logoData;
						spriteInfo.x = (RENDERWIDE - logoWidth) / 2;
						spriteInfo.w = logoWidth;
						spriteInfo.h = logoHeight;
					} else
						spriteInfo.x = (RENDERWIDE - frame.width) / 2;
					break;
				}

				if (spriteInfo.data)
					drawSprite(&spriteInfo);
			} else
				break;
		}

		updateDisplay();

		KeyboardEvent *ke = _vm->keyboardEvent();

		if (ke && ke->kbd.keycode == Common::KEYCODE_ESCAPE) {
			if (!abortCredits) {
				abortCredits = true;
				fadeDown();
			}
		}

		if (abortCredits && getFadeStatus() == RDFADE_BLACK)
			break;

		_vm->sleepUntil(musicStart + (musicLength * scrollPos) / scrollSteps + _pauseTicks);
		scrollPos++;
	}

	// We're done. Clean up and try to put everything back where it was
	// before the credits.

	for (i = 0; i < lineCount; i++) {
		delete creditsLines[i];
	}

	free(logoData);

	if (!abortCredits) {
		fadeDown();

		// The music should either have stopped or be about to stop, so
		// wait for it to really happen.

		while (_vm->_sound->musicTimeRemaining() && !_vm->shouldQuit()) {
			updateDisplay(false);
			_vm->_system->delayMillis(100);
		}
	}

	if (_vm->shouldQuit())
		return;

	waitForFade();

	_vm->_sound->muteFx(false);
	_vm->_sound->muteSpeech(false);

	if (loopingMusicId)
		_vm->_sound->streamCompMusic(loopingMusicId, true);
	else
		_vm->_sound->stopMusic(false);

	if (!_vm->_mouse->getMouseStatus() || _vm->_mouse->isChoosing())
		_vm->_mouse->setMouse(NORMAL_MOUSE_ID);

	if (_vm->_logic->readVar(DEAD))
		_vm->_mouse->buildSystemMenu();
}
Ejemplo n.º 18
0
void Screen::displayMsg(byte *text, int time) {
	byte pal[256 * 3];
	byte oldPal[256 * 3];

	debug(2, "DisplayMsg: %s", text);

	if (getFadeStatus() != RDFADE_BLACK) {
		fadeDown();
		waitForFade();
	}

	_vm->_mouse->setMouse(0);
	_vm->_mouse->setLuggage(0);
	_vm->_mouse->closeMenuImmediately();

	clearScene();

	byte *text_spr = _vm->_fontRenderer->makeTextSprite(text, 640, 187, _vm->_speechFontId);

	FrameHeader frame;

	frame.read(text_spr);

	SpriteInfo spriteInfo;

	spriteInfo.x = _screenWide / 2 - frame.width / 2;
	if (!time)
		spriteInfo.y = _screenDeep / 2 - frame.height / 2 - MENUDEEP;
	else
		spriteInfo.y = 400 - frame.height;
	spriteInfo.w = frame.width;
	spriteInfo.h = frame.height;
	spriteInfo.scale = 0;
	spriteInfo.scaledWidth = 0;
	spriteInfo.scaledHeight	= 0;
	spriteInfo.type = RDSPR_DISPLAYALIGN | RDSPR_NOCOMPRESSION | RDSPR_TRANS;
	spriteInfo.blend = 0;
	spriteInfo.data = text_spr + FrameHeader::size();
	spriteInfo.colourTable = 0;
	spriteInfo.isText = true;

	uint32 rv = drawSprite(&spriteInfo);
	if (rv)
		error("Driver Error %.8x (in DisplayMsg)", rv);

	memcpy(oldPal, _palette, sizeof(oldPal));
	memset(pal, 0, sizeof(pal));

	pal[187 * 3 + 0] = 255;
	pal[187 * 3 + 1] = 255;
	pal[187 * 3 + 2] = 255;

	setPalette(0, 256, pal, RDPAL_FADE);
	fadeUp();
	free(text_spr);
	waitForFade();

	if (time > 0) {
		uint32 targetTime = _vm->_system->getMillis() + (time * 1000);
		_vm->sleepUntil(targetTime);
	} else {
		while (!_vm->shouldQuit()) {
			MouseEvent *me = _vm->mouseEvent();
			if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN)))
				break;

			if (_vm->keyboardEvent())
				break;

			updateDisplay();
			_vm->_system->delayMillis(50);
		}
	}

	fadeDown();
	waitForFade();
	clearScene();
	setPalette(0, 256, oldPal, RDPAL_FADE);
	fadeUp();
}
Ejemplo n.º 19
0
Scene::~Scene(void)
{	
	clearScene();
}
Ejemplo n.º 20
0
	Scene::~Scene() {
		clearScene();
	}
Ejemplo n.º 21
0
void koregui::SceneViewer::showScene(kore::SceneNode* root) {
  clearScene();
  createNode(root, 0,0);
}
Ejemplo n.º 22
0
koregui::SceneViewer::~SceneViewer() {
  clearScene();
}
Ejemplo n.º 23
0
void GraphScene::load(){
    clearScene();

    QString fileName =
        QFileDialog::getOpenFileName(nullptr,
            tr("Open Flow Scene"),
            QDir::homePath(),
            tr("Flow Scene Files (*.json)"));

    if (!QFileInfo::exists(fileName))
        return;
    std::ifstream ifs(fileName.toStdString());
    std::map<std::string, std::string> _vm, _sm;
    std::map<std::string, std::string>& vm = this->vm ? *this->vm : _vm;
    std::map<std::string, std::string>& sm = this->sm ? *this->sm : _sm;

    aq::JSONInputArchive ar(ifs, vm, sm);
    aq::IDataStream::VariableMap defaultVM, defaultSM;
    
    std::stringstream currentDate;
    boost::posix_time::ptime timeLocal = boost::posix_time::second_clock::local_time();
    currentDate << timeLocal.date().year() << "-" << std::setfill('0') << std::setw(2) << timeLocal.date().month().as_number() << "-" << std::setfill('0') << std::setw(2) << timeLocal.date().day().as_number();
    sm["${date}"] = currentDate.str();
    sm["${hostname}"] = boost::asio::ip::host_name();
    currentDate.str(std::string());
    currentDate << std::setfill('0') << std::setw(2) << timeLocal.time_of_day().hours() << std::setfill('0') << std::setw(2) << timeLocal.time_of_day().minutes();
    sm["${hour}"] = currentDate.str();
    sm["${pid}"] = boost::lexical_cast<std::string>(boost::log::aux::this_process::get_id());
    sm["${config_file_dir}"] = boost::filesystem::path(fileName.toStdString()).parent_path().string();
    
    
    ar(cereal::make_optional_nvp("DefaultVariables", defaultVM, defaultVM));
    ar(cereal::make_optional_nvp("DefaultStrings", defaultSM, defaultSM));
    for (const auto& pair : defaultVM) {
        if (vm.count(pair.first) == 0)
            vm[pair.first] = pair.second;
    }
    for (const auto& pair : defaultSM) {
        if (sm.count("${" + pair.first + "}") == 0)
            sm["${" + pair.first + "}"] = pair.second;
    }
    if (sm.size()) {
        std::stringstream ss;
        for (const auto& pair : sm)
            ss << "\n"
               << pair.first << " = " << pair.second;
        MO_LOG(debug) << "Used string replacements: " << ss.str();
    }

    if (vm.size()) {
        std::stringstream ss;
        for (const auto& pair : vm)
            ss << "\n"
               << pair.first << " = " << pair.second;
        MO_LOG(debug) << "Used variable replacements: " << ss.str();
    }
    auto dsvec = aq::IDataStream::load(ar);
    for(auto& ds : dsvec){
        load(ds);
    }
    std::map<std::string, cv::Vec2f> node_position_map;
    ar(cereal::make_optional_nvp("ui_node_positions", node_position_map, node_position_map));
    for (auto node_itr = this->_nodes.begin(); node_itr != this->_nodes.end(); ++node_itr) {
        if (auto node_proxy = dynamic_cast<aq::NodeProxy*>(node_itr->second->nodeDataModel())) {
            auto itr = node_position_map.find(node_proxy->m_obj->getTreeName());
            if(itr != node_position_map.end()){
                node_itr->second->nodeGraphicsObject().setPos(itr->second.val[0], itr->second.val[1]);
            }
        }
        if (auto fg_proxy = dynamic_cast<aq::FrameGrabberProxy*>(node_itr->second->nodeDataModel())) {
            auto itr = node_position_map.find(fg_proxy->m_obj->getTreeName());
            if (itr != node_position_map.end()) {
                node_itr->second->nodeGraphicsObject().setPos(itr->second.val[0], itr->second.val[1]);
            }
        }
    }
    for(auto& connection : this->_connections){
        connection.second->getConnectionGraphicsObject().move();
    }
}
Ejemplo n.º 24
0
void Scene::openFromPWB(const char *fileName)
{
    clearScene();
    loadFromPWB(fileName);
}
void LabelToolPlugin::drawQtPolygon(bool connect)
{
  //delete everything from scene
  clearScene();

  // add img to scene
  if(!img_with_polygons_.empty())
    drawImage();



  if(selected_points_.size() == 1)
  {
    // draw point
    double rad = 1;
    QPen pen(Qt::blue);
    QBrush brush(Qt::SolidPattern);
    scene_->addEllipse(selected_points_[0].x() - rad,
        selected_points_[0].y() - rad ,
        rad * 5.0, rad * 5.0, pen, brush);
  }
  else
  {
    if(!connect)
    {
      QPen pen_point(Qt::blue);
      QBrush brush_point(Qt::SolidPattern);
      QPen pen_line(Qt::red);
      pen_line.setWidth(4);

      double rad = 1;
      for(int idx = 0; idx < (selected_points_.size() - 1); idx++)
      {
        scene_->addEllipse(selected_points_[idx].x() - rad,
                           selected_points_[idx].y() - rad ,
                           rad * 5.0, rad * 5.0, pen_point, brush_point);
        scene_->addLine(selected_points_[idx].x(), selected_points_[idx].y(),
                        selected_points_[idx + 1].x(), selected_points_[idx + 1].y(),
            pen_line);
      }
      scene_->addEllipse(selected_points_[selected_points_.size() - 1].x() - rad,
          selected_points_[selected_points_.size() - 1].y() - rad ,
          rad * 5.0, rad * 5.0, pen_point, brush_point);

    }
    else
    {
      QPen pen_line(Qt::green);
      pen_line.setWidth(4);
      for(int idx = 0; idx < (selected_points_.size() - 1); idx++)
      {
        scene_->addLine(selected_points_[idx].x(), selected_points_[idx].y(),
                        selected_points_[idx + 1].x(), selected_points_[idx + 1].y(),
            pen_line);
      }
      scene_->addLine(selected_points_[0].x(), selected_points_[0].y(),
          selected_points_[selected_points_.size() - 1].x(), selected_points_[selected_points_.size() - 1].y(),
          pen_line);
    }
  }

  ui_.graphicsView->show();
  ui_.graphicsView->viewport()->repaint();
}