protected override void Reset() { List <MyMotivatedAction> actions = Target.Rds.ActionManager.Actions; if (numOfActions < actions.Count) { if (m_actionLabels != null) { m_actionLabels.Dispose(); } m_actionLabels = new CudaDeviceVariable <uint>(actions.Count * LABEL_PIXEL_WIDTH * LABEL_PIXEL_WIDTH); m_actionLabels.Memset(0); for (int i = 0; i < actions.Count; i++) { MyDrawStringHelper.DrawString(actions[i].GetLabel(), i * LABEL_PIXEL_WIDTH + 5, 8, 0, 0xFFFFFFFF, m_actionLabels.DevicePointer, LABEL_PIXEL_WIDTH * actions.Count, LABEL_PIXEL_WIDTH); } numOfActions = actions.Count; } Target.Vis.ReadTwoDimensions(ref m_qMatrix, ref m_qMatrixActions, XAxisVariableIndex, YAxisVariableIndex, ShowCurrentMotivations); if (MatrixSizeOK()) { DrawDataToGpu(); } }
protected override void Execute() { m_kernel.SetupExecution(Target.AttentionMap.Count); m_kernel.Run(Target.AttentionMap, Target.Centroids, Target.CentroidsCount, TextureWidth, TextureHeight, VBODevicePointer); for (int i = 0; i < Target.CentroidsCount; i++) { int x = (int)((Target.Centroids.Host[i * MyPupilControl.CENTROID_FIELDS] + 1) * 0.5f * TextureWidth); int y = (int)((Target.Centroids.Host[i * MyPupilControl.CENTROID_FIELDS + 1] + 1) * 0.5f * TextureHeight); float DBI = Target.Centroids.Host[i * MyPupilControl.CENTROID_FIELDS + 5]; MyDrawStringHelper.DrawString(i + " ", x - 4, y - 14, 0, 0xFF69A5FF, VBODevicePointer, TextureWidth, TextureHeight); //MyDrawStringHelper.DrawDecimalString(DBI.ToString("0.0000") , x - 10, y + 2, 0, 0xFF69A5FF, VBODevicePointer, TextureWidth, TextureHeight); } }
protected override void Execute() { if (m_qMatrix != null) { m_kernel.SetupExecution(TextureWidth * TextureHeight); m_kernel.Run(m_plotValues.DevicePointer, m_actionIndices.DevicePointer, m_actionLabels.DevicePointer, numOfActions, LABEL_PIXEL_WIDTH, LABEL_PIXEL_WIDTH, 0f, MaxQValue, m_qMatrix.GetLength(0), m_qMatrix.GetLength(1), VBODevicePointer); if (ViewMode == ViewMethod.Orbit_3D) { m_vertexKernel.SetupExecution(m_qMatrix.Length); m_vertexKernel.Run(m_plotValues.DevicePointer, 0.1f, m_qMatrix.GetLength(0), m_qMatrix.GetLength(1), MaxQValue, VertexVBODevicePointer); } } float[,] lastQMatrix = m_qMatrix; MyStochasticReturnPredictor srp = null; if (AbstractActionIndex < Target.Rds.VarManager.MAX_VARIABLES) { srp = (MyStochasticReturnPredictor)Target.Vis.GetPredictorNo(AbstractActionIndex); } if (srp != null) { Target.Vis.ReadTwoDimensions(ref m_qMatrix, ref m_qMatrixActions, srp, XAxisVariableIndex, YAxisVariableIndex, ShowCurrentMotivations); } if (lastQMatrix != m_qMatrix) { TriggerReset(); } else if (m_qMatrix != null && MatrixSizeOK()) { m_plotValues.CopyToDevice(m_qMatrix); m_actionIndices.CopyToDevice(m_qMatrixActions); if (ShowSRPNames && srp != null) { //Set texture size, it will trigger texture buffer reallocation TextureWidth = LABEL_PIXEL_WIDTH * m_qMatrix.GetLength(0); TextureHeight = LABEL_PIXEL_WIDTH * m_qMatrix.GetLength(1); String label = srp.GetLabel() + " M:" + srp.GetMyTotalMotivation(); MyDrawStringHelper.DrawString(label, 0, 0, 0, 0x999999, VBODevicePointer, TextureWidth, TextureHeight); } } }
protected override void Reset() { List <MyMotivatedAction> actions = Target.Rds.ActionManager.Actions; if (numOfActions < actions.Count) { if (m_actionLabels != null) { m_actionLabels.Dispose(); } m_actionLabels = new CudaDeviceVariable <uint>(actions.Count * LABEL_PIXEL_WIDTH * LABEL_PIXEL_WIDTH); m_actionLabels.Memset(0); for (int i = 0; i < actions.Count; i++) { MyDrawStringHelper.DrawString(actions[i].GetLabel(), i * LABEL_PIXEL_WIDTH + 5, 8, 0, 0xFFFFFFFF, m_actionLabels.DevicePointer, LABEL_PIXEL_WIDTH * actions.Count, LABEL_PIXEL_WIDTH); } numOfActions = actions.Count; } MyStochasticReturnPredictor srp = null; if (AbstractActionIndex < Target.Rds.VarManager.MAX_VARIABLES) { srp = (MyStochasticReturnPredictor)Target.Vis.GetPredictorNo(AbstractActionIndex); } if (srp == null) { m_qMatrix = null; TextureWidth = 0; TextureHeight = 0; } else { Target.Vis.ReadTwoDimensions(ref m_qMatrix, ref m_qMatrixActions, srp, XAxisVariableIndex, YAxisVariableIndex, ShowCurrentMotivations); if (MatrixSizeOK()) { DrawDataToGpu(); } } }
private void drawCoordinates() { m_canvas.Memset(COLOR_BACKGROUND); // Ordinates double range = m_plotCurrentValueMax - m_plotCurrentValueMin; double scale = Math.Floor(Math.Log10(range)); double unit = Math.Pow(10, scale) / 2; int displayPrecision = (scale >= 1) ? 0 : (1 - (int)scale); double firstOrdinate = Math.Ceiling(m_plotCurrentValueMin / unit) * unit; for (int n = 0; firstOrdinate + n * unit < m_plotCurrentValueMax; n++) { double value = firstOrdinate + n * unit; string valueStr = string.Format("{0,8:N" + displayPrecision + "}", value); double y = TextureHeight - m_plotAreaOffsetY - m_plotAreaHeight * (value - m_plotCurrentValueMin) / range - MyDrawStringHelper.CharacterHeight / 2; MyDrawStringHelper.DrawString(valueStr, 0, (int)y, COLOR_BACKGROUND, COLOR_FONT, VBODevicePointer, TextureWidth, TextureHeight); } }
protected override void Execute() { m_kernel_drawEdges.GridDimensions = new dim3(Target.PatchesNum); m_kernel_drawEdges.BlockDimensions = new dim3(Target.PatchesNum); m_kernel_fillImWhite.SetupExecution(Target.MaskCount); m_kernel_fillImFromIm.SetupExecution(Target.MaskCount); m_kernel_fillImFromIm.Run(VBODevicePointer, Target.OutMask, TextureWidth * TextureHeight, 5);//(int)Target.PatchesNum /5); switch (ObserverMode) { case MyJoinPatObsMode.Graph: //. print edges m_kernel_drawEdges.Run(VBODevicePointer, TextureWidth, Target.AdjMatrix, Target.Patches, Target.PatchesNum, Target.PatchesDim, Target.Desc, Target.Desc.ColumnHint, 0); break; case MyJoinPatObsMode.GraphWeights: //. print weight of graph's edges m_kernel_fillImWhite.Run(VBODevicePointer, TextureWidth, TextureHeight); m_kernel_drawEdges.Run(VBODevicePointer, TextureWidth, Target.AdjMatrix, Target.Patches, Target.PatchesNum, Target.PatchesDim, Target.Desc, Target.Desc.ColumnHint, 1); break; case MyJoinPatObsMode.MaskId: //. print ids to objects Target.OutPatches.SafeCopyToHost(); for (int i = 0; i < Math.Min(Target.PatchesNum, 10); i++) { int x = (int)Target.OutPatches.Host[i * Target.PatchesDim]; int y = (int)Target.OutPatches.Host[i * Target.PatchesDim + 1]; MyDrawStringHelper.DrawString(i.ToString(), x, y, (uint)Color.White.ToArgb(), (uint)Color.Black.ToArgb(), VBODevicePointer, TextureWidth, TextureHeight); } break; } }