Пример #1
0
int main(int argc, char** argv)
{

    if (argc < 2) {
        std::cerr << "Demo requires a map image" << std::endl;
        return -1;
    }

    Planner::Config pc;
    pc.graph_search = graph_search::a_star();
    pc.graph_builder = graph_builder::probabilistic(100);
    pc.interpolator = interpolator::none();

    Planner p(pc);
    Workspace ws;
    ws.map = load_map_from_image(argv[1]);
    p.load_workspace(ws);

    ProblemDefinition pdef;
    pdef.start = mark_point(ws);
    pdef.goal = Point(400, 400);

    Path path = p.solve(pdef);

    View v;
    v.add_layer(p);
    v.add_layer(pdef);
    v.add_layer(path);
    View::stay();

    v.save();

    return 0;
}
Пример #2
0
fCoord ViewBody::globalPos() const
{
	fCoord ret = geometry().pos();
	for (View p = parent(); p; p = p->parent())
		ret += p->geometry().pos();
	return ret;
}
Пример #3
0
void CameraObject::DrawLine( double x1, double y1, double x2, double y2, double color[4] )
{
    double start[3];
    start[0] = x1;
    start[1] = y1;
    start[2] = zMin;
    double end[3];
    end[0] = x2;
    end[1] = y2;
    end[2] = zMin;

    PerViewElementCont::iterator it = m_perViewElements.begin();
    while( it != m_perViewElements.end() )
    {
        View * v = (*it).first;
        if( v->GetType() == THREED_VIEW_TYPE )
        {
            vtkProp3D * line = SimplePropCreator::CreateLine( start, end, color );
            line->SetUserTransform( m_imageTransform );
            GetCurrentRenderer(v)->AddViewProp( line );
            PerViewElements & elem = (*it).second;
            elem.anotations.push_back( line );
        }
        ++it;
    }
}
Пример #4
0
void Game::setZoom(){
	View camara;

	camara.setSize(100.0f, 100.0f);
	camara.setCenter(50.0f, 50.0f);
	pWnd->setView(camara);
}
Пример #5
0
void PolyDataObject::SetTexture( vtkImageData * texImage )
{
    // standard set code
    if( this->Texture )
        this->Texture->UnRegister( this );
    this->Texture = texImage;
    if( this->Texture )
        this->Texture->Register( this );

    // update texture in actor
    PolyDataObjectViewAssociation::iterator it = this->polydataObjectInstances.begin();
    for( ; it != this->polydataObjectInstances.end(); ++it )
    {
        View * view = (*it).first;
        if( view->GetType() == THREED_VIEW_TYPE )
        {
            vtkSmartPointer<vtkActor> actor = (*it).second;
            vtkTexture * tex = actor->GetTexture();
            if( tex )
            {
                if( this->Texture )
                    tex->SetInputData( this->Texture );
                else
                    tex->SetInputData( this->checkerBoardTexture );
            }
        }
    }

    emit ObjectModified();
}
Пример #6
0
void Surface_RenderScalar_Plugin::changeScalarVBO(const QString& view, const QString& map, const QString& vbo)
{
	View* v = m_schnapps->getView(view);
	MapHandlerGen* m = m_schnapps->getMap(map);
	if(v && m)
	{
		MapParameters& p = h_viewParameterSet[v][m];

		Utils::VBO* vbuf = m->getVBO(vbo);
		p.positionVBO = vbuf;

		if(vbuf)
		{
			MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m);
			const VertexAttribute<PFP2::REAL, PFP2::MAP>& attr = mh->getAttribute<PFP2::REAL, VERTEX>(QString::fromStdString(vbuf->name()));
			p.scalarMin = std::numeric_limits<float>::max();
			p.scalarMax = std::numeric_limits<float>::min();
			for(unsigned int i = attr.begin(); i != attr.end(); attr.next(i))
			{
				p.scalarMin = attr[i] < p.scalarMin ? attr[i] : p.scalarMin;
				p.scalarMax = attr[i] > p.scalarMax ? attr[i] : p.scalarMax;
			}
		}

		if(v->isSelectedView())
		{
			if(v->isLinkedToMap(m))	v->updateGL();
			if(m->isSelectedMap()) m_dockTab->updateMapParameters();
		}
	}
}
Пример #7
0
int Control::CurAlpha(DisplayDirector* director)
{
	// find out where the mouse is and make sure it's in the window
	View* windowView = director->WindowView();
	BPoint mousePoint = windowView->GetMousePoint();
	if (!windowView->Bounds().BRect::Contains(mousePoint))
		return 0;

	// calculate the alpha
	BRect rect = GetRect();
	int xDistance = 0;
	if (mousePoint.x < rect.left)
		xDistance = (int) (rect.left - mousePoint.x);
	else if (mousePoint.x > rect.right)
		xDistance = (int) (mousePoint.x - rect.right);
	int yDistance = 0;
	if (mousePoint.y < rect.top)
		yDistance = (int) (rect.top - mousePoint.y);
	else if (mousePoint.y > rect.bottom)
		yDistance = (int) (mousePoint.y - rect.bottom);
	float distance = sqrt(xDistance * xDistance + yDistance * yDistance);
	if (distance > visibleZone)
		distance = visibleZone;
	float visibility = (visibleZone - distance) / visibleZone;
	return (int) (visibility * 255);
}
Пример #8
0
void PaletteView::update_scroll(int color)
{
  View* view = View::getView(this);
  if (!view)
    return;

  gfx::Rect vp = view->getViewportBounds();
  gfx::Point scroll;
  int x, y, cols;
  div_t d;

  scroll = view->getViewScroll();

  d = div(Palette::MaxColors, m_columns);
  cols = m_columns;

  y = (m_boxsize+this->child_spacing) * (color / cols);
  x = (m_boxsize+this->child_spacing) * (color % cols);

  if (scroll.x > x)
    scroll.x = x;
  else if (scroll.x+vp.w-m_boxsize-2 < x)
    scroll.x = x-vp.w+m_boxsize+2;

  if (scroll.y > y)
    scroll.y = y;
  else if (scroll.y+vp.h-m_boxsize-2 < y)
    scroll.y = y-vp.h+m_boxsize+2;

  view->setViewScroll(scroll);
}
Пример #9
0
void View::transform(
    Transformer& t, const Allocation& a, const Allocation&
) const {
    scene2view(a);
    const Allotment& ax = a.x_allotment();
    const Allotment& ay = a.y_allotment();
    csize(ax.begin(), ax.span(), ay.begin(), ay.span());
    float sx = ax.span()/XYView::width();
    float sy = ay.span()/XYView::height();
//	if (sx > sy) sx = sy;
    t.translate( -x(), -y());
    t.scale(sx, sx);
    View* v = (View*)this;
    v->x_pick_epsilon_ = pick_epsilon/sx;
    v->y_pick_epsilon_ = pick_epsilon/sx;
    t.translate((ax.begin() + ax.end())/2,(ay.begin() + ay.end())/2);
//printf("\nx origin=%g span=%g alignment=%g begin=%g end=%g\n", ax.origin(), ax.span(), ax.alignment(), ax.begin(), ax.end());
//printf("\ny origin=%g span=%g alignment=%g begin=%g end=%g\n", ay.origin(), ay.span(), ay.alignment(), ay.begin(), ay.end());
    Coord x1,y1;
    t.transform(x() - x_span_/2, y() - y_span_/2, x1, y1);
    if (!Math::equal(ax.begin(), x1, 1) || !Math::equal(ay.begin(), y1, 1)) {
        t.inverse_transform(ax.begin(), ay.begin(), x1, y1);
        v->x_span_ = 2*(x() - x1);
        v->y_span_ = 2*(y() - y1);
        v->size(x1,y1,x1+v->x_span_, y1+v->y_span_);
    }

}
void DisplayDirector::FindSelection()
{
//***	be_app->HideCursor();
	View* view = WindowView();
	BPoint point;
	BPoint lastPoint(-1000000, -1000000);
	bool scrolling = false;
	for (;; lastPoint = point) {
		// get & check mouse state
		int buttons = view->GetMouseButtons();
		if (buttons == 0)
			break;
		point = view->GetMousePoint();
		bool autoscrolling = Autoscroll(point);
		if (point == lastPoint && !autoscrolling && !scrolling) {
			view->MouseTrackingPause();
			continue;
			}

		// move the selection
		StartRefreshCycle();
		BPoint docPoint = ViewToDoc(point);
		FindSelectionContext context(docPoint.x, docPoint.y);
		Selection* newSelection = docDisplayNode->BlockFindSelection(&context);
		SetSelection(newSelection);
		scrolling = DoScrollStep();
		FinishRefreshCycle();
		ClearDeletedSelections();
		}
//***	be_app->ShowCursor();	//*** didn't work
}
Пример #11
0
MainWindow::MainWindow(QWidget *parent)
    : QWidget(parent)
{
    populateScene();

    h1Splitter = new QSplitter;
    h2Splitter = new QSplitter;
    
    QSplitter *vSplitter = new QSplitter;
    vSplitter->setOrientation(Qt::Vertical);
    vSplitter->addWidget(h1Splitter);
    vSplitter->addWidget(h2Splitter);

    View *view = new View("Top left view");
    view->view()->setScene(scene);
    h1Splitter->addWidget(view);

    view = new View("Top right view");
    view->view()->setScene(scene);
    h1Splitter->addWidget(view);

    view = new View("Bottom left view");
    view->view()->setScene(scene);
    h2Splitter->addWidget(view);

    view = new View("Bottom right view");
    view->view()->setScene(scene);
    h2Splitter->addWidget(view);

    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget(vSplitter);
    setLayout(layout);

    setWindowTitle(tr("Chip Demo"));
}
Пример #12
0
 forceinline ExecStatus
 MultZeroOne<View>::post(Home home, View x0, View x1) {
   switch (rtest_eq(x0,0.0)) {
   case RT_FALSE:
     GECODE_ME_CHECK(x1.eq(home,1.0));
     break;
   case RT_TRUE:
     break;
   case RT_MAYBE:
     switch (rtest_eq(x1,1.0)) {
     case RT_FALSE:
       GECODE_ME_CHECK(x0.eq(home,0.0));
       break;
     case RT_TRUE:
       break;
     case RT_MAYBE:
       (void) new (home) MultZeroOne<View>(home,x0,x1);
       break;
     default: GECODE_NEVER;
     }
     break;
   default: GECODE_NEVER;
   }
   return ES_OK;
 }
