void Render( int realX, int realY, bool highlighted, bool clicked )
    {
        LandscapeGuideGridWindow *parent = (LandscapeGuideGridWindow *) m_parent;
        LandscapeTile *def = parent->m_tileDef;

        if( def->m_guideGrid )
        {
            RenderColours   ( realX, realY, highlighted, clicked );
            RenderGrid      ( realX, realY, highlighted, clicked );
            RenderBorder    ( realX, realY, highlighted, clicked );
            RenderMouse     ( realX, realY, highlighted, clicked );

            HandleMouseInput();
        }
    }
void TerrainTileEditorPanel::OnRender(ion::render::Renderer& renderer, const ion::Matrix4& cameraInverseMtx, const ion::Matrix4& projectionMtx, float& z, float zOffset)
{
	RenderTile(renderer, cameraInverseMtx, projectionMtx, z);

	z += zOffset;

	RenderCollision(renderer, cameraInverseMtx, projectionMtx, z);

	z += zOffset;

	if(m_project.GetShowGrid())
	{
		RenderGrid(renderer, cameraInverseMtx, projectionMtx, z);
	}
}
/*
########  ######## ##    ## ########  ######## ########  
##     ## ##       ###   ## ##     ## ##       ##     ## 
##     ## ##       ####  ## ##     ## ##       ##     ## 
########  ######   ## ## ## ##     ## ######   ########  
##   ##   ##       ##  #### ##     ## ##       ##   ##   
##    ##  ##       ##   ### ##     ## ##       ##    ##  
##     ## ######## ##    ## ########  ######## ##     ## 
*/
void SpaceInvadersState::Render(RenderState* renderState)
{
	// Apply the camera transformation
	ApplyCamera(renderState);

	Shader *shader = shaderMan->GetShader(SHADER_NORMAL);

    // Apply renderState settings
    //renderState->renderAABB = this->renderAABB;
    //renderState->renderOutline = this->renderOutline;

    // Render the grid
	if(renderGrid)
		RenderGrid(renderState);
    // Render the border
	if(renderBorder)
		RenderBorder(renderState);

	glUseProgram(shader->program);
    
    /*RigidBody **objects = physics->GetObjects();
    int amountObjects = physics->AmountObjects();
    for(int i = 0; i < amountObjects; ++i){
        if(objects[i])
            objects[i]->Render(renderState);
    }*/
    
    // Render Spaceship
    if(spaceship)
    	RenderSpaceShip(renderState);

	//PrintSentence(renderState, "Made by Blankycan", Vector2f(1.5f * 16.f * (float)windowState->GetWindow()->GetXPixel(), -4.5f * 16.f * (float)windowState->GetWindow()->GetYPixel()));

    
	glUseProgram(shader->program);
   
   
	glUseProgram(0);
}
Esempio n. 4
0
void RenderingView::paintGL() 
{
    glDisable(GL_SCISSOR_TEST);
    glClear(GL_COLOR_BUFFER_BIT);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    RocketSystem::getInstance().getContext()->Update();

    glScalef(GraphicSystem::scaleFactor,GraphicSystem::scaleFactor,1.0f);
    glTranslatef(positionOffset.x,positionOffset.y,0.0f);
    GraphicSystem::scissorOffset = positionOffset;

    glEnable(GL_TEXTURE_2D);
    glDisable( GL_BLEND );
    GraphicSystem::drawBackground();
    glEnable( GL_BLEND );
    glDisable(GL_TEXTURE_2D);

    drawAxisGrid();
    if (displayGrid)
        RenderGrid(RocketSystem::getInstance().getContext()->GetDimensions().x, RocketSystem::getInstance().getContext()->GetDimensions().y, GraphicSystem::scaleFactor, 10, 10, 4, true);

    RocketSystem::getInstance().getContext()->Render();

    glDisable(GL_TEXTURE_2D);
    glDisable(GL_SCISSOR_TEST);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glScalef(GraphicSystem::scaleFactor,GraphicSystem::scaleFactor,1.0f);
    glTranslatef(positionOffset.x,positionOffset.y,0.0f);

    if (!currentDocument)
        return;

    ToolManager::getInstance().getCurrentTool()->onRender();
}
void TerrainTilesPanel::OnRender(ion::render::Renderer& renderer, const ion::Matrix4& cameraInverseMtx, const ion::Matrix4& projectionMtx, float& z, float zOffset)
{
	//Render canvas
	RenderCanvas(renderer, cameraInverseMtx, projectionMtx, z);

	z += zOffset;

	//Render selected TerrainTile
	if(m_selectedTerrainTile != InvalidTerrainTileId)
	{
		if(TerrainTile* terrainTile = m_project.GetTerrainTileset().GetTerrainTile(m_selectedTerrainTile))
		{
			ion::Vector2 size(1, 1);
			const ion::Colour& colour = m_renderResources.GetColour(RenderResources::eColourSelected);
			RenderBox(m_selectedTerrainTilePos, size, colour, renderer, cameraInverseMtx, projectionMtx, z);
		}
	}

	z += zOffset;

	//Render mouse hover TerrainTile
	if(m_hoverTerrainTile != InvalidTerrainTileId && m_hoverTerrainTile != m_selectedTerrainTile)
	{
		if(TerrainTile* terrainTile = m_project.GetTerrainTileset().GetTerrainTile(m_hoverTerrainTile))
		{
			ion::Vector2 size(1, 1);
			const ion::Colour& colour = m_renderResources.GetColour(RenderResources::eColourHighlight);
			RenderBox(m_hoverTerrainTilePos, size, colour, renderer, cameraInverseMtx, projectionMtx, z);
		}
	}

	z += zOffset;

	//Render grid
	if(m_project.GetShowGrid())
	{
		RenderGrid(renderer, cameraInverseMtx, projectionMtx, z);
	}
}
Esempio n. 6
0
int CALLBACK WinMain(HINSTANCE Instance,
	HINSTANCE PrevInstance,
	LPSTR     CmdLine,
	int       CmdShow)
{
	WNDCLASS wc = { 0 };
	ResizeDIBSection(&GlobalBackbuffer, WINSIZE + 17, WINSIZE + 41);
	wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
	wc.lpfnWndProc = WindowCallback;
	wc.hInstance = Instance;
	wc.lpszClassName = "LifeWindowClass";
	RegisterClass(&wc);
	HWND Window =
		CreateWindowEx(
			0,
			wc.lpszClassName,
			"Game of Life",
			WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE,
			CW_USEDEFAULT,
			CW_USEDEFAULT,
			WINSIZE + 17,
			WINSIZE + 41,
			0,
			0,
			Instance,
			0);
	DeviceContext = GetDC(Window);
	srand(time(NULL));
	globalRunning = 1;
	globalIterating = globalMode = gridLines = highlight = 0;
	screen = 1; //0 is main grid, 1 is menu, 2 is load list
	str = (unsigned char *)malloc(MAX_PATH);
	int MSElapsed = 0;
	sleepTime = 128; //milliseconds
	ResetGrid();
	RenderMenuScreen();

	LARGE_INTEGER perfCountFrequencyResult;
	QueryPerformanceFrequency(&perfCountFrequencyResult);
	long long perfCountFrequency = perfCountFrequencyResult.QuadPart;
	LARGE_INTEGER lastCounter;
	QueryPerformanceCounter(&lastCounter);
	while (globalRunning)
	{
		MSG Message;
		while (PeekMessage(&Message, 0, 0, 0, PM_REMOVE))
		{
			if (Message.message == WM_QUIT)
			{
				globalRunning = 0;
			}
			TranslateMessage(&Message);
			DispatchMessage(&Message);
		}

		switch (screen)
		{
			case 0:
				if (globalIterating == 1)
				{
					Sleep(1);
					LARGE_INTEGER endCounter;
					QueryPerformanceCounter(&endCounter);
					long long counterElapsed = endCounter.QuadPart - lastCounter.QuadPart;
					MSElapsed += (1000 * counterElapsed) / perfCountFrequency;
					lastCounter = endCounter;
					if (MSElapsed >= sleepTime)
					{
						Iterate();
						RenderGrid();
						MSElapsed = 0;
					}
				}
				else
				{
					Sleep(50);
				}
				break;
			default:
				Sleep(50);
				break;
		}
		Display();
	}
	return 0;
}
Esempio n. 7
0
LRESULT CALLBACK WindowCallback(
	HWND   Window,
	UINT   Message,
	WPARAM wParam,
	LPARAM lParam)
{
	LRESULT Result = 0;
	struct window_dimension Dimension = GetWindowDimension(Window);
	switch (Message)
	{
		case WM_LBUTTONDOWN:
		{
			if (globalIterating == 0 && screen == 0)
			{
				int xPos = GET_X_LPARAM(lParam);
				int yPos = GET_Y_LPARAM(lParam);
				xPos -= GRIDOFFSET;
				yPos -= GRIDOFFSET;
				switch (grid[xPos / SPACING][yPos / SPACING].state)
				{
					case 0:
						grid[xPos / SPACING][yPos / SPACING].state = 1;
						grid[xPos / SPACING][yPos / SPACING].color = 255;
						break;
					case 1:
						grid[xPos / SPACING][yPos / SPACING].state = 0;
						break;
				}
				RenderGrid();
			}
		}break;

		case WM_RBUTTONDOWN:
		{
			if (globalIterating == 0 && screen == 0 && globalMode != 0)
			{
				int xPos = GET_X_LPARAM(lParam) - GRIDOFFSET;
				int yPos = GET_Y_LPARAM(lParam) - GRIDOFFSET;
				if (grid[xPos / SPACING][yPos / SPACING].state == 1)
				{
					if (grid[xPos / SPACING][yPos / SPACING].color < 128)
					{
						grid[xPos / SPACING][yPos / SPACING].color = 255;
					}
					else
					{
						grid[xPos / SPACING][yPos / SPACING].color = 0;
					}
				}
				RenderGrid();
			}
		}break;

		case WM_KEYDOWN:
			switch (wParam)
			{
				case VK_SPACE:
					switch (globalIterating)
					{
						case 0:
							globalIterating = 1;
							break;
						case 1:
							globalIterating = 0;
							break;
					}
					break;

				case VK_UP:
					switch (screen)
					{
						case 0:
							sleepTime /= 2;
							break;
						case 1:
							if (highlight > 0)
							{
								highlight--;
							}
							RenderMenuScreen();
							break;
						case 2:
							if (highlight > 0)
							{
								highlight--;
							}
							ClearScreen();
							RenderLoadScreen();
							break;
					}
					break;

				case VK_DOWN:
					switch (screen)
					{
						case 0:
							if (sleepTime == 0)
							{
								sleepTime = 1;
							}
							else
							{
								sleepTime *= 2;
							}
							break;
						case 1:
							if (highlight < 2)
							{
								highlight++;
							}
							RenderMenuScreen();
							break;
						case 2:
							highlight++;
							ClearScreen();
							RenderLoadScreen();
							break;
					}
					break;

				case VK_ESCAPE:
					screen = 1;
					globalIterating = 0;
					ClearScreen();
					highlight = 0;
					RenderMenuScreen();
					break;

				case VK_RETURN:
					switch (screen)
					{
						case 1:
							screen = 0;
							globalIterating = 0;
							ClearScreen();
							ResetGrid();
							globalMode = highlight;
							RenderGrid();
							break;
						case 2:
							FILE *fp;
							fp = fopen(fileList[highlight], "r");
							int X, Y, length, skip;
							X = Y = length = skip = 0;
							ResetGrid();
							while (X < GRIDSIZE)
							{
								unsigned char state = fgetc(fp);
								if (skip == 1)
								{
									if (state == '\n')
									{
										skip = 0;
									}
									continue;
								}
								switch (state)
								{
									case 255:
										X = GRIDSIZE;
										break;
									case '.':
										gridTemp[X++][Y].state = 0;
										break;
									case 'O':
										gridTemp[X++][Y].state = 1;
										break;
									case '\n':
										if (X > length)
										{
											length = X;
										}
										X = 0;
										Y++;
										break;
									case '!':
										skip = 1;
										break;
								}
							}
							fclose(fp);
							int xShift = (GRIDSIZE - length) / 2;
							int yShift = (GRIDSIZE - Y) / 2;
							int height = Y;
							for (int Y = 0; Y <= height; Y++)
							{
								for (int X = 0; X <= length; X++)
								{
									grid[X + xShift][Y + yShift].state = gridTemp[X][Y].state;
									grid[X + xShift][Y + yShift].color = 255;
								}
							}
							globalIterating = 0;
							screen = 0;
							ClearScreen();
							RenderGrid();
							break;
					}
					break;

				case 0x43: //c, clears
					if (screen == 0)
					{
						ResetGrid();
						globalIterating = 0;
						RenderGrid();
					}
					break;

				case 0x47: //g, toggles grid
					switch (gridLines)
					{
						case 0:
							gridLines = 1;
							break;
						case 1:
							gridLines = 0;
							break;
					}
					RenderGrid();
					break;

				case 0x4C: //l, loads
					if (screen == 0)
					{
						unsigned char *pathPointer;
						pathPointer = str;
						GetModuleFileName(NULL, str, MAX_PATH);
						pathPointer += strlen(str);
						while (*(pathPointer - 1)  != '\\')
						{
							pathPointer--;
						}
						strcpy(pathPointer, "*.cells");
						WIN32_FIND_DATA data;
						HANDLE h = FindFirstFile(str, &data);
						if (GetLastError() == ERROR_FILE_NOT_FOUND)
						{
							FindClose(h);
							break;
						}
						strcpy(pathPointer, data.cFileName);
						strcpy(fileList[0], str);
						for (int i = 1; i < MAXFILES; i++)
						{
							FindNextFile(h, &data);
							if (GetLastError() == ERROR_NO_MORE_FILES)
							{
								FindClose(h);;
								break;
							}
							strcpy(pathPointer, data.cFileName);
							strcpy(fileList[i], str);
						}
						screen = 2;
						highlight = 0;
						ClearScreen();
						RenderLoadScreen();
					}
					break;

				case 0x52: //r, randomize
					if (screen == 0)
					{
						Randomize(100);
						globalIterating = 0;
						RenderGrid();
					}
					break;
			} break;

		case WM_DESTROY:
			globalRunning = 0;
			free(str);
			break;

		case WM_CLOSE:
			globalRunning = 0;
			free(str);
			break;

		case WM_ACTIVATEAPP:
			break;

		case WM_PAINT:
		{
			PAINTSTRUCT Paint;
			HDC devicecontext = BeginPaint(Window, &Paint);
			Display();
			EndPaint(Window, &Paint);
		} break;

		default:
			Result = DefWindowProc(Window, Message, wParam, lParam);
			break;

	return(Result);
	}
}
Esempio n. 8
0
void OculusWorldDemoApp::RenderEyeView(ovrEyeType eye)
{
    Recti    renderViewport = EyeTexture[eye].Header.RenderViewport;
    Matrix4f viewAdjust     = Matrix4f::Translation(Vector3f(EyeRenderDesc[eye].ViewAdjust));


    // *** 3D - Configures Viewport/Projection and Render
    
    pRender->ApplyStereoParams(renderViewport, Projection[eye]);
    pRender->SetDepthMode(true, true);

    Matrix4f baseTranslate = Matrix4f::Translation(ThePlayer.BodyPos);
    Matrix4f baseYaw       = Matrix4f::RotationY(ThePlayer.BodyYaw.Get());


    if (GridDisplayMode != GridDisplay_GridOnly)
    {
        if (SceneMode != Scene_OculusCubes)
        {
            MainScene.Render(pRender, viewAdjust * View);        
            RenderAnimatedBlocks(eye, ovr_GetTimeInSeconds());
        }
	    
        if (SceneMode == Scene_Cubes)
	    {
            // Draw scene cubes overlay. Red if position tracked, blue otherwise.
            Scene sceneCubes = (HmdStatus & ovrStatus_PositionTracked) ?
                               RedCubesScene : BlueCubesScene;        
            sceneCubes.Render(pRender, viewAdjust * View * baseTranslate * baseYaw);
        }

	    else if (SceneMode == Scene_OculusCubes)
	    {
            OculusCubesScene.Render(pRender, viewAdjust * View * baseTranslate * baseYaw);
        }
    }   

    if (GridDisplayMode != GridDisplay_None)
    {
        RenderGrid(eye);
    }


    // *** 2D Text - Configure Orthographic rendering.

    // Render UI in 2D orthographic coordinate system that maps [-1,1] range
    // to a readable FOV area centered at your eye and properly adjusted.
    pRender->ApplyStereoParams(renderViewport, OrthoProjection[eye]);
    pRender->SetDepthMode(false, false);

    // We set this scale up in CreateOrthoSubProjection().
    float textHeight = 22.0f;

    // Display Loading screen-shot in frame 0.
    if (LoadingState != LoadingState_Finished)
    {
        const float scale = textHeight * 25.0f;
        Matrix4f view ( scale, 0.0f, 0.0f, 0.0f, scale, 0.0f, 0.0f, 0.0f, scale );
        LoadingScene.Render(pRender, view);
        String loadMessage = String("Loading ") + MainFilePath;
        DrawTextBox(pRender, 0.0f, -textHeight, textHeight, loadMessage.ToCStr(), DrawText_HCenter);
        LoadingState = LoadingState_DoLoad;
    }

    // HUD overlay brought up by spacebar.
    RenderTextInfoHud(textHeight);

    // Menu brought up by 
    Menu.Render(pRender);
}
Esempio n. 9
0
void RenderGrid(const CViewPoint *view_point){
	RenderGrid(view_point, 0);
}
Esempio n. 10
0
static void RenderGrid(const CViewPoint *view_point, int plane)
{
	switch(wxGetApp().grid_mode){
	case 1:
		{
			const HeeksColor& bg = wxGetApp().background_color[0];
			HeeksColor cc = bg.best_black_or_white();
			gp_Vec v_bg((double)bg.red, (double)bg.green, (double)bg.blue);
			gp_Vec v_cc((double)cc.red, (double)cc.green, (double)cc.blue);
			gp_Vec v_contrast = v_cc - v_bg;
			gp_Vec unit_contrast = v_contrast.Normalized();
			double l1, l2, l3;
			if(v_cc * gp_Vec(1,1,1)>0){
				l1 = 200;
				l2 = 130;
				l3 = 80;
			}
			else{
				l1 = 100;
				l2 = 30;
				l3 = 10;
			}
			if(l1>v_contrast.Magnitude())l1 = v_contrast.Magnitude();
			if(l2>v_contrast.Magnitude())l2 = v_contrast.Magnitude();
			if(l3>v_contrast.Magnitude())l3 = v_contrast.Magnitude();
			gp_Vec uf = (view_point->forwards_vector()).Normalized();
			gp_Vec vx, vy;
			view_point->GetTwoAxes(vx, vy, false, plane);
			gp_Pnt datum(0, 0, 0);
			gp_Trsf orimat = wxGetApp().GetDrawMatrix(false);
			datum = datum.Transformed(orimat);
			orimat = make_matrix(datum, vx, vy);
			gp_Vec v_up = gp_Vec(0,0, 1).Transformed(orimat);
			double fufz = fabs(uf * v_up);
			if(fufz<0.7){
				double there = (fufz - 0.3) / 0.4;
				l1 *= there;
				l2 *= there;
			}
			gp_Vec v_gc1 = v_bg + unit_contrast * l1;
			gp_Vec v_gc2 = v_bg + unit_contrast * l2;
			gp_Vec v_gc3 = v_bg + unit_contrast * l3;
			glColor3ub((unsigned char)(v_gc3.X()), (unsigned char)(v_gc3.Y()), (unsigned char)(v_gc3.Z()));
			RenderGrid(view_point, 200, false, true, NULL, NULL, 0, plane);
			glColor3ub((unsigned char)(v_gc2.X()), (unsigned char)(v_gc2.Y()), (unsigned char)(v_gc2.Z()));
			RenderGrid(view_point, 20, true, false, NULL, NULL, 0, plane);
			glColor3ub((unsigned char)(v_gc1.X()), (unsigned char)(v_gc1.Y()), (unsigned char)(v_gc1.Z()));
			RenderGrid(view_point, 20, false, false, NULL, NULL, 0, plane);
		}
		break;

	case 2:
	case 3:
		{
			const HeeksColor& bg = wxGetApp().background_color[0];
			HeeksColor cc = bg.best_black_or_white();
			bool light_color = cc.red + cc.green + cc.blue > 384;
			wxGetApp().EnableBlend();
			RenderGrid(view_point, 200, false, true, &bg, &cc, light_color ? 40:10, plane);
			RenderGrid(view_point, 20, true, false, &bg, &cc, light_color ? 80:20, plane);
			RenderGrid(view_point, 20, false, false, &bg, &cc, light_color ? 120:30, plane);
			wxGetApp().DisableBlend();
		}
		break;
	}
}
Esempio n. 11
0
/*
================
rvGEWorkspace::Render

Renders the workspace to the given DC
================
*/
void rvGEWorkspace::Render ( HDC hdc )
{
	int		front;
	int		back;
	float	scale;

	scale = g_ZoomScales[mZoom];

	// Switch GL contexts to our dc
	if (!qwglMakeCurrent( hdc, win32.hGLRC ))
	{
		common->Printf("ERROR: wglMakeCurrent failed.. Error:%i\n", qglGetError());
		common->Printf("Please restart Q3Radiant if the Map view is not working\n");
		return;
	}

	// Prepare the view and clear it
	GL_State( GLS_DEFAULT );
	qglViewport(0, 0, mWindowWidth, mWindowHeight );
	qglScissor(0, 0, mWindowWidth, mWindowHeight );
	qglClearColor ( 0.75f, 0.75f, 0.75f, 0 );

	qglDisable(GL_DEPTH_TEST);
	qglDisable(GL_CULL_FACE);
	qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Render the workspace below
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	qglOrtho(0,mWindowWidth, mWindowHeight, 0, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	qglColor3f ( mApplication->GetOptions().GetWorkspaceColor()[0], mApplication->GetOptions().GetWorkspaceColor()[1], mApplication->GetOptions().GetWorkspaceColor()[2] );
	qglBegin ( GL_QUADS );
	qglVertex2f ( mRect.x, mRect.y );
	qglVertex2f ( mRect.x + mRect.w, mRect.y );
	qglVertex2f ( mRect.x + mRect.w, mRect.y + mRect.h );
	qglVertex2f ( mRect.x, mRect.y + mRect.h );
	qglEnd ( );

	// Prepare the renderSystem view to draw the GUI in
	viewDef_t viewDef;
	memset ( &viewDef, 0, sizeof(viewDef) );
	tr.viewDef = &viewDef;
	tr.viewDef->renderView.x = mRect.x;
	tr.viewDef->renderView.y = mWindowHeight - mRect.y - mRect.h;
	tr.viewDef->renderView.width = mRect.w;
	tr.viewDef->renderView.height = mRect.h;
	tr.viewDef->scissor.x1 = 0;
	tr.viewDef->scissor.y1 = 0;
	tr.viewDef->scissor.x2 = mRect.w;
	tr.viewDef->scissor.y2 = mRect.h;
	tr.viewDef->isEditor = true;
	renderSystem->BeginFrame(mWindowWidth, mWindowHeight );

	// Draw the gui
	mInterface->Redraw ( 0 ); // eventLoop->Milliseconds() );

	// We are done using the renderSystem now
	renderSystem->EndFrame( &front, &back );

	if ( mApplication->GetActiveWorkspace ( ) == this )
	{
		mApplication->GetStatusBar().SetTriangles ( backEnd.pc.c_drawIndexes/3 );
	}

	// Prepare the viewport for drawing selections, etc.
	GL_State( GLS_DEFAULT );
	qglDisable( GL_TEXTURE_CUBE_MAP_EXT );
//	qglDisable(GL_BLEND);
	qglDisable(GL_CULL_FACE);

	qglViewport(0, 0, mWindowWidth, mWindowHeight );
	qglScissor(0, 0, mWindowWidth, mWindowHeight );
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	qglOrtho(0,mWindowWidth, mWindowHeight, 0, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	RenderGrid ( );

	mSelections.Render ( );

	qglFinish ( );
	qwglSwapBuffers(hdc);

	qglEnable( GL_TEXTURE_CUBE_MAP_EXT );
	qglEnable( GL_CULL_FACE);
}
Esempio n. 12
0
QCSXCAD::QCSXCAD(QWidget *parent) : QMainWindow(parent)
{
	QStringList argList=qApp->arguments();
	for (int i=1;i<argList.size();++i)
	{
		if (argList.at(i).startsWith("-"))
			QCSX_Settings.parseCommandLineArgument(argList.at(i));
	}

	m_ViewDir = 2;

	m_RenderDiscModels = QCSX_Settings.GetRenderDiscMaterial();

	StructureVTK = new QVTKStructure();
	StructureVTK->SetGeometry(this);

	setCentralWidget(StructureVTK->GetVTKWidget());

	CSTree = new QCSTreeWidget(this);
	QObject::connect(CSTree,SIGNAL(Edit()),this,SLOT(Edit()));
	QObject::connect(CSTree,SIGNAL(Copy()),this,SLOT(Copy()));
	QObject::connect(CSTree,SIGNAL(ShowHide()),this,SLOT(ShowHide()));
	QObject::connect(CSTree,SIGNAL(Delete()),this,SLOT(Delete()));
	QObject::connect(CSTree,SIGNAL(NewBox()),this,SLOT(NewBox()));
	QObject::connect(CSTree,SIGNAL(NewMultiBox()),this,SLOT(NewMultiBox()));
	QObject::connect(CSTree,SIGNAL(NewSphere()),this,SLOT(NewSphere()));
	QObject::connect(CSTree,SIGNAL(NewCylinder()),this,SLOT(NewCylinder()));
	QObject::connect(CSTree,SIGNAL(NewUserDefined()),this,SLOT(NewUserDefined()));

	QObject::connect(CSTree,SIGNAL(NewMaterial()),this,SLOT(NewMaterial()));
	QObject::connect(CSTree,SIGNAL(NewMetal()),this,SLOT(NewMetal()));
	QObject::connect(CSTree,SIGNAL(NewExcitation()),this,SLOT(NewExcitation()));
	QObject::connect(CSTree,SIGNAL(NewChargeBox()),this,SLOT(NewChargeBox()));
	QObject::connect(CSTree,SIGNAL(NewResBox()),this,SLOT(NewResBox()));
	QObject::connect(CSTree,SIGNAL(NewDumpBox()),this,SLOT(NewDumpBox()));

	QDockWidget *dock = new QDockWidget(tr("Properties and Structures"),this);
	dock->setAllowedAreas(Qt::LeftDockWidgetArea);
	dock->setWidget(CSTree);
	dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
	dock->setObjectName("Properties_and_Structures_Dock");

	addDockWidget(Qt::LeftDockWidgetArea,dock);

	GridEditor = new QCSGridEditor(&clGrid);
	QObject::connect(GridEditor,SIGNAL(OpacityChange(int)),StructureVTK,SLOT(SetGridOpacity(int)));
	QObject::connect(GridEditor,SIGNAL(signalDetectEdges(int)),this,SLOT(DetectEdges(int)));
	QObject::connect(GridEditor,SIGNAL(GridChanged()),StructureVTK,SLOT(RenderGrid()));
	QObject::connect(GridEditor,SIGNAL(GridPlaneXChanged(int)),StructureVTK,SLOT(RenderGridX(int)));
	QObject::connect(GridEditor,SIGNAL(GridPlaneYChanged(int)),StructureVTK,SLOT(RenderGridY(int)));
	QObject::connect(GridEditor,SIGNAL(GridPlaneZChanged(int)),StructureVTK,SLOT(RenderGridZ(int)));

	dock = new QDockWidget(tr("Rectilinear Grid"),this);
	dock->setAllowedAreas(Qt::LeftDockWidgetArea);
	dock->setWidget(GridEditor);
	dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
	dock->setObjectName("Rectilinear_Grid_Dock");
	addDockWidget(Qt::LeftDockWidgetArea,dock);

	QParaSet= new QParameterSet();
	QObject::connect(QParaSet,SIGNAL(ParameterChanged()),this,SLOT(CheckGeometry()));
	QObject::connect(QParaSet,SIGNAL(ParameterChanged()),this,SLOT(setModified()));
	clParaSet=QParaSet;

	dock = new QDockWidget(tr("Rectilinear Grid - Plane Position"),this);
	dock->setAllowedAreas(Qt::LeftDockWidgetArea);
	dock->setWidget(GridEditor->BuildPlanePosWidget());
	dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
	dock->setObjectName("Grid_Plane_Pos");
	addDockWidget(Qt::LeftDockWidgetArea,dock);

	dock = new QDockWidget(tr("Parameter"),this);
	dock->setAllowedAreas(Qt::LeftDockWidgetArea);
	dock->setWidget(QParaSet);
	dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
	dock->setObjectName("Parameter_Dock");
	addDockWidget(Qt::LeftDockWidgetArea,dock);

	BuildToolBar();

	bModified=true;
	GridEditor->SetOpacity(30);
	Render();
}