Example #1
0
 public void resize()
 {
     if (isCongruent())
     {
         int width  = glControl_.Width;
         int height = glControl_.Height;
         projection_ = Matrix4.CreateOrthographic(width, height, DrawOptions.zNear, DrawOptions.zFar);
         // Update drawing constants
         DrawOptions.update(glControl_.Width, glControl_.Height);
         // Coordinate system position
         coordinateSystemOrigin_.X        *= (float)width / prevControlWidth_;
         coordinateSystemOrigin_.Y        *= (float)height / prevControlHeight_;
         coordinateSystemScaleTranslation_ = Matrix4.CreateScale(DrawOptions.defaultScale, DrawOptions.defaultScale, 1.0f) * Matrix4.CreateTranslation(coordinateSystemOrigin_);
         prevControlWidth_  = glControl_.Width;
         prevControlHeight_ = glControl_.Height;
     }
 }
Example #2
0
        public void initializeGL()
        {
            GL.ClearColor(Color4.White);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);
            // Blending
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
            // Z-buffer
            GL.ClearDepth(1.0f);
            GL.DepthMask(true);
            GL.DepthFunc(DepthFunction.Lequal);
            GL.Enable(EnableCap.DepthTest);
            // Stencil
            GL.ClearStencil(0);
            GL.Enable(EnableCap.StencilTest);
            GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Replace);
            // Smoothing
            GL.Enable(EnableCap.PolygonSmooth);
            GL.Enable(EnableCap.LineSmooth);
            GL.Hint(HintTarget.PolygonSmoothHint, HintMode.Nicest);
            GL.Hint(HintTarget.LineSmoothHint, HintMode.Nicest);
            GL.Hint(HintTarget.PointSmoothHint, HintMode.Nicest);
            // Sizes
            GL.PointSize(DrawOptions.pointSize);
            GL.LineWidth(DrawOptions.lineWidth);
            // Defining all the colors for further selection
            availableColors_ = new List <Color4>()
            {
                Color4.Blue, Color4.Green, Color4.DarkOrange,
                Color4.Red, Color4.SaddleBrown, Color4.Purple,
                Color4.DarkBlue, Color4.DarkCyan, Color4.Chocolate
            };
            selection_         = new Dictionary <string, List <uint> >();
            sequenceSelection_ = new List <string>();
            selectionColor_    = Color4.HotPink;
            // Update drawing constants
            DrawOptions.update(glControl_.Width, glControl_.Height);
            // Transformations
            location_         = Vector3.Zero;
            modelTranslation_ = Matrix4.Identity;
            modelScale_       = Matrix4.CreateScale(DrawOptions.defaultScale, DrawOptions.defaultScale, 1.0f);
            modelRotation_    = Matrix4.Identity;
            view_             = Matrix4.Identity;
            projection_       = Matrix4.CreateOrthographic(glControl_.Width, glControl_.Height, DrawOptions.zNear, DrawOptions.zFar);
            // Markers
            isShowNodeMarkers = true;
            // Fonts
            isShowNodeNames = false;
            fontDrawing_    = new QFontDrawing();
            var builderConfig = new QFontBuilderConfiguration(true)
            {
                TextGenerationRenderHint = TextGenerationRenderHint.ClearTypeGridFit,
                Characters = CharacterSet.General | CharacterSet.Japanese | CharacterSet.Thai | CharacterSet.Cyrillic
            };

            font_ = new QFont("Optima", 8, builderConfig);
            fontRenderOptions_ = new QFontRenderOptions()
            {
                Colour           = Color.Black,
                DropShadowActive = false,
                CharacterSpacing = 0.1f
            };
            // Compiling the shader
            shader_ = new Shader(shaderPath_ + "shaders/shader.vert", shaderPath_ + "shaders/shader.frag");
            // Lighting
            isLighting = true;
            shader_.SetVector3("light.ambient", LightingOptions.lightAmbient);
            shader_.SetVector3("light.diffuse", LightingOptions.lightDiffuse);
            shader_.SetVector3("light.specular", LightingOptions.lightSpecular);
            // Light attenuation constants
            shader_.SetFloat("light.constant", LightingOptions.lightConstant);
            shader_.SetFloat("light.linear", LightingOptions.lightLinear);
            shader_.SetFloat("light.quadratic", LightingOptions.lightQuadratic);
            // Material
            shader_.SetVector3("material.ambient", LightingOptions.materialAmbient);
            shader_.SetVector3("material.diffuse", LightingOptions.materialDiffuse);
            shader_.SetVector3("material.specular", LightingOptions.materialSpecular);
            shader_.SetFloat("material.shininess", LightingOptions.materialShininess);
            // Coordinate system
            coordinateSystem_                 = new CoordinateSystem();
            coordinateSystem_.font            = font_;
            coordinateSystem_.shader          = shader_;
            coordinateSystemOrigin_           = new Vector3(DrawOptions.originSystemX, DrawOptions.originSystemY, DrawOptions.originSystemZ);
            coordinateSystemScaleTranslation_ = Matrix4.CreateScale(DrawOptions.defaultScale, DrawOptions.defaultScale, 1.0f) * Matrix4.CreateTranslation(coordinateSystemOrigin_);
            // Viewport
            prevControlWidth_  = glControl_.Width;
            prevControlHeight_ = glControl_.Height;
        }