Ejemplo n.º 1
0
void CChartTable::setScaleArea( const CDataPosition& _roGeoPosition1, const CDataPosition& _roGeoPosition2, double _fdScaleCorrection )
{
  if( bIgnoreUpdate || QTabWidget::currentIndex() < 0 ) return;
  CChart* __poChart = (CChart*)QTabWidget::currentWidget();
  setGeoPosition( CDataPosition( ( _roGeoPosition1.getLongitude() + _roGeoPosition2.getLongitude() ) / 2.0, ( _roGeoPosition1.getLatitude() + _roGeoPosition2.getLatitude() ) / 2.0 ) );
  setScale( toScale( __poChart->getZoomArea( _roGeoPosition1, _roGeoPosition2 ) * _fdScaleCorrection, __poChart ) );
}
Ejemplo n.º 2
0
void CChartTable::setScaleFit()
{
  if( bIgnoreUpdate || QTabWidget::currentIndex() < 0 ) return;
  CChart* __poChart = (CChart*)QTabWidget::currentWidget();
  setGeoPosition( __poChart->getGeoPositionCenter() );
  setScale( toScale( __poChart->getZoomFit(), __poChart ) );
}
Ejemplo n.º 3
0
CChart* CChartTable::loadChart( const QString& _rqsFilename )
{
  // Create new chart widget
  CChart* __poChart = new CChart( _rqsFilename );
  if( __poChart->getStatus() != QVCT::OK )
  {
    delete __poChart;
    return 0;
  }

  // Set reference position
  if( oGeoPositionReference == CDataPosition::UNDEFINED ) oGeoPositionReference = __poChart->getGeoPosition();
  else __poChart->setGeoPosition( oGeoPositionReference );

  // Set reference scale factor
  if( fdScaleReference < 0 ) fdScaleReference = toScale( __poChart->getZoom(), __poChart );
  else __poChart->setZoom( toZoom( fdScaleReference,  __poChart ) );

  // Have the chart table manage chart events
  __poChart->installEventFilter( this );
  // ... including pinch gestures
  if( QVCTRuntime::useSettings()->isScreenGestures() ) __poChart->grabGesture( Qt::PinchGesture );

  // Add chart to chart table
  QFileInfo __qFileInfo( _rqsFilename );
  addTab( __poChart, __qFileInfo.baseName() );
  setCurrentWidget( __poChart );
  return __poChart;
}
Ejemplo n.º 4
0
void CChartTable::slotChangeTab( int _iTabIndex )
{
  CChartControl* __poChartControl = QVCTRuntime::useChartControl();
  bIgnoreUpdate = true;
  if( _iTabIndex < 0 )
  {
    __poChartControl->enableControls( false );
  }
  else
  {
    CChart* __poChart = (CChart*)QTabWidget::currentWidget();
    __poChartControl->lockPosition( __poChart->isPositionLocked() );
    __poChartControl->lockScale( __poChart->isZoomLocked() );
    __poChartControl->setScale( toScale( __poChart->getZoom(), __poChart ) );
    __poChartControl->setElevation( __poChart->hasElevation(), __poChart->isElevationShowed() );
    __poChartControl->enableControls( true );
    bIgnoreUpdate = false;
  }
}
Ejemplo n.º 5
0
void CChartTable::setZoom( double _fdZoom, bool _bSkipCurrent, bool _bUpdateControl )
{
  if( count() < 1 ) return;
  //qDebug( "DEBUG[%s] %f", Q_FUNC_INFO, _fdZoom );
  double __fdScale = toScale( _fdZoom );
  int __iWidgetCurrentIndex = QTabWidget::currentIndex();
  bool __bLocked = ((CChart*)QTabWidget::currentWidget())->isZoomLocked();
  if( __bLocked ) fdScaleReference = __fdScale;
  for( int __iWidgetIndex = count() - 1; __iWidgetIndex >= 0; __iWidgetIndex-- )
  {
    CChart* __poChart = (CChart*)widget( __iWidgetIndex );
    if( __iWidgetIndex != __iWidgetCurrentIndex && __bLocked && __poChart->isZoomLocked() )
    {
      __poChart->setZoom( _fdZoom );
    }
    if( __iWidgetIndex == __iWidgetCurrentIndex && !_bSkipCurrent )
    {
      __poChart->setZoom( _fdZoom );
      if( _bUpdateControl ) QVCTRuntime::useChartControl()->setScale( __fdScale );
      // __poChart->update();
    }
  }
}
Ejemplo n.º 6
0
void polygonManager::loadMap(const map* toLoad)
{
    polygon **cubes;
    string name;
    int *numTris;
    int max;

    ifstream fin (toLoad->getCubeInfo().c_str());
    fin>>max;
    for(int x=0;x<max;x++)
    {
        fin>>name;
        texNames.push_back(name);
    }

    fin>>max;
    cubes= new polygon*[max];
    numTris=new int [max];
    for(int x=0;x<max;x++)
    {
        fin>>numTris[x];
        cubes[x]=new polygon[numTris[x]];
        for(int y=0;y<numTris[x];y++)
        {
            fin>>cubes[x][y].norms[0]
               >>cubes[x][y].norms[1]
               >>cubes[x][y].norms[2];
            for(int a=0;a<3;a++)
            {
                fin>>cubes[x][y].texCoord[a][0];
                fin>>cubes[x][y].texCoord[a][1];

                fin>>cubes[x][y].verts[a][0];
                fin>>cubes[x][y].verts[a][1];
                fin>>cubes[x][y].verts[a][2];
            }

        }
    }
    int deb=0;
    float scale=2;
    for(int x=0;x<toLoad->getMaxX();x++)
        for(int y=0;y<toLoad->getMaxY();y++)
            for(int z=0;z<toLoad->getMaxZ();z++)
            {
                int n=toLoad->getObj(x,y,z),m=toLoad->getMaterial(x,y,z);
                for(int a=0;a<numTris[n];a++)
                {

                    polygon tmp(cubes[n][a].texCoord,m,cubes[n][a].norms,cubes[n][a].verts);
                    Vec3f toScale(8,16,8);
                    Vec3f toAdd(-toScale[0]*x,toScale[1]*z,-toScale[2]*y);
                    Vec3f scaler (4,8,4);
                    tmp.verts[0]*=scaler;
                    tmp.verts[1]*=scaler;
                    tmp.verts[2]*=scaler;

                    tmp.verts[0]+=toAdd;
                    tmp.verts[1]+=toAdd;
                    tmp.verts[2]+=toAdd;
                    list.push_back(tmp);
                    if (tmp.verts[0][0]>xmax)xmax=tmp.verts[0][0];if (tmp.verts[0][0]<xmin)xmin=tmp.verts[0][0];
                    if (tmp.verts[0][1]>ymax)ymax=tmp.verts[0][1];if (tmp.verts[0][1]<ymin)ymin=tmp.verts[0][1];
                    if (tmp.verts[0][2]>zmax)zmax=tmp.verts[0][2];if (tmp.verts[0][2]<zmin)zmin=tmp.verts[0][2];

                    if (tmp.verts[1][0]>xmax)xmax=tmp.verts[1][0];if (tmp.verts[1][0]<xmin)xmin=tmp.verts[1][0];
                    if (tmp.verts[1][1]>ymax)ymax=tmp.verts[1][1];if (tmp.verts[1][1]<ymin)ymin=tmp.verts[1][1];
                    if (tmp.verts[1][2]>zmax)zmax=tmp.verts[1][2];if (tmp.verts[1][2]<zmin)zmin=tmp.verts[1][2];

                    if (tmp.verts[2][0]>xmax)xmax=tmp.verts[2][0];if (tmp.verts[2][0]<xmin)xmin=tmp.verts[2][0];
                    if (tmp.verts[2][1]>ymax)ymax=tmp.verts[2][1];if (tmp.verts[2][1]<ymin)ymin=tmp.verts[2][1];
                    if (tmp.verts[2][2]>zmax)zmax=tmp.verts[2][2];if (tmp.verts[2][2]<zmin)zmin=tmp.verts[2][2];
                }
            }
}
Ejemplo n.º 7
0
void CChartTable::load( const QString& _rqsFilename )
{
  QFileInfo __qFileInfo( _rqsFilename );
  QString __qsError;
  do // error-catching context [begin]
  {
    // File
    QFileInfo __qFileInfo( _rqsFilename );
    QFile __qFile( __qFileInfo.absoluteFilePath() );
    if( !__qFile.open( QIODevice::ReadOnly ) )
    {
      __qsError = QString( "Failed to open file (%1)" ).arg( __qFile.fileName() );
      break;
    }
    QDomDocument __qDocDocument;
    if( !__qDocDocument.setContent( &__qFile ) )
    {
      __qsError = QString( "Failed to parse XML (%1)" ).arg( __qFile.fileName() );
      __qFile.close();
      break;
    }
    __qFile.close();

    // XML
    QDomElement __qDomElement = __qDocDocument.documentElement();
    QString __qDocType = __qDomElement.nodeName();
    if( __qDomElement.isNull() || ( __qDocType != "QVCT" ) )
    {
      __qsError = QString( "Invalid XML document type (%1); expected: 'QVCT'" ).arg( __qFile.fileName() );
      break;
    }
    // ... settings
    QVCTRuntime::useSettings()->parseQVCT( __qDomElement );
    // ... chart table
    if( parseQVCT( __qDomElement ) )
    {
      QTabWidget::setCurrentIndex( 0 );
      CChartControl* __poChartControl = QVCTRuntime::useChartControl();
      CChart* __poChart = (CChart*)QTabWidget::currentWidget();
      bIgnoreUpdate = true;
      __poChartControl->lockPosition( __poChart->isPositionLocked() );
      __poChartControl->lockScale( __poChart->isZoomLocked() );
      __poChartControl->setScale( toScale( __poChart->getZoom(), __poChart ) );
      __poChartControl->enableControls( true );
      bIgnoreUpdate = false;
    }
    // ... overlays
    QVCTRuntime::useLandmarkOverlay()->parseQVCT( __qDomElement );
    QVCTRuntime::useLandmarkOverlay()->QTreeWidgetItem::setExpanded( true );
    QVCTRuntime::useRouteOverlay()->parseQVCT( __qDomElement );
    QVCTRuntime::useRouteOverlay()->QTreeWidgetItem::setExpanded( true );
    QVCTRuntime::useTrackOverlay()->parseQVCT( __qDomElement );
    QVCTRuntime::useTrackOverlay()->QTreeWidgetItem::setExpanded( true );
    QVCTRuntime::useVesselOverlay()->parseQVCT( __qDomElement );
    QVCTRuntime::useVesselOverlay()->QTreeWidgetItem::setExpanded( true );
  }
  while( false ); // error-catching context [end]
  if( !__qsError.isEmpty() )
  {
    qCritical( "ERROR[%s]: %s", Q_FUNC_INFO, qPrintable( __qsError ) );
    QVCTRuntime::useMainWindow()->fileError( QVCT::OPEN, _rqsFilename );
    return;
  }
}
Ejemplo n.º 8
0
void CChartTable::setScaleActual()
{
  if( bIgnoreUpdate || QTabWidget::currentIndex() < 0 ) return;
  CChart* __poChart = (CChart*)QTabWidget::currentWidget();
  setScale( toScale( __poChart->getZoomActual(), __poChart ) );
}