Пример #13
0
Presenter::Presenter(
        Model& m,
        View& v,
        QObject *parent):
    iscore::SettingsDelegatePresenterInterface{m, v, parent}
{
    con(v, &View::skinChanged,
        this, [&] (const auto& val) {
        if(val != m.getSkin())
        {
            m_disp.submitCommand<SetSkin>(this->model(this), val);
        }
    });

    con(m, &Model::skinChanged, &v, &View::setSkin);
    v.setSkin(m.getSkin());

    con(v, &View::zoomChanged,
        this, [&] (const auto val) {
        if(val != m.getGraphicZoom())
        {
            m_disp.submitCommand<SetGraphicZoom>(this->model(this), 0.01*double(val));
        }
    });
    con(m, &Model::graphicZoomChanged,
        this, [&] (const double z) {
        v.setZoom((100 * z));
    });
    v.setZoom(m.getGraphicZoom() * 100);
}
Пример #14
0
void Surface_RenderScalar_Plugin::vboRemoved(Utils::VBO *vbo)
{
	MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());

	if(map == m_schnapps->getSelectedMap())
	{
		if(vbo->dataSize() == 3)
			m_dockTab->removePositionVBO(QString::fromStdString(vbo->name()));
		else if(vbo->dataSize() == 1)
			m_dockTab->removeScalarVBO(QString::fromStdString(vbo->name()));
	}

	QSet<View*> viewsToUpdate;

	QHash<View*, QHash<MapHandlerGen*, MapParameters> >::iterator i;
	for (i = h_viewParameterSet.begin(); i != h_viewParameterSet.end(); ++i)
	{
		View* view = i.key();
		QHash<MapHandlerGen*, MapParameters>& viewParamSet = i.value();
		MapParameters& mapParam = viewParamSet[map];
		if(mapParam.positionVBO == vbo)
		{
			mapParam.positionVBO = NULL;
			if(view->isLinkedToMap(map)) viewsToUpdate.insert(view);
		}
		if(mapParam.scalarVBO == vbo)
		{
			mapParam.scalarVBO = NULL;
			if(view->isLinkedToMap(map)) viewsToUpdate.insert(view);
		}
	}

	foreach(View* v, viewsToUpdate)
		v->updateGL();
}
Пример #15
0
void NewImageInterface::UpdateReadout( const View& v, const DPoint&, double R, double G, double B, double A )
{
   if ( GUI != 0 && IsVisible() )
   {
      if ( ISCOLOR || !v.IsColor() )
      {
         instance.v0 = R;
         instance.v1 = G;
         instance.v2 = B;
      }
      else
      {
         RGBColorSystem rgb;
         v.Window().GetRGBWS( rgb );
         instance.v0 = instance.v1 = instance.v2 = rgb.Lightness( R, G, B );
      }

      GUI->V0_NumericControl.SetValue( instance.v0 );
      GUI->V1_NumericControl.SetValue( instance.v1 );
      GUI->V2_NumericControl.SetValue( instance.v2 );

      if ( HASALPHA )
      {
         instance.va = A;
         GUI->VA_NumericControl.SetValue( instance.va );
      }

      GUI->ColorSample_Control.Update();
   }
}
Пример #16
0
  void onSelect() override {
    if (m_image)
      return;

    ListBox* listbox = static_cast<ListBox*>(getParent());
    if (!listbox)
      return;

    app::skin::SkinTheme* theme = app::skin::SkinTheme::instance();
    gfx::Color color = theme->colors.text();

    try {
      m_image.reset(
        render_text(
          m_filename, 16,
          "ABCDEabcde",             // TODO custom text
          doc::rgba(gfx::getr(color),
                    gfx::getg(color),
                    gfx::getb(color),
                    gfx::geta(color)),
          true));                   // antialias

      View* view = View::getView(listbox);
      view->updateView();
      listbox->makeChildVisible(this);

      // Save the thumbnail for future FontPopups
      g_thumbnails[m_filename] = m_image;
    }
    catch (const std::exception&) {
      // Ignore errors
    }
  }
Пример #17
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    Model model;

    // create a scene
    QGraphicsScene* scene = new QGraphicsScene();

    // create an item to put into scene
    MovingBall* ball = new MovingBall(model.get_width()/2, model.get_height()/2);

    // make rect focusable

    // add item to scene
    scene->addItem(ball);


    View* view = new View(scene);
    view->show();

//    MainWindow w;
//    w.setCentralWidget(view);
//    w.setFixedSize(model.get_width(), model.get_height());
//    w.show();



    return a.exec();
}
Пример #18
0
void DbViewerPanel::OnDnDStart(wxTreeEvent& event)
{
    ShapeList lstDnD;
    lstDnD.DeleteContents(true);
    DbItem* item = (DbItem*) m_treeDatabases->GetItemData(event.GetItem());

    ErdPanel* pPanel = wxDynamicCast(m_mgr->GetActivePage(),ErdPanel);

    if (item != NULL) {
        if (pPanel) {
            Table* table = wxDynamicCast(item->GetData(),Table);
            if (table) {
                table = (Table*) table->Clone();
                wxSFShapeBase *pShape = new dndTableShape(table);
                lstDnD.Append(pShape);
                pPanel->GetCanvas()->DoDragDrop(lstDnD);
            }

            View* view = wxDynamicCast(item->GetData(),View);
            if (view) {
                view = (View*) view->Clone();
                wxSFShapeBase *pShape = new dndTableShape(view);
                lstDnD.Append(pShape);
                pPanel->GetCanvas()->DoDragDrop(lstDnD);
            }
        }
    }
}
void DisplayDirector::MouseDown(int x, int y)
{
	BPoint mousePoint(x, y);
	View* view = WindowView();

	// hit the hotspot
	if (hotspot && hotspot->ContainsPoint(ViewToDoc(mousePoint)))
		hotspot->Clicked(this);

	// extend the selection
	else if ((view->CurModifiers() & B_SHIFT_KEY) != 0)
		ExtendSelection();

	// promote or drag the selection
	else if (selection && selection->ContainsPoint(ViewToDoc(mousePoint))) {
		if (view->CurClicks() > 1) {
			StartRefreshCycle();
			selection->Promote(this);
			FinishRefreshCycle();
			ExtendSelection();
			}
		else
			DragSelection(mousePoint);
		}

	// otherwise find a new selection
	else {
		if (DocRect().Contains(mousePoint))
			FindSelection();
		else
			SetSelection(NULL);
		}
}
Пример #20
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
wxWindow*
Notebook::addPage(I_View* _pWindow, const std::string& _title)
{
    View* pWindow = dynamic_cast<View*>(_pWindow);

    // Get the number of pages
    const size_t pageCount = GetPageCount();

    // Add a page to the end
    AddPage(pWindow, std2wx(_title.c_str()), true);
    pWindow->SetLabel(std2wx(_title.c_str()));

    // Return that page.
    wxWindow* const pPage = GetPage(pageCount);

    pWindow->setPage(this, pPage);

    m_views[pPage] = pWindow;

    // Activate the page.
    SetSelection(pageCount);

    pPage->SetFocus();

    // If it's the first page, activate it. (um, didn't we just do that?)
    if (pageCount == 0)
    {
        notifyPageChange(_pWindow);
    }

    return pPage;
}
Пример #21
0
 View* View::create(cocos2d::Scene* scene)
 {
     View* view = new View();
     view->setScene(scene);
     view->init();
     return view;
 }
Пример #22
0
bool CropInstance::ExecuteOn( View& view )
{
   if ( !view.IsMainView() )
      return false;  // should not happen!

   if ( p_margins == 0.0 )
   {
      Console().WriteLn( "<end><cbr>&lt;* Identity *&gt;" );
      return true;
   }

   AutoViewLock lock( view );

   ImageWindow window = view.Window();
   ImageVariant image = view.Image();

   Crop C( p_margins );
   C.SetMode( static_cast<Crop::crop_mode>( p_mode ) );
   C.SetResolution( p_resolution.x, p_resolution.y );
   C.SetMetricResolution( p_metric );
   C.SetFillValues( p_fillColor );

   // Dimensions of target image
   int w0 = image.Width();
   int h0 = image.Height();

   // Dimensions of transformed image
   int width = w0, height = h0;
   C.GetNewSizes( width, height );

   if ( width < 1 || height < 1 )
      throw Error( "Crop: Invalid operation: Null target image dimensions" );

   // On 32-bit systems, make sure the resulting image requires less than 4 GB.
   if ( sizeof( void* ) == sizeof( uint32 ) )
   {
      uint64 sz = uint64( width )*uint64( height )*image.NumberOfChannels()*image.BytesPerSample();
      if ( sz > uint64( uint32_max-256 ) )
         throw Error( "Crop: Invalid operation: Target image dimensions would exceed four gigabytes" );
   }

   DeleteAstrometryMetadataAndPreviewsAndMask( window );

   Console().EnableAbort();

   StandardStatus status;
   image.SetStatusCallback( &status );

   C >> image;

   if ( p_forceResolution )
   {
      Console().WriteLn( String().Format( "Setting resolution: h:%.3lf, v:%.3lf, u:px/%s",
                                          p_resolution.x, p_resolution.y, p_metric ? "cm" : "inch" ) );
      window.SetResolution( p_resolution.x, p_resolution.y, p_metric );
   }

   return true;
}
void AdaptiveStretchCurveGraphInterface::__Click( Button& sender, bool checked )
{
   if ( sender == GUI->Render_ToolButton )
   {
      ImageWindow window( m_width, m_height,
                          3,      // numberOfChannels
                          8,      // bitsPerSample
                          false,  // floating point
                          true ); // color
      if ( !m_gridBitmap.IsNull() )
      {
         View mainView = window.MainView();
         ImageVariant v = mainView.Image();
         static_cast<UInt8Image&>( *v ).Blend( m_gridBitmap );
         if ( !m_curveBitmap.IsNull() )
            static_cast<UInt8Image&>( *v ).Blend( m_curveBitmap );
      }

      window.BringToFront();
      window.Show();
      window.ZoomToFit( false/*allowMagnification*/ );
   }
   else if ( sender == GUI->Edit_ToolButton )
   {
      CurvesTransformationInstance curves( TheCurvesTransformationProcess );
      float ux = 1.0/(m_curve.Length() - 1);
      float m0 = 0;
      for ( int i = 0, j = 1; j < m_curve.Length(); ++j )
      {
         float dy = Abs( m_curve[j] - m_curve[i] );
         if ( dy > 0.01 )
         {
            float dx = ux*(j - i);
            float m = dy/dx;
            if ( Abs( m - m0 )/m > 0.05 )
            {
               m0 = m;
               i = j;
               curves[CurveIndex::RGBK].Add( ux*i, m_curve[i] );
            }
         }
         else if ( 1 + dy == 1 )
         {
            for ( ; ++j < m_curve.Length(); ++j )
            {
               dy = Abs( m_curve[j] - m_curve[i] );
               if ( 1 + dy > 1 )
               {
                  m0 = 0;
                  i = j-1;
                  curves[CurveIndex::RGBK].Add( ux*i, m_curve[i] );
                  break;
               }
            }
         }
      }
      curves.LaunchInterface();
   }
}
Пример #24
0
void reset_after_disconnection(const SocketError &) {
    Window *win = App::get()->get_window();
    delete win->remove_last_subview();
    View *start = new StartScreen(*win);
    win->attach_subview(start, DispPoint());
    win->resize(start->get_w(), start->get_h());
    
}
Пример #25
0
GameWidget::GameWidget(Scene *scene, QWidget *parent) :
    QGraphicsView(parent),
    m_scene(scene),
    m_timeLabel(this),
    m_checkpointRemainingLabel(this),
    m_paused(false),
    m_cameraScale(1.f),
    m_frameCount(0),
    m_timeBeforeStartLabel(this)
{
    if (!scene)
    {
        QMessageBox::information(nullptr, "Erreur (GameWidget)", "Aucune scène a afficher!", 0);
    }
    else if (!scene->loaded())
    {
        QMessageBox::information(nullptr, "Erreur (GameWidget)", "Le niveau n'a pas été chargé!", 0);
    }
    else
    {       
        this->setCursor(Qt::BlankCursor);

        //Placement du label du timer
        m_timeLabel.setGeometry(0,0,500,50);
        m_timeLabel.setStyleSheet("color: white;font: 24pt \"Leelawadee UI\";");

        //Placement du label du nombre de checkpoints restants
        m_checkpointRemainingLabel.setGeometry(parent->width()-250,0,250,50);
        m_checkpointRemainingLabel.setStyleSheet("color: white;font: 14pt \"Leelawadee UI\";");

        //Placement du label du affichant le temps avant le début de la partie
        m_timeBeforeStartLabel.setGeometry(350,250,100,100);
        m_timeBeforeStartLabel.setStyleSheet("font: 72pt \"Leelawadee UI\";");

        // prépare la scène pour l'affichage
        this->setScene(scene->graphicsScene());
        this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

        // réglages du clavier
        grabKeyboard();
        scene->setPlayerInput(&m_playerInput);

        // démarrage du timer de rafraichissement du jeu
        startTimer(sf::seconds(1/60.f).asMilliseconds());

        //Centrage de la caméra
        View view = m_scene->calcViewPoint();
        centerOn(view.position());

        //Démarrage du timer de début de course ( 3,2,1 -> Go)
        m_preStartTimer = new PreStartTimer(this);
        m_preStartTimer->startTimer();
        connect(m_preStartTimer,SIGNAL(startGame()),this,SLOT(startGame()));

    }
}
Пример #26
0
void GameWidget::timerEvent(QTimerEvent *timerEvent)
{
    //Vérifie si la partie a déjà commencé ou non
    if(m_preStartTimer->timeRemaining())
    {
        m_timeBeforeStartLabel.setText(QString::number(m_preStartTimer->timeRemaining()));
    }
    else{
        //Vérifie si le jeu est en pause ou non
        if(!m_paused)
        {
            if (m_scene)
            {
                //Vérifie si le jeu est en pause
                if(m_scene->isFinished())
                {
                    killTimer(timerEvent->timerId());
                    emit showScore("EndGame");
                }
                //Gère les actions dans le cas où la partie est en cours
                else
                {
                    /// mise à jour de la scène
                    m_scene->update();

                     /// mise à jour de la caméra
                    View view = m_scene->calcViewPoint();
                    centerOn(view.position());
                    // "crante" l'effet de zoom, car visiblement, changer l'échelle de la vue dans qt prend du temps
                    // et ralenti considérablement le jeu lorsque cela est fait à chaque frame.
                    //float zoom = (int)(view.zoom()*200)/200.f;
                    //std::cout << view.zoom() << " --- " << zoom << " --- " << m_cameraScale << std::endl;
                    //view.setZoom(.7);
                    m_frameCount++;
                    if (m_frameCount == 3)
                        m_frameCount = 0;
                    if (m_frameCount == 0)
                    {
                        if (view.zoom() != m_cameraScale)
                        {
                            float cameraScale = 1 - (m_cameraScale - view.zoom());
                            m_cameraScale = view.zoom();
                            scale(cameraScale, cameraScale);
                        }
                    }

                    /// mise à jour du compteur (Affichage
                    m_timeLabel.setText(utils::showableTime(m_scene->time().elapsed()));

                    /// mise à jour du nombre de checkpoint restant (Affichage)
                    QString checkpointRemainingString = "Checkpoint(s) Remaining : "+QString::number(m_scene->checkpointListener()->checkpointRemaining());
                    m_checkpointRemainingLabel.setText(checkpointRemainingString);
                }
            }
        }
    }
}
Пример #27
0
void ImageIdentifierInterface::__ViewDrop( Control& sender, const Point& pos, const View& view, unsigned modifiers )
{
   if ( sender == GUI->Identifier_Edit )
      if ( view.IsMainView() )
      {
         instance.SetId( view.Id() );
         UpdateControls();
      }
}
Пример #28
0
void init()
{
  int major,minor;
  v.getOpenGLVersion(&major,&minor);
  cout << "OpenGL version supported by the GLUT window: " << major << "." << minor << endl;
  v.getGLSLVersion(&major,&minor);
  cout << "GLSL version supported by the GLUT window: " << major << "." << minor << endl;
  glClearColor(0,0,0,1);
  v.initialize();
}
Пример #29
0
void
Background::draw (View& view)
{
  //sprite.draw();
  // FIXME: We should take the view size and surface size into account
  for (int y = -1; y <= 2; ++y)
    for (int x = -1; x <= 2; ++x)
      sprite.draw(x * sprite.get_width()  + (int(view.get_x_offset()) % sprite.get_width()),
                  y * sprite.get_height() + (int(view.get_y_offset()) % sprite.get_height()));
}
Пример #30
0
 virtual int GetPreferredHeightForWidth(View* host, int width)
 {
     int height = 0;
     for(int i=0; i<host->child_count(); ++i)
     {
         View* page = host->child_at(i);
         height = std::max(height, page->GetHeightForWidth(width));
     }
     return height;
 }