Ejemplo n.º 1
0
void RoutePresenter::show()
{
    m_treeWidget->clear();

    QTreeWidgetItem* requestTop = new QTreeWidgetItem(m_treeWidget);
    requestTop->setText(0, "request");

    QTreeWidgetItem* modesItem = new QTreeWidgetItem(requestTop);
    modesItem->setText(0, "modes");
    showModes(modesItem, m_routeReply->request(), m_routeReply->request().travelModes());

    QTreeWidgetItem* waypointsItem = new QTreeWidgetItem(requestTop);
    waypointsItem->setText(0, "waypoints");
    waypointsItem->setText(1, QString().setNum(m_routeReply->request().waypoints().length()));
    showPoints(waypointsItem, m_routeReply->request().waypoints());

    QTreeWidgetItem* excludesItem = new QTreeWidgetItem(requestTop);
    excludesItem->setText(0, "exclude areas");
    excludesItem->setText(1, QString().setNum(m_routeReply->request().excludeAreas().length()));
    for (int i = 0; i < m_routeReply->request().excludeAreas().length(); ++i)
        showBoundingBox(excludesItem, m_routeReply->request().excludeAreas().at(i));

    QTreeWidgetItem* alternativesItem = new QTreeWidgetItem(requestTop);
    alternativesItem->setText(0, "alternatives");
    alternativesItem->setText(1, QString().setNum(m_routeReply->request().numberAlternativeRoutes()));

    showRoutes();
}
Ejemplo n.º 2
0
void BoundingBoxDialog::toggle(ModelWindow *modelWindow)
{
	setModelWindow(modelWindow);
	if (hWindow == NULL)
	{
		HWND hParentWnd = GetParent(modelWindow->getHWindow());

		createDialog(IDD_BOUNDING_BOX, hParentWnd);
	}
	if (IsWindowVisible(hWindow))
	{
		ShowWindow(hWindow, SW_HIDE);
		showBoundingBox(false);
	}
	else
	{
		ShowWindow(hWindow, SW_SHOW);
		showBoundingBox(true);
	}
}
Ejemplo n.º 3
0
//-------------------------------------------------------
void Ground::LoadFromHeightMap(std::shared_ptr<Ogre::Image> hmap, Ogre::SceneNode* parentNode)
{
    mImage = hmap;
    Ogre::Box box = Ogre::Box(0, 0, mImage->getWidth(), mImage->getHeight());

    mRootNode = parentNode->createChildSceneNode();
    
    mGlobalBoundingBox.setNull();

    Ogre::Material* groundMaterial = CreateGroundMaterialTextured("Material/" + CLASS_NAME + "/Textured", mImage.get());
    
    static const float VERTEX_STEP = 1.0f;
    static const float HEIGHT_STEP = 8.0f;

    float offsetX = GROUND_SIZE * VERTEX_STEP / 2.0f;
    float offsetY = GROUND_SIZE * VERTEX_STEP / 2.0f;

    size_t width  = mImage->getWidth();
    size_t height = mImage->getHeight();

    float texStep = 1.0f / REGIONS_NUMBER;

    size_t texRegionWidth  = static_cast<size_t>(std::ceil(static_cast<float>(width) / REGIONS_NUMBER));
    size_t texRegionHeight = static_cast<size_t>(std::ceil(static_cast<float>(height) / REGIONS_NUMBER));
    for (size_t y = 0; y < REGIONS_NUMBER; ++y)
    {
        size_t top = y * texRegionHeight;
        for (size_t x = 0; x < REGIONS_NUMBER; ++x)
        {
            size_t left = x * texRegionWidth;
            Ogre::Box roi = Ogre::Box(left, height - std::min(top + texRegionHeight + 1, height), std::min(left + texRegionWidth + 1, width), height - top);
                
            Ogre::MeshPtr mesh = CreateRegion(y * REGIONS_NUMBER + x, groundMaterial->getName(), roi,
                Ogre::Vector3(x * VERTEX_STEP * REGION_SIZE - offsetX, y * VERTEX_STEP * REGION_SIZE - offsetY, 0.0f),
                Ogre::Vector3(VERTEX_STEP, VERTEX_STEP, HEIGHT_STEP),
                Ogre::Vector2(x * texStep, 1.0f - (y + 1) * texStep));

            Ogre::Entity* entity = mSceneManager->createEntity(mesh);
            
            auto node = mRootNode->createChildSceneNode();
            node->attachObject(entity);
            node->showBoundingBox(true);

            mGlobalBoundingBox.merge(entity->getBoundingBox());

            mEntities.push_back(entity);
        }
    }
}
Ejemplo n.º 4
0
void RoutePresenter::showRoute(QTreeWidgetItem* top, const QGeoRoute& route)
{
    QTreeWidgetItem* routeItem = new QTreeWidgetItem(top);
    routeItem->setText(0, "route");

    QTreeWidgetItem* idItem = 0;
    if (!route.routeId().isEmpty()) {
        idItem = new QTreeWidgetItem(routeItem);
        idItem->setText(0, "id");
        idItem->setText(1, route.routeId());
    }

    QTreeWidgetItem* modeItem = new QTreeWidgetItem(routeItem);
    modeItem->setText(0, "mode");
    showModes(modeItem, route.request(), route.travelMode());

    QTreeWidgetItem* distanceItem = new QTreeWidgetItem(routeItem);
    distanceItem->setText(0, "distance");
    distanceItem->setText(1, QString().setNum(route.distance()));

    showBoundingBox(routeItem, route.bounds());

    QTreeWidgetItem* wayPointsItem = new QTreeWidgetItem(routeItem);
    QString overviewLabel = "overview";
    if (route.path().count() > 100)
        overviewLabel += "(100)";
    wayPointsItem->setText(0, overviewLabel);
    showPoints(wayPointsItem, route.path());

    QList<QGeoRouteSegment> segments;
    QGeoRouteSegment segment = route.firstRouteSegment();
    while (segment.isValid()) {
        segments << segment;
        segment = segment.nextRouteSegment();
    }

    QTreeWidgetItem* segmentsItem = new QTreeWidgetItem(routeItem);
    QString segmentsLabel = "segments";
    if (segments.length() > 100)
        segmentsLabel += "(100)";

    segmentsItem->setText(0, segmentsLabel);

    segmentsItem->setText(1, QString().setNum(segments.length()));
    for (int i = 0; i < segments.length() && i < 100; ++i) {
        showRouteSegment(segmentsItem, segments[i]);
    }
}
Ejemplo n.º 5
0
void display()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();

  // camera parameters are Phi, Theta, R
  gluLookAt(R * cos(Phi) * cos (Theta), R * sin (Theta), R * sin(Phi) * cos (Theta),
	        0.0,0.0,0.0, 0.0,1.0,0.0);
	

  /* Lighting */
  /* You are encouraged to change lighting parameters or make improvements/modifications
     to the lighting model . 
     This way, you will personalize your assignment and your assignment will stick out. 
  */

  // global ambient light
  GLfloat aGa[] = { 0.0, 0.0, 0.0, 0.0 };
  
  // light 's ambient, diffuse, specular
  GLfloat lKa0[] = { 0.0, 0.0, 0.0, 1.0 };
  GLfloat lKd0[] = { 1.0, 1.0, 1.0, 1.0 };
  GLfloat lKs0[] = { 1.0, 1.0, 1.0, 1.0 };

  GLfloat lKa1[] = { 0.0, 0.0, 0.0, 1.0 };
  GLfloat lKd1[] = { 1.0, 0.0, 0.0, 1.0 };
  GLfloat lKs1[] = { 1.0, 0.0, 0.0, 1.0 };

  GLfloat lKa2[] = { 0.0, 0.0, 0.0, 1.0 };
  GLfloat lKd2[] = { 1.0, 1.0, 0.0, 1.0 };
  GLfloat lKs2[] = { 1.0, 1.0, 0.0, 1.0 };

  GLfloat lKa3[] = { 0.0, 0.0, 0.0, 1.0 };
  GLfloat lKd3[] = { 0.0, 1.0, 1.0, 1.0 };
  GLfloat lKs3[] = { 0.0, 1.0, 1.0, 1.0 };

  GLfloat lKa4[] = { 0.0, 0.0, 0.0, 1.0 };
  GLfloat lKd4[] = { 0.0, 0.0, 1.0, 1.0 };
  GLfloat lKs4[] = { 0.0, 0.0, 1.0, 1.0 };

  GLfloat lKa5[] = { 0.0, 0.0, 0.0, 1.0 };
  GLfloat lKd5[] = { 1.0, 0.0, 1.0, 1.0 };
  GLfloat lKs5[] = { 1.0, 0.0, 1.0, 1.0 };

  GLfloat lKa6[] = { 0.0, 0.0, 0.0, 1.0 };
  GLfloat lKd6[] = { 1.0, 1.0, 1.0, 1.0 };
  GLfloat lKs6[] = { 1.0, 1.0, 1.0, 1.0 };

  GLfloat lKa7[] = { 0.0, 0.0, 0.0, 1.0 };
  GLfloat lKd7[] = { 0.0, 1.0, 1.0, 1.0 };
  GLfloat lKs7[] = { 0.0, 1.0, 1.0, 1.0 };

  // light positions and directions
  GLfloat lP0[] = { -1.999, -1.999, -1.999, 1.0 };
  GLfloat lP1[] = { 1.999, -1.999, -1.999, 1.0 };
  GLfloat lP2[] = { 1.999, 1.999, -1.999, 1.0 };
  GLfloat lP3[] = { -1.999, 1.999, -1.999, 1.0 };
  GLfloat lP4[] = { -1.999, -1.999, 1.999, 1.0 };
  GLfloat lP5[] = { 1.999, -1.999, 1.999, 1.0 };
  GLfloat lP6[] = { 1.999, 1.999, 1.999, 1.0 };
  GLfloat lP7[] = { -1.999, 1.999, 1.999, 1.0 };
  
  // jelly material color

  GLfloat mKa[] = { 0.0, 0.0, 0.0, 1.0 };
  GLfloat mKd[] = { 0.3, 0.3, 0.3, 1.0 };
  GLfloat mKs[] = { 1.0, 1.0, 1.0, 1.0 };
  GLfloat mKe[] = { 0.0, 0.0, 0.0, 1.0 };

  /* set up lighting */
  glLightModelfv(GL_LIGHT_MODEL_AMBIENT, aGa);
  glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
  glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);

  // set up cube color
  glMaterialfv(GL_FRONT, GL_AMBIENT, mKa);
  glMaterialfv(GL_FRONT, GL_DIFFUSE, mKd);
  glMaterialfv(GL_FRONT, GL_SPECULAR, mKs);
  glMaterialfv(GL_FRONT, GL_EMISSION, mKe);
  glMaterialf(GL_FRONT, GL_SHININESS, 120);
    
  // macro to set up light i
  #define LIGHTSETUP(i)\
  glLightfv(GL_LIGHT##i, GL_POSITION, lP##i);\
  glLightfv(GL_LIGHT##i, GL_AMBIENT, lKa##i);\
  glLightfv(GL_LIGHT##i, GL_DIFFUSE, lKd##i);\
  glLightfv(GL_LIGHT##i, GL_SPECULAR, lKs##i);\
  glEnable(GL_LIGHT##i)
  
  LIGHTSETUP (0);
  LIGHTSETUP (1);
  LIGHTSETUP (2);
  LIGHTSETUP (3);
  LIGHTSETUP (4);
  LIGHTSETUP (5);
  LIGHTSETUP (6);
  LIGHTSETUP (7);

  // enable lighting
  glEnable(GL_LIGHTING);    
  glEnable(GL_DEPTH_TEST);

  // show the cube
  //showCube(&jello);

  glDisable(GL_LIGHTING);

  // show the bounding box
  showBoundingBox();

  // show Circle and Chain
  showCircle();
  showChain(&jello);
	
  showText(&jello);
 
  glutSwapBuffers();
}
Ejemplo n.º 6
0
LRESULT BoundingBoxDialog::doClose(void)
{
	showWindow(SW_HIDE);
	showBoundingBox(false);
	return 0;
}