Mercurial > hg > ccmieditor
view native/Falcon/CollectionsManager.h @ 8:ea7885bd9bff tip
fixed bug : render solid line as dotted/dashed when moving the stylus from dotted/dashed to solid
author | ccmi-guest |
---|---|
date | Thu, 03 Jul 2014 16:12:20 +0100 |
parents | d66dd5880081 |
children |
line wrap: on
line source
/* CCmI Editor - A Collaborative Cross-Modal Diagram Editing Tool Copyright (C) 2011 Queen Mary University of London (http://ccmi.eecs.qmul.ac.uk/) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <jni.h> #include <new> #include <H3DUtil/Vec3d.h> #include "utils.h" /* this class uses the java haptic object lists to provide nodes * * and edges to draw to the graphic and haptic managers */ class CollectionsManager { public: struct NodeData { jdouble x; jdouble y; jint hapticId; jint diagramId; NodeData(){} private : NodeData(const NodeData& n){/* avoid mistakenly copy construction calls */} }; struct EdgeData{ jdouble *x; jdouble *y; bool **adjMatrix; jint hapticId; jint diagramId; jint stipplePattern; jsize nodeStart; jdouble attractPoint[2]; void setSize(unsigned int s){ size = s; if(s > previousSize){ /* delete the old memory */ delete [] x; delete [] y; for(unsigned int i=0; i<previousSize; i++) delete[] adjMatrix[i]; delete [] adjMatrix; /* allocates a bigger one */ try{ x = new jdouble[size]; y = new jdouble[size]; adjMatrix = new bool* [size]; for(unsigned int i=0; i<size; i++){ adjMatrix[i] = new bool[size]; for(unsigned int j=0; j<size; j++) adjMatrix[i][j] = false; } }catch(std::bad_alloc){ stopExecution("Could not allocate memory for the program.\nAborting..."); } previousSize = size; } } unsigned int getSize() const { return size; } EdgeData(unsigned int s) : size(s), previousSize(s){ x = new jdouble[size]; y = new jdouble[size]; adjMatrix = new bool* [size]; for(unsigned int i=0; i<size; i++){ adjMatrix[i] = new bool[size]; for(unsigned int j=0; j<size; j++) adjMatrix[i][j] = false; } } ~EdgeData(){ delete [] x; delete [] y; for(unsigned int i=0; i<size; i++) delete[] adjMatrix[i]; delete [] adjMatrix; } private : unsigned int size; unsigned int previousSize; EdgeData(const EdgeData& e){ /* avoid mistakenly copy construction */} }; private: JNIEnv *env; jobject *haptics; jclass hapticClass; jclass hapticNodeClass; jclass hapticEdgeClass; jclass listClass; jclass bitsetClass; jobject nodeList; jobject edgeList; jmethodID getMethodId; jmethodID sizeMethodId; jmethodID getBitMethodId; jfieldID xFieldId; jfieldID yFieldId; jfieldID nodeHapticIdFieldId; jfieldID edgeHapticIdFieldId; jfieldID nodeDiagramIdFieldId; jfieldID edgeDiagramIdFieldId; jfieldID nodeListfieldId; jfieldID stipplePatternfieldId; jfieldID edgeListfieldId; jfieldID edgeSizefieldId; jfieldID edgeXsFieldId; jfieldID edgeYsFieldId; jfieldID edgeAdjMatrixFieldId; jfieldID attractPointXFieldId; jfieldID attractPointYFieldId; jfieldID edgeNodeStartFieldId; int screenHeight; int screenWidth; NodeData nd; EdgeData ed; void fillupNodeData(struct NodeData & nd, jobject & currentNode); void fillupEdgeData(struct EdgeData & ed, jobject & currentEdge); public: CollectionsManager(JNIEnv *environment, jobject *obj) : env(environment), haptics(obj), ed(2){} virtual ~CollectionsManager(void){} const jint getNodesNum(); const jint getEdgesNum(); struct NodeData & getNodeData(const int i); struct EdgeData & getEdgeData(const int i); inline int getScreenHeight() const { return screenHeight;} inline void setScreenHeight(const int sh) { screenHeight = sh; } inline int getScreenWidth() const { return screenWidth;} inline void setScreenWidth(const int sw) { screenWidth = sw; } void init(void); };