private void GetParameters(ParameterSet parameters) { try { foreach (Parameter param in parameters) { var paramName = param.Definition.Name; if (paramName.Contains(".Extensions")) { continue; } if (param.Id.IntegerValue == (int)BuiltInParameter.VIEWER_VOLUME_OF_INTEREST_CROP) { ScopeBoxId = param.AsElementId(); continue; } if (param.Id.IntegerValue == (int)BuiltInParameter.VIEW_PHASE) { PhaseId = param.AsElementId(); continue; } if (param.StorageType == StorageType.None || param.StorageType == StorageType.ElementId) { continue; } if (!ViewParameters.ContainsKey(paramName) && param.HasValue) { ViewParameters.Add(paramName, param); } } } catch (Exception) { // ignored } }
public static string CreateSelectStatement(string columns, string name, ViewParameters parameters) { StringBuilder builder = new StringBuilder(); string selectedColumns = string.IsNullOrEmpty(columns) ? SelectAllColumns : columns; builder.Append(String.Format(SelectTemplate, selectedColumns, name)); if (parameters.WhereParameters != null && parameters.WhereParameters.Any()) { builder.Append(WhereStatement); foreach (DbQueryParameter parameter in parameters.WhereParameters) { AppendParameter(builder, parameter); } if (parameters.GroupByParameters != null && parameters.GroupByParameters.Count > 0) { builder.Append(string.Format(GroupByTemplate, parameters.GroupByParameters[0].ParameterName)); for (int i = 1; i < parameters.GroupByParameters.Count; i++) { builder.Append(", " + parameters.GroupByParameters[i].ParameterName); } } if (parameters.OrderByParameters != null && parameters.OrderByParameters.Count > 0) { builder.Append(string.Format(OrderByTemplate, parameters.OrderByParameters[0].ParameterName, parameters.OrderByParameters[0].ParameterValue)); for (int i = 1; i < parameters.OrderByParameters.Count; i++) { builder.Append(string.Format(", {0} {1}", parameters.OrderByParameters[i].ParameterName, parameters.OrderByParameters[i].ParameterValue)); } } } return(builder.ToString()); }
public override void paint(Graphics g, bool drawHandles, ViewParameters parameters) { g.SmoothingMode = SmoothingMode.HighQuality; g.InterpolationMode = InterpolationMode.HighQualityBicubic; Brush arrowBrush = shape.ShapeBrush; PointF ps = shape.Handles["start"]; PointF pe = shape.Handles["end"]; PointF[] points = a.calculatePoints(ps, getLength(ps, pe), getArc(ps, pe)); Point[] ptsAbs = new Point[points.Length]; Point[] pointsOffs = new Point[points.Length]; for (int i = 0; i < points.Length; ++i) { ptsAbs[i] = pointsOffs[i] = parameters.toAbsolute(points[i]); pointsOffs[i].Offset((int)(Constants.SHADOW_X * parameters.ZoomRatio), (int)(Constants.SHADOW_Y * parameters.ZoomRatio)); } if (a.sp.chkUseShadow.Checked) { Brush shadowBrush = new SolidBrush(Constants.SHADOW_COLOR); g.FillPolygon(shadowBrush, pointsOffs); shadowBrush.Dispose(); } g.FillPolygon(arrowBrush, ptsAbs); base.paint(g, drawHandles, parameters); arrowBrush.Dispose(); }
public void TestCreateSelectStatementSuccessfully(bool wherePresent, bool orderByPresent, bool groupByPresent, string tableName, string expectedSelectStatement) { ViewParameters viewParams = GetTestParameters(wherePresent, orderByPresent, groupByPresent); string actualSelectStatement = SqlStatmentsGenerator.CreateSelectStatement(null, tableName, viewParams); Assert.Equal(expectedSelectStatement, actualSelectStatement); }
private void drawShadow(Graphics g, Rectangle r, ViewParameters parameters, Color shadowColor) { Bitmap b = new Bitmap(r.Width + (int)(40 * parameters.ZoomRatio), r.Height + (int)(40 * parameters.ZoomRatio)); Graphics gr = Graphics.FromImage(b); GraphicsPath pth = new GraphicsPath(); Pen p = new Pen(shadowColor, Math.Max(12f * parameters.ZoomRatio, 2)) { LineJoin = LineJoin.Round, EndCap = LineCap.Round, StartCap = LineCap.Round }; pth.AddString(t.Text, editorFont.FontFamily, (int)t.sp.buttonFont.Font.Style, editorFont.Size, new Point((int)(10 * parameters.ZoomRatio), (int)(10 * parameters.ZoomRatio)), StringFormat.GenericTypographic); gr.DrawPath(p, pth); // lame blurring :) for (int i = 0; i < 20; i = i + 2) { for (int j = 0; j < 20; j = j + 2) { g.DrawImageUnscaled(b, new Point((int)((-2.5 + i) * parameters.ZoomRatio), (int)((-2.5 + j) * parameters.ZoomRatio))); } } b.Dispose(); p.Dispose(); pth.Dispose(); }
private void addEditor() { Editor = new BrutallyKillableTextBox(delegate { deactivate(); editor.invalidateView(); }); // Editor = new RichTextBox(); ViewParameters p = editor.CurrentViewParameters; Rectangle r = ShapeView.getShapeRectangle(Handles["start"], Handles["end"], p); Editor.Location = new Point(r.Location.X + p.Scrolls.X, r.Location.Y + p.Scrolls.Y); Editor.Size = r.Size; Editor.BorderStyle = BorderStyle.None; Editor.ScrollBars = RichTextBoxScrollBars.None; Editor.DetectUrls = false; Editor.Font = new Font(sp.buttonFont.Font.FontFamily, REL_SIZE * ShapeView.scaledThickness(this, p), sp.buttonFont.Font.Style, GraphicsUnit.Pixel, 0); Editor.ForeColor = editorColor; Editor.BackColor = getPerceivedBrightness(editorColor) > 0x80 ? Color.DarkGray : Color.LightGray; Editor.HideSelection = false; // bug #52 - max length of the text input no longer makes sense for multi-line editors // Editor.MaxLength = 100; Editor.Multiline = true; Editor.AcceptsTab = true; Editor.WordWrap = false; Editor.Name = "editor"; Editor.TabIndex = 0; Editor.TabStop = false; Editor.Text = Text ?? ""; Editor.Anchor = AnchorStyles.None; editor.addControl(Editor); TextView v = (TextView)getView(); v.setTextChangeHandler(Editor); }
private ViewParameters GetTestParameters(bool useWhereParameters, bool useOrderByParams, bool useGroupByParams) { ViewParameters parameters = new ViewParameters(); if (useWhereParameters) { List <DbQueryParameter> whereParams = new List <DbQueryParameter>(); whereParams.Add(new DbQueryParameter(null, "City", "IN", "(Yekaterinburg, Moscow, Kazan)")); whereParams.Add(new DbQueryParameter(new[] { JoinCondition.Or }, "Age", ">", "18")); whereParams.Add(new DbQueryParameter(new[] { JoinCondition.And }, "District", "BETWEEN", "Northern AND Southerly")); parameters.WhereParameters = whereParams; } if (useOrderByParams) { List <DbQueryParameter> orderByParams = new List <DbQueryParameter>(); orderByParams.Add(new DbQueryParameter(null, "City", null, "ASC")); orderByParams.Add(new DbQueryParameter(null, "Name", null, "DESC")); parameters.OrderByParameters = orderByParams; } if (useGroupByParams) { List <DbQueryParameter> groupByParams = new List <DbQueryParameter>(); groupByParams.Add(new DbQueryParameter(null, "Age", null, null)); groupByParams.Add(new DbQueryParameter(null, "Name", null, null)); parameters.GroupByParameters = groupByParams; } return(parameters); }
public override void paint(Graphics g, bool drawHandles, ViewParameters parameters) { RectangleF r = getShapeRectangleF(c.Handles["start"], c.Handles["end"]); if (r.Width <= 0 || r.Height <= 0) { return; } Brush b = new SolidBrush(Color.FromArgb(0x80, c.ShapeColor)); Bitmap screenshot = c.editor.getAnnotatedScreenshot(c); if (c.view == null || screenshot != c.previousScreenshot) { if (c.view != null) { c.view.Dispose(); } c.view = c.createCensorBitmap(r, screenshot); c.previousScreenshot = screenshot; } RectangleF rAbs = getShapeRectangle(c.Handles["start"], c.Handles["end"], parameters); g.DrawImage(c.view, rAbs); if (!c.editor.HaveScreenshot || !c.ShapeColor.Equals(c.ShapeColorNoHilight)) { g.FillRectangle(b, rAbs); } base.paint(g, drawHandles, parameters); }
public async Task <DbData> ExtractAsync(string viewName, ViewParameters parameters) { using (DbConnection connection = DbConnectionFactory.Create(_dbEngine, _connectionString)) { try { _logger.LogDebug("Extract db data async via \"View\" started"); DbData result = null; await connection.OpenAsync().ConfigureAwait(false); string cmdText = SqlStatmentsGenerator.CreateSelectStatement(SqlStatmentsGenerator.SelectAllColumns, viewName, parameters); using (IDbCommand command = DbCommandFactory.Create(_dbEngine, connection, cmdText)) { command.CommandType = CommandType.Text; result = await ReadDataImplAsync((DbCommand)command); } connection.Close(); _logger.LogDebug("Extract db data async via \"View\" completed"); return(result); } catch (Exception e) { _logger.LogError($"An error occured during async data extraction via \"View\", exception: {e}"); return(null); } } }
private void CopyParametersToYebis() { // Retrieve defaults if (ViewParameters != null) { yebis.Config.Camera.NearClipPlane = ViewParameters.Get(CameraKeys.NearClipPlane); yebis.Config.Camera.FarClipPlane = ViewParameters.Get(CameraKeys.FarClipPlane); yebis.Config.Camera.FieldOfView = ViewParameters.Get(CameraKeys.FieldOfView); ViewParameters.Get(TransformationKeys.View, out yebis.Config.Camera.View); // Reverse value for Z and recalculate matrix projection yebis.Config.Camera.IsZReverse = yebis.Config.Camera.NearClipPlane > yebis.Config.Camera.FarClipPlane; float nearClipPlane = yebis.Config.Camera.IsZReverse ? yebis.Config.Camera.FarClipPlane : yebis.Config.Camera.NearClipPlane; float farClipPlane = yebis.Config.Camera.IsZReverse ? yebis.Config.Camera.NearClipPlane : yebis.Config.Camera.FarClipPlane; yebis.Config.Camera.NearClipPlane = nearClipPlane; yebis.Config.Camera.FarClipPlane = farClipPlane; var focusDistance = ViewParameters.Get(CameraKeys.FocusDistance); DepthOfField.AutoFocus = (focusDistance < 0.01); if (!DepthOfField.AutoFocus) { DepthOfField.FocusDistance = focusDistance; } } yebis.Config.AntiAlias = AntiAlias; yebis.Config.ToneMap = ToneMap; yebis.Config.Glare = Glare; yebis.Config.ColorCorrection = ColorCorrection; yebis.Config.Lens = Lens; yebis.Config.DepthOfField = DepthOfField; yebis.Config.HeatShimmer = HeatShimmer; yebis.Config.LightShaft = LightShaft; }
public void TestExtractFromViewWithParams(string name, bool?sex, int expectedNumberOfRows) { SetUpTestData(); // testing is here ViewParameters parameters = new ViewParameters(); if (!string.IsNullOrEmpty(name)) { parameters.WhereParameters.Add(new DbQueryParameter(null, "FirstName", "=", name)); } if (sex.HasValue) { IList <JoinCondition> sexJoin = parameters.WhereParameters.Count > 0 ? new List <JoinCondition>() { JoinCondition.And } : null; parameters.WhereParameters.Add(new DbQueryParameter(sexJoin, "Sex", "=", sex.Value ? "1" : "0")); } IDbExtractor extractor = new SimpleDbExtractor(_loggerFactory, DbEngine.SqlServer, GlobalTestsParams.TestSqlServerHost, GlobalTestsParams.TestSqlServerDatabasePattern); Task <DbData> result = extractor.ExtractAsync(TestView, parameters); result.Wait(); DbData rows = result.Result; Assert.Equal(expectedNumberOfRows, rows.Rows.Count); TearDownTestData(); }
public object ComputeFieldValue(IIndexable indexable) { var contactIndexable = indexable as IContactIndexable; if (contactIndexable == null) { return(null); } var contactId = (Guid)contactIndexable.Id.Value; if (contactId == Guid.Empty) { return(null); } var viewParams = new ViewParameters { ContactId = contactId, ViewName = GoalsViewName, ViewEntityId = null }; var resultSet = CustomerIntelligenceManager.ViewProvider.GenerateContactView(viewParams); return(resultSet.Data.Dataset[GoalsViewName].Rows .Cast <DataRow>() .Select(GetGoalIdFromDataRow()) .Distinct()); }
public override void paint(Graphics g, bool drawHandles, ViewParameters parameters) { g.SmoothingMode = SmoothingMode.HighQuality; Brush brush = shape.ShapeBrush; Pen pen = new Pen(brush, scaledThickness(shape, parameters)) { StartCap = LineCap.Round, EndCap = LineCap.Round }; Point start = parameters.toAbsolute(shape.Handles["start"]); Point end = parameters.toAbsolute(shape.Handles["end"]); if (l.sp.chkUseShadow.Checked) { Pen shadowPen = new Pen(Constants.SHADOW_COLOR, scaledThickness(shape, parameters)) { StartCap = LineCap.Round, EndCap = LineCap.Round }; int offsx = (int)(Constants.SHADOW_X * parameters.ZoomRatio); int offsy = (int)(Constants.SHADOW_Y * parameters.ZoomRatio); g.DrawLine(shadowPen, start.X + offsx, start.Y + offsy, end.X + offsx, end.Y + offsy); shadowPen.Dispose(); } g.DrawLine(pen, start, end); pen.Dispose(); brush.Dispose(); base.paint(g, drawHandles, parameters); }
/// <summary> /// Init all references /// </summary> public void InitReferences() { var initialParameters = ViewParameters.Where(i => i.CustomValue).ToList(); ViewParameters.Clear(); if (Report != null && View != null) { foreach (var configParameter in View.Template.Parameters) { OutputParameter parameter = initialParameters.FirstOrDefault(i => i.Name == configParameter.Name); if (parameter == null) { parameter = new OutputParameter() { Name = configParameter.Name, Value = configParameter.Value } } ; else { parameter.CustomValue = true; } ViewParameters.Add(parameter); parameter.Enums = configParameter.Enums; parameter.Description = configParameter.Description; parameter.Type = configParameter.Type; parameter.UseOnlyEnumValues = configParameter.UseOnlyEnumValues; parameter.DisplayName = configParameter.DisplayName; parameter.ConfigValue = configParameter.Value; parameter.EditorLanguage = configParameter.EditorLanguage; parameter.TextSamples = configParameter.TextSamples; } } }
public static Bitmap generateElementBitmap(PonyVille ponyVille, SizeF s, ViewParameters p) { int w = (int)(s.Width * p.ZoomRatio); int h = (int)(s.Height * p.ZoomRatio); if (w == 0) { w = 1; } if (h == 0) { h = 1; } Bitmap b = new Bitmap(w, h); Bitmap pony = ponyVille.getBitmap(); Graphics g = Graphics.FromImage(b); g.InterpolationMode = InterpolationMode.HighQualityBicubic; Point[] pts = new Point[3]; pts[0] = new Point(0, 0); pts[1] = new Point(w, 0); pts[2] = new Point(0, h); g.DrawImage(pony, pts); pony.Dispose(); return(b); }
public static void drawElement(Graphics g, Element e, ViewParameters p) { Point ptAbs = p.toAbsolute(e.r.Location); ptAbs.Offset(p.Scrolls.X, p.Scrolls.Y); g.DrawImageUnscaled(e.b, ptAbs); }
private void resizeBitmaps(ViewParameters parameters) { foreach (Element e in p.elements) { e.b = generateElementBitmap(p, e.r.Size, parameters); } }
public override void paint(Graphics g, bool drawHandles, ViewParameters parameters) { g.SmoothingMode = SmoothingMode.HighQuality; Point[] pShadow = new Point[pencil.points.Count]; Point[] pColor = new Point[pencil.points.Count]; int i = 0; foreach (PointF p in pencil.points) { pColor[i] = parameters.toAbsolute(p); int offsx = (int)(Constants.SHADOW_X * parameters.ZoomRatio); int offsy = (int)(Constants.SHADOW_Y * parameters.ZoomRatio); pShadow[i] = new Point(pColor[i].X + offsx, pColor[i].Y + offsy); ++i; } Brush b = shape.ShapeBrush; if (pencil.sp.chkUseShadow.Checked) { Brush shadow = new SolidBrush(Constants.SHADOW_COLOR); draw(g, pShadow, shadow, parameters); shadow.Dispose(); } draw(g, pColor, b, parameters); b.Dispose(); }
public void SetMatrices(ViewParameters viewParameters) { var eye = viewParameters.EyePoint; this.gameModelview.Matrix = Matrix4.LookAt( eye, eye.Xy.WithZ(), new Vector3(0, 1, 0) ); }
public override void Open(ViewParameters parameters) { base.Open(); InitializeElements(); RegisterEvents(); }
public override void paint(Graphics g, bool drawHandles, ViewParameters pars) { if (pars != parameters || s.needRedraw) { parameters = pars; s.needRedraw = false; scaledShot = new Bitmap(pars.Viewport.Width, pars.Viewport.Height); Graphics gg = Graphics.FromImage(scaledShot); gg.InterpolationMode = InterpolationMode.HighQualityBicubic; gg.ScaleTransform(pars.ZoomRatio, pars.ZoomRatio); PointF[] dst = new PointF[3]; dst[0] = new PointF(0, 0); dst[1] = new PointF(scaledShot.Width / pars.ZoomRatio, 0); dst[2] = new PointF(0, scaledShot.Height / pars.ZoomRatio); Bitmap warpedShot = new Bitmap(s.shot.Width, s.shot.Height); Graphics ggg = Graphics.FromImage(warpedShot); Matrix transform = BackgroundTransformator.Instance.getTransform(warpedShot.Size); ggg.Transform = transform; ggg.DrawImage(s.shot, 0, 0); if (BackgroundTransformator.Instance.DrawPivotPoint && !pars.ForSave) { Brush b = new SolidBrush(Color.Black); Point pivotPoint = BackgroundTransformator.Instance.getPivotPoint(warpedShot.Size); pivotPoint.Offset(-10, -10); ggg.FillEllipse(b, pivotPoint.X, pivotPoint.Y, 20, 20); b.Dispose(); } if (pars.ZoomRatio != 1) { RectangleF src = new RectangleF( (pars.Scrolls.X) / pars.ZoomRatio - (pars.CanvasSize.Width / pars.ZoomRatio - s.shot.Width) / 2 - 0.5f, (pars.Scrolls.Y) / pars.ZoomRatio - (pars.CanvasSize.Height / pars.ZoomRatio - s.shot.Height) / 2 - 0.5f, (pars.Viewport.Width) / pars.ZoomRatio, (pars.Viewport.Height) / pars.ZoomRatio); gg.DrawImage(warpedShot, dst, src, GraphicsUnit.Pixel); } else { gg.DrawImageUnscaled( warpedShot, (pars.CanvasSize.Width - s.shot.Width) / 2 - pars.Scrolls.X, (pars.CanvasSize.Height - s.shot.Height) / 2 - pars.Scrolls.Y); } warpedShot.Dispose(); } g.DrawImageUnscaled(scaledShot, 0, 0); }
public void BeforeSerialization() { _tempParameters = ViewParameters.ToList(); _tempCSS = ViewCSS.ToList(); //Remove parameters and CSS identical to config ViewParameters.RemoveAll(i => i.Value == null || i.Value == i.ConfigValue); ViewCSS.RemoveAll(i => i.Value == i.ConfigValue); }
public ExecutionConfig(ReportDataSource dataSource, string name, string displayName, string description, IList <StoredProcedureParameter> storedProcedureParameters, ViewParameters viewParameters) { DataSource = dataSource; Name = name; DisplayName = displayName; Description = description; StoredProcedureParameters = storedProcedureParameters.ToList(); ViewParameters = viewParameters; }
/// <summary> /// Copy the current parameter values to a parameter list /// </summary> public void CopyParameters(List <Parameter> destination) { foreach (var parameter in ViewParameters.Where(i => i.CustomValue)) { var destParameter = destination.FirstOrDefault(i => i.Name == parameter.Name); if (destParameter != null) { destParameter.Value = parameter.Value; } } }
private ExecutionConfig GetConfig(ReportDataSource source) { ExecutionConfig config = new ExecutionConfig(); config.DataSource = source; if (source == ReportDataSource.StoredProcedure) { List <StoredProcedureParameter> procedureParameters = new List <StoredProcedureParameter>(); procedureParameters.Add(new StoredProcedureParameter((int)SqlDbType.NVarChar, "City", "N'Yekaterinburg")); procedureParameters.Add(new StoredProcedureParameter((int)SqlDbType.Int, "PostalCode", "620000")); procedureParameters.Add(new StoredProcedureParameter((int)SqlDbType.DateTime, "DateOfBirth", "'2018-01-01'")); config.StoredProcedureParameters = procedureParameters; config.Name = "GetSitizensByCityAndDateOfBirth"; config.DisplayName = "Get citizens"; config.Description = "Get citizens from SQL Server via parametrized stored procedure (city, postal code and date of birth)"; } else { ViewParameters viewParameters = new ViewParameters(); config.ViewParameters = viewParameters; config.Name = "CitizensView"; config.DisplayName = "Get citizens"; config.Description = "Get citizens from SQL Server view by group of params"; List <DbQueryParameter> whereParameters = new List <DbQueryParameter>(); whereParameters.Add(new DbQueryParameter(null, "FirstName", "=", "N'Michael'")); whereParameters.Add(new DbQueryParameter(new List <JoinCondition>() { JoinCondition.And, JoinCondition.Not }, "City", "=", "N'Yekaterinburg'")); whereParameters.Add(new DbQueryParameter(new List <JoinCondition>() { JoinCondition.And }, "Age", "BETWEEN", "18 AND 60")); whereParameters.Add(new DbQueryParameter(new List <JoinCondition>() { JoinCondition.And }, "District", "IN", "(N'D1', N'A3', N'A5', N'C7')")); whereParameters.Add(new DbQueryParameter(new List <JoinCondition>() { JoinCondition.Or }, "Region", "!=", "N'Sverdlovskaya oblast'")); config.ViewParameters.WhereParameters = whereParameters; List <DbQueryParameter> orderByParameters = new List <DbQueryParameter>(); orderByParameters.Add(new DbQueryParameter(null, "FirstName", null, "ASC")); orderByParameters.Add(new DbQueryParameter(null, "LastName", null, "DESC")); config.ViewParameters.OrderByParameters = orderByParameters; List <DbQueryParameter> groupByParameters = new List <DbQueryParameter>(); groupByParameters.Add(new DbQueryParameter(null, "District", null, null)); config.ViewParameters.GroupByParameters = groupByParameters; } return(config); }
public void setFont(ViewParameters p) { if (editorFont != null) { editorFont.Dispose(); } editorFont = new Font(t.sp.buttonFont.Font.Name, REL_SIZE * scaledThickness(shape, p), t.sp.buttonFont.Font.Style, GraphicsUnit.Pixel, 0); invalidateCache(); }
private void moveEditor(ViewParameters p) { if (t.Editor == null) { return; } Point pt = p.toAbsolute(shape.Handles["start"]); t.Editor.Location = new Point(pt.X + p.Scrolls.X, pt.Y + p.Scrolls.Y); t.editor.invalidateView(); invalidateCache(); }
public override void Open(ViewParameters parameters) { base.Open(); _params = parameters as MainMenuViewParameters; if (_params == null) { return; } InitializeElements(); RegisterEvents(); }
public void TestCreateSelectStatementMultiple() { ViewParameters parameters = new ViewParameters(); List <DbQueryParameter> whereParams = new List <DbQueryParameter>(); whereParams.Add(new DbQueryParameter(null, "Age", ">", "18")); whereParams.Add(new DbQueryParameter(new[] { JoinCondition.And, JoinCondition.Not }, "FirstName", "IS NOT", "'John'")); whereParams.Add(new DbQueryParameter(new[] { JoinCondition.Or }, "LastName", "=", "'Smith'")); parameters.WhereParameters = whereParams; string expectedSelectStatement = "SELECT * FROM Person WHERE Age > 18 AND NOT FirstName IS NOT 'John' OR LastName = 'Smith'"; string actualSelectStatement = SqlStatmentsGenerator.CreateSelectStatement(null, "Person", parameters); Assert.Equal(expectedSelectStatement, actualSelectStatement); }
/// <summary> /// Pop view to previous view angle and position /// </summary> public void PopView(bool forcePop = false) { if (forcePop) { ViewParameters sourceParameters; if (viewStack.Count > 2) { sourceParameters = viewStack.Pop(); } else { sourceParameters = viewStack.Peek(); } currentViewParameter = viewStack.Peek(); if (!inViewTransitioning) { if (currentViewParameter.forceFading || sourceParameters.forceFading) { cameraTranstioningType = CameraTransitioningType.FadeoutFadeinTranstioning; } else if (sourceParameters.viewContentType == ViewContentType.Model3DView && currentViewParameter.viewContentType == ViewContentType.Model3DView) { cameraTranstioningType = CameraTransitioningType.MovementTransition; } else if (sourceParameters.viewContentType == ViewContentType.Model3DView && currentViewParameter.viewContentType == ViewContentType.PanoramaView) { cameraTranstioningType = CameraTransitioningType.MoveInFadeOutTransition; } else if (sourceParameters.viewContentType == ViewContentType.PanoramaView && currentViewParameter.viewContentType == ViewContentType.Model3DView) { cameraTranstioningType = CameraTransitioningType.FadeInMoveOutTranstion; } else { cameraTranstioningType = CameraTransitioningType.FadeoutFadeinTranstioning; } } inViewTransitioning = true; } else if (viewCommandQueue.Count < maxCommandBuffer) { viewCommandQueue.Enqueue(new PushPopViewCommand(null, false, Time.time)); } }
public bool parseJSON(string s) { // 3 obj being parse by the JSON string[] data = splitJSON (s,3); UnityEngine.Debug.Log("parseJSON "+data[0]+" "+data[1]); UnityEngine.Debug.Log ("Miau :"+data.Length+"\n"); for (int i = 0; i < data.Length; i+=2) { switch(data[i]){ case "dtm_data": // UnityEngine.Debug.Log("d = "+data[i+1]); //UnityEngine.Debug.Log("DTM"); // dtm_model.SetHeightMap(data[i+1]); break; case "view_params": ViewParameters vP = new ViewParameters (data[i+1]); mComputeCraterGeometry.setViewParameters(vP); receivedDataFromPython = true; break; case "w": string sW = Regex.Split(data[i+1],"[{}]")[1]; receivedDataFromPython = true; PythonOutputHandler (sW); break; case "name": string sName = Regex.Split(data[i+1],"'")[1]; UnityEngine.Debug.Log("s is "+sName); mComputeCraterGeometry.setCraterName(sName); receivedDataFromPython = true; break; case "exit": return true; } } return false; // UnityEngine.Debug.Log("sw: "+sW+"Raw: "+data[3]); }
public void setViewParams(string s) { ViewParameters vP = new ViewParameters (s); mComputeCraterGeometry.setViewParameters(vP); // UnityEngine.Debug.Log ("Encode " + s); }
/// <summary> /// Calculate camera view parameters based on the entity bounding box. /// </summary> /// <param name="entity">The entity that we want to display</param> /// <param name="up">The vector representing the up of the entity</param> /// <param name="front">The vector representing the front of the entity</param> /// <param name="cameraComponent">The camera component used to render to object</param> /// <returns>Appropriate view parameters that can be used to display the entity</returns> public static ViewParameters CalculateViewParameters(Entity entity, Vector3 up, Vector3 front, CameraComponent cameraComponent) { var upAxis = up.Length() < MathUtil.ZeroTolerance ? Vector3.UnitY : Vector3.Normalize(up); // if we ensure that the whole object bounding box seen under the view vector in the frustum, // most of the time it results in object occupying only ~ 1/4 * 1/4 of the screen space. // So instead we decided to approximate the object with a bounding sphere (taking the risk that some of the objects are a little bit out of the screen) var boundingSphere = CalculateBoundingSpere(entity); // calculate the min distance from the object to see it entirely var minimunDistance = Math.Max( boundingSphere.Radius / (2f * (float)Math.Tan(cameraComponent.VerticalFieldOfView * cameraComponent.AspectRatio / 2f)), boundingSphere.Radius / (2f * (float)Math.Tan(cameraComponent.VerticalFieldOfView / 2f))); var distance = 1.2f * (minimunDistance + boundingSphere.Radius); // set the view distance such that the object can be seen entirely var parameters = new ViewParameters(upAxis) { Target = boundingSphere.Center + entity.Transform.Position, // use of center of the bounding box as camera target Distance = distance, FarPlane = distance }; return parameters; }
public void setViewParameters(ViewParameters vp) { UnityEngine.Debug.Log ("got View Params"); viewParameters = vp; float[] lightDir = {1.0f,1.0f,0.0f}; float[] _WorldSpaceCameraPos = {0.0f,10.0f,0.0f}; pixelShaderCrater.updateViewParameters (lightDir,_WorldSpaceCameraPos); }