float3 CGridManager::GridtoMap(float3 Gridpos) {
		float3 finalpos=UpVector;
		if(ValidGridPos(Gridpos)){
			finalpos.z = Gridpos.z*GetCellHeight();
			finalpos.z += GetCellHeight()/2;
			finalpos.x = Gridpos.x*GetCellWidth();
			finalpos.x += GetCellWidth()/2;
		}
		return finalpos;
	}
Beispiel #2
0
/*
     * Initializes the object, assuming that filename, origin, size, etc are already set on the
     * member variables. Makes sure the raster can be opened, sets the block size, NODATA value,
     * pixel size, and the extent of the raster. If not using the full image then makes sure that
     * the subset chosen (based on origin and size) is valid. If using the full image then sets the
     * size and origin is assumed to be 0,0 and is set in the constructor.
     * @param fullImage True if using the full image, False if using a subset.
     */
void Raster::Init(bool bFullImage)
{
    Init();
    GDALDataset * ds = (GDALDataset*) GDALOpen(m_sFilePath, GA_ReadOnly);

    if (ds == NULL)
        throw RasterManagerException(INPUT_FILE_NOT_VALID, CPLGetLastErrorMsg());

    GDALRasterBand * band = ds->GetRasterBand(1);

    double dRMin, dRMax, dRMean, dRStdDev;

    // Get some easy stats that GDAL gives us
    band->GetStatistics( 0 , true, &dRMin, &dRMax, &dRMean, &dRStdDev );
    m_dRasterMax = dRMax;
    m_dRasterMin = dRMin;

    m_dRasterMean = dRMean;
    m_dRasterStdDev = dRStdDev;

    OGRLinearRing ring = OGRLinearRing();
    if (bFullImage)
    {
        SetCols( band->GetXSize() );
        SetRows( band->GetYSize() );

        ring.addPoint(GetLeft(), GetTop());
        ring.addPoint(GetLeft(), GetTop() + (GetCellHeight() * GetRows()));
        ring.addPoint(GetLeft() + (GetCellWidth() * GetCols()), GetTop() + (GetCellHeight() * GetRows()));
        ring.addPoint(GetLeft() + (GetCellWidth() * GetCols()), GetTop());
        ring.closeRings();
    }
    else
    {
        if ((GetLeft() + GetCols() > band->GetXSize()) || (GetTop() + GetRows() > band->GetYSize()))
        {
            QString sErr = QString("Invalid origin ( %1, %2 ) and size ( %5, %6 ) for file: %7")
                    .arg(GetLeft())
                    .arg(GetTop())
                    .arg(GetCols())
                    .arg(GetRows())
                    .arg(FilePath());
            throw RasterManagerException(INPUT_FILE_NOT_VALID, sErr);
        }
        double xMapOrigin = GetLeft() + (GetLeft() * GetCellWidth());
        double yMapOrigin = GetTop() + (GetTop() * GetCellHeight());
        ring.addPoint(xMapOrigin, yMapOrigin);
        ring.addPoint(xMapOrigin, yMapOrigin + (GetCellHeight() * GetRows()));
        ring.addPoint(xMapOrigin + (GetCellWidth() * GetCols()), yMapOrigin + (GetCellHeight() * GetRows()));
        ring.addPoint(xMapOrigin + (GetCellWidth() * GetCols()), yMapOrigin);
        ring.closeRings();
    }
    GDALClose(ds);

}
Beispiel #3
0
void UIHierarchy::ScrollToData(void *userData)
{
    int32 count = 0;
    
    GetCount(NULL, userData, count);
    
    float32 scrollPos = count * GetCellHeight();
    scroll->SetPosition(-scrollPos);
}
	int CGridManager::MaptoIndex(float3 Mappos) {
		if(ValidMapPos(Mappos)){
			int Index = 0;
			Index += (int)floor(Mappos.z/GetCellHeight())*GetGridWidth();
			Index += (int)floor(Mappos.x/GetCellWidth());
			return Index;
		}
		return -1;
	}
	float3 CGridManager::MaptoGrid(float3 Mappos) {
		float3 finalpos=UpVector;
		if(ValidMapPos(Mappos)){
			finalpos.z=floor(Mappos.z/GetCellHeight());
			finalpos.x=floor(Mappos.x/GetCellWidth());
			finalpos.y =0;
		}
		return finalpos;
	}
TextureConverterCell::TextureConverterCell(const Rect &rect, const String &cellIdentifier)
:   UIListCell(Rect(rect.x, rect.y, rect.dx, (float32)GetCellHeight()), cellIdentifier)
{
    ControlsFactory::CustomizeListCell(this, L"");
    
    textureName = new UIStaticText(Rect(0, 0, rect.dx, ControlsFactory::BUTTON_HEIGHT));
    textureName->SetFont(ControlsFactory::GetFont12());
	textureName->SetTextColor(ControlsFactory::GetColorDark());
    textureName->SetInputEnabled(false);
    AddControl(textureName);
    
    preview = new UIControl(Rect(0, textureName->GetRect().y + textureName->GetRect().dy, 
                                 rect.dx, ControlsFactory::TEXTURE_PREVIEW_HEIGHT));
    preview->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_PROPORTIONAL);
    preview->SetInputEnabled(false);
    AddControl(preview);
    

    textureFormat = new UIStaticText(Rect(0, preview->GetRect().y + preview->GetRect().dy, 
                                          rect.dx, ControlsFactory::BUTTON_HEIGHT));
    textureFormat->SetFont(ControlsFactory::GetFont12());
	textureFormat->SetTextColor(ControlsFactory::GetColorDark());
    textureFormat->SetInputEnabled(false);
    AddControl(textureFormat);
    
    textureDimensions = new UIStaticText(Rect(0, textureFormat->GetRect().y + textureFormat->GetRect().dy, 
                                          rect.dx, ControlsFactory::BUTTON_HEIGHT));
    textureDimensions->SetFont(ControlsFactory::GetFont12());
	textureDimensions->SetTextColor(ControlsFactory::GetColorDark());
    textureDimensions->SetInputEnabled(false);
    AddControl(textureDimensions);

    textureSize = new UIStaticText(Rect(0, textureDimensions->GetRect().y + textureDimensions->GetRect().dy, 
                                              rect.dx, ControlsFactory::BUTTON_HEIGHT));
    textureSize->SetFont(ControlsFactory::GetFont12());
	textureSize->SetTextColor(ControlsFactory::GetColorDark());
    textureSize->SetInputEnabled(false);
    AddControl(textureSize);

    
    UIControl *line =  ControlsFactory::CreateLine(Rect(0, (float32)GetCellHeight() - 1.f, rect.dx, 1.f), Color(0.2f, 0.2f, 0.2f, 0.8f));
    AddControl(line);
    SafeRelease(line);
}
Beispiel #7
0
		/*=============================================================================
		-- Populates @mVisibleCells with the cells that are visible.
		=============================================================================*/
		void ListBox::_CalculateVisibleCells()
		{
			int totalCells = mChildren.size()-1;  //TODO we are assuming all children are cells and one is the scroll bar
			int cellViewHeight = GetHeight() - LISTBOX_CELL_PADDING*2;
			int cellsThatCanBeAtTop = totalCells - (cellViewHeight/GetCellHeight());
			
			if (cellsThatCanBeAtTop < 0)
				cellsThatCanBeAtTop = totalCells;

			int currentTopCellIndex = (int)std::floor((double)cellsThatCanBeAtTop * mScrollBar.lock()->GetScrollPosition());

			mVisibleCells.clear();
			
			//copy over the visible cells from the mChildren vector to the mVisibleCells vector
			int cellIndex = 0;	//first child is scrollbar
			int relativeCellIndex = 0;
			std::vector< WeakPtr<Cell> >::iterator iter = mCells.begin();

			while (iter != mCells.end())
			{
				if (cellIndex >= currentTopCellIndex  &&  cellIndex < currentTopCellIndex+(cellViewHeight/GetCellHeight()))
				{
					mVisibleCells.push_back(*iter);
					(*iter).lock()->SetDraws(true);
					(*iter).lock()->SetDisabled(false);

					Vector2D<int> relPos;
					relPos.x = LISTBOX_CELL_PADDING;
					relPos.y = LISTBOX_CELL_PADDING + GetCellHeight()*relativeCellIndex;
					(*iter).lock()->SetRelPos(relPos);

					relativeCellIndex++;
				}
				else if (cellIndex != -1)  //don't want to disable scroll bar
				{
					(*iter).lock()->SetDraws(false);
					(*iter).lock()->SetDisabled(true);
				}

				cellIndex++;
				iter++;
			}
		}
Beispiel #8
0
		/*=============================================================================
		-- Updates the position and size of each asset.
		=============================================================================*/
		void ListBox::_UpdateAssets()
		{
			mImgBackground.SetPos(GetScreenPos());
			mImgBackground.SetSize(GetWidth(), GetHeight());

			//tell every cell the new sizes
			std::vector< WeakPtr<Cell> >::iterator iter = mVisibleCells.begin();
			while (iter != mVisibleCells.end())
			{
				(*iter).lock()->SetSize(GetCellWidth(), GetCellHeight());
				iter++;
			}
		}
Beispiel #9
0
		/*=============================================================================
		-- Adds a new item to the context menu. Items are just Picture objects.
		=============================================================================*/
		WeakPtr<Cell> ListBox::AddCell(String name, String uid)
		{
			mCells.push_back( GetRoot()->CreateCell(-mIdTrack, DynamicPtrCast<ListBox>(_GetAsWeakPtr().lock()), Vector2D<int>(0,0),
													GetCellWidth(), GetCellHeight()) );

			mCells.back().lock()->SetBackgroundImage("cell.png");
			mCells.back().lock()->SetSolid(false);

			mCells.back().lock()->SetInternalCaption(GetRoot()->CreateText(-1243, mCells.back(), Vector2D<int>(2,2), name));
			mCells.back().lock()->SetUID(uid);

			mIdTrack++;

			return mCells.back();
		}
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
//		¥ SetCellHeight
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// Changes the height in the table of this cell
void CHierarchicalElement::SetCellHeight(
	SInt32			inNewRowHeight,
	bool			inRefresh)
{
	if (IsInTable())
	{
		SignalIf_(inNewRowHeight>0xFFFF);		// Row heights are measured as UInt16's from here on
		
		STableCell			cell;
		
		GetElementCell(cell);
		
		if (inNewRowHeight!=GetCellHeight())
			GetTable()->SetRowHeight(inNewRowHeight,cell.row,cell.row);
	}
}
Beispiel #11
0
		/*=============================================================================
		-- Returns the cell at the absolute screen position @point. If the point is not
		   within the bounds of where cells are, then no cell will be returned.
		=============================================================================*/
		WeakPtr<Cell> ListBox::GetCellAtPoint(Vector2D<int> point)
		{
			_CalculateVisibleCells();

			Vector2D<int> screenPos = GetScreenPos();

			if (point.x > screenPos.x+LISTBOX_CELL_PADDING  &&  point.x < screenPos.x+GetCellWidth()+LISTBOX_CELL_PADDING)
			{
				int selectedVisibleCellIndex = (point.y-screenPos.y-LISTBOX_CELL_PADDING) / GetCellHeight();

				if (selectedVisibleCellIndex < (int)mVisibleCells.size()  &&  selectedVisibleCellIndex >= 0)
					return mVisibleCells.at(selectedVisibleCellIndex);
			}

			return WeakPtr<Cell>();
		}
Beispiel #12
0
		/*=============================================================================
		-- Updates the ListBox.
		=============================================================================*/
		void ListBox::_Update()
		{
			_CalculateVisibleCells();

			mScrollBar.lock()->SetVirtualScrollSize(mCells.size()*GetCellHeight());
		}
Beispiel #13
0
		void ListBox::SetHeightForViewableCellCount(int numberOfVisibleCells)
		{
			SetSize(GetWidth(), numberOfVisibleCells*GetCellHeight() + LISTBOX_CELL_PADDING*2);
		}