Browse Source

两个doc 错误案例

hxx 2 năm trước cách đây
mục cha
commit
f18736e729
9 tập tin đã thay đổi với 598 bổ sung22 xóa
  1. 7 2
      ADI_ACIS.pro
  2. 1 1
      ADI_ACIS.pro.user
  3. 4 2
      WebsocketServer.h
  4. 1 1
      app.cpp
  5. 33 0
      appdoc.cpp
  6. 38 0
      appdoc.h
  7. 4 2
      appmodel.cpp
  8. 474 0
      hasfiletoolkit.h
  9. 36 14
      websocketserver.cpp

+ 7 - 2
ADI_ACIS.pro

@@ -8,14 +8,19 @@ SOURCES += \
     app.cpp \
     appview.cpp \
     appmodel.cpp \
-    appselectionset.cpp
+    appselectionset.cpp \
+    appdoc.cpp \
+    appdoc.cpp
 
 HEADERS += \
     WebsocketServer.h \
     app.h \
     appview.h \
     appmodel.h \
-    appselectionset.h
+    appselectionset.h \
+    hasfiletoolkit.h \
+    appdoc.h \
+    appdoc.h
 
 
 

+ 1 - 1
ADI_ACIS.pro.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.8.0, 2022-09-30T18:01:10. -->
+<!-- Written by QtCreator 4.8.0, 2022-10-08T17:06:37. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>

+ 4 - 2
WebsocketServer.h

@@ -6,6 +6,7 @@
 #include <QtCore/QMap>
 #include "appmodel.h"
 #include "appview.h"
+#include "appdoc.h"
 QT_FORWARD_DECLARE_CLASS(QWebSocketServer)
 QT_FORWARD_DECLARE_CLASS(QWebSocket)
 
@@ -28,8 +29,9 @@ private Q_SLOTS:
 private:
     QWebSocketServer *m_pWebSocketServer;
     QMap<int,AppView *> m_clientMap;
-    AppModel * model =NULL;
-    AppModel * model2 =NULL;
+     QMap<int,AppDoc *> m_clientDocMap;
+//    AppModel * model =NULL;
+//    AppModel * model2 =NULL;
 };
 
 #endif // WEBSOCKETSERVER_H

+ 1 - 1
app.cpp

@@ -9,7 +9,7 @@ BOOL App::InitInstance()
     HC_Define_System_Options("license = `" VISUALIZE_LICENSE "`");
     m_pHoopsDB = new HDB;
     m_pHoopsDB->Init();
-    m_pHoopsDB->SetIsolatedDrivers(true);
+    m_pHoopsDB->SetIsolatedDrivers(true);//设置“隔离”驱动程序选项。允许在单独的线程上生成驱动程序。用于背景打印或多视图
 
 
 

+ 33 - 0
appdoc.cpp

@@ -0,0 +1,33 @@
+#include "appdoc.h"
+#include "appmodel.h"
+AppDoc:: AppDoc()
+{
+    m_pHoopsModel = 0;
+}
+AppDoc::~AppDoc()
+{
+    if (m_pHoopsModel != NULL)
+    {
+        delete m_pHoopsModel;
+        m_pHoopsModel = 0;
+    }
+}
+int AppDoc::OnNewDocument()
+{
+
+    // delete the HMFCDemoModel object if there is already one
+    if(m_pHoopsModel != NULL)
+    {
+        delete m_pHoopsModel;
+        m_pHoopsModel = NULL;
+    }
+
+    // create a new AppModel object for this Document
+    m_pHoopsModel = new AppModel();
+    if (m_pHoopsModel == NULL)
+        return FALSE;
+
+    m_pHoopsModel->Init();
+
+    return TRUE;
+}

+ 38 - 0
appdoc.h

@@ -0,0 +1,38 @@
+#ifndef APPDOC_H
+#define APPDOC_H
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "ha_part.h"
+#include "ha_part_util.h"
+#include "roll_hm.hxx"
+// HOOPS includes
+#include "hc.h"
+#include "HStream.h"
+#include "HOpcodeShell.h"
+#include "HUtility.h"
+#include <part_api.hxx>
+#include "HTools.h"
+#include "ha_rend_options.h"
+#include "HIOManager.h"
+#include "varray.h"
+#include "HBaseView.h"
+#include "kernapi.hxx"
+#include <QtCore/QDebug>
+
+class AppDoc
+{
+public:
+    AppDoc();
+
+    HBaseModel* GetHoopsModel( void ) { return m_pHoopsModel; }
+    HC_KEY		GetIncludeKey( void) { return m_include_key; }
+    int OnNewDocument();
+    ~AppDoc();
+private:
+    HBaseModel*		m_pHoopsModel; //指向与此文档关联的HOOPS/MVO HBaseModel对象的指针
+    //与本文档相关的HOOPS Include Library段的键,用于替代 到HOOPS/MVO HBaseModel对象(m_pHoopsModel)
+    HC_KEY			m_include_key;
+};
+
+#endif // APPDOC_H

+ 4 - 2
appmodel.cpp

@@ -17,6 +17,7 @@
 #include "varray.h"
 #include "HBaseView.h"
 #include "kernapi.hxx"
+#include <QtCore/QDebug>
 AppModel::AppModel()
 {
         m_bSolidModel = true;
@@ -26,15 +27,16 @@ AppModel::AppModel()
        // initialize_ha_part();
         m_pHAPart = ACIS_NEW HA_Part();
 
-        api_part_set_distribution_mode( TRUE );
+        api_part_set_distribution_mode( TRUE );//设置历史分布打开或关闭。
     //	distributed_history(TRUE,TRUE);
 
         char buffer[1024];
         char pbuffer[POINTER_BUFFER_SIZE];
         PART* pPart = m_pHAPart->GetPart();
         sprintf(buffer,"?Include Library/%s",ptoax(pPart->history_stream(), pbuffer));
+        qDebug() << "appmodde buffer" << buffer;
         m_ModelKey = HA_KCreate_Segment(0, buffer);
-        HA_Set_Rendering_Options("segment pattern = ?Include Library/history/entity");
+        HA_Set_Rendering_Options("segment pattern = ?Include Library/history/entity");//提供对如何通过HOOPS/ACIS网格管理器将ACIS对象渲染为HOOPS对象的控制
 }
 AppModel::~AppModel()
 {

+ 474 - 0
hasfiletoolkit.h

@@ -0,0 +1,474 @@
+//
+// Copyright (c) 2000 by Tech Soft 3D, LLC.
+// The information contained herein is confidential and proprietary to
+// Tech Soft 3D, LLC., and considered a trade secret as defined under
+// civil and criminal statutes.  Tech Soft 3D shall pursue its civil
+// and criminal remedies in the event of unauthorized use or misappropriation
+// of its trade secrets.  Use of this information by anyone other than
+// authorized employees of Tech Soft 3D, LLC. is granted only under a
+// written non-disclosure agreement, expressly prescribing the scope and
+// manner of such use.
+//
+// $Header: /files/homes/master/cvs/hoops_master/hoops_appwizard/VCWizards/HOOPSAppWiz_NET2008/Templates/1033/3daf/HMSFileToolkit.h,v 1.1 2008-04-16 23:14:27 stage Exp $
+//
+
+#ifndef _HMSFILETOOLKIT_H_
+#define _HMSFILETOOLKIT_H_
+
+#include "afxtempl.h"
+#include "HStream.h"
+#include "HOpcodeShell.h"
+#include "HPolyPoly.h"
+
+class HBaseModel;
+
+//! The CModellerObject class is used to store and manage information about an solid modeler object
+/*!
+Assuming a BRep model, this class stores the information about it's (body, face, edge etc.) and also about
+its parents and childern. This class is expected to be used as a base class for different type of modeller
+objects your geometry kernel may have.
+*/
+class CModellerObject
+{
+
+public:
+
+        HC_KEY *m_keys;		/*!< Array of HOOPS keys associated with this modeller object */
+        int  m_numchildren; /*!< Number of children this object has */
+        long *m_children;	/*!< Array of ids of children of this object */
+        long *m_parents;	/*!< Array of ids of parents of this object */
+        int m_identifier;	/*!< Solid modeler identifier (tag/pointer) of this object */
+
+        /*! Constructs CModellerObject object */
+        CModellerObject() { m_keys = 0; m_numchildren=0; m_children = 0; m_parents = 0; m_identifier = 0; }
+
+        /*! Destroys the CModeller object and frees up memory associated with it */
+        ~CModellerObject()
+        {
+                delete [] m_keys;
+                delete [] m_children;
+                delete [] m_parents;
+        }
+
+        /*! Returns the class of the object (body/face/edge). Should be overridden by the derived class */
+        virtual  int AskClass() { return 0; }
+
+        /*! Returns the number of keys associated with this model. Should be overridden */
+        virtual long GetKeyNum() {
+                if (!m_keys)
+                        return 0;
+                else
+                        return 1;
+        }
+
+        /*! Associates the given key with the modeller object. It erases any previously associated keys */
+        virtual void SetKey(HC_KEY key)
+        {
+                if (m_keys!=0)
+                        delete m_keys;
+                if (key!=0)
+                {
+                        m_keys = new HC_KEY;
+                        m_keys[0] = key;
+                }
+        }
+
+        /*! Associates the given id as a parent of this modeller object. It erases any previously associated parent */
+        virtual void SetParent(long parent)
+        {
+                if (m_parents!=0)
+                        delete m_parents;
+                m_parents = new long;
+                m_parents[0] = parent;
+        }
+
+        /*! Sets the children count and allocated memory to store the ids. It erases any previously associated children */
+        void SetChildNum(int numchildren)
+        {
+                m_numchildren = numchildren;
+                if (m_children)
+                        delete [] m_children;
+                m_children = new long[numchildren];
+        }
+
+};
+
+//! The CBaseModellerObject class is used to store and manage information about an solid modeler object
+/*!
+This class can be use to extend the base class and create a more specific modeller object (e.g. BRep object).
+Currently, there it is not utilised in that way.
+*/
+class CBaseModellerObject : public CModellerObject
+{
+
+public:
+
+        /*! Constructor */
+        CBaseModellerObject()  : CModellerObject() {}
+
+        /*! Returns the class of the object (body/face/edge). Should be overridden by the derived class */
+        virtual  int AskClass() { return 0; }
+};
+
+//! The CBodyModellerObject class represents a BODY type of solid modeller object
+/*!
+The CBodyModellerObject class represents a BODY type of solid modeller object
+*/
+class CBodyModellerObject : public CModellerObject
+{
+
+public:
+        /*! Constructor */
+        CBodyModellerObject()  : CModellerObject() {}
+
+        /*! Returns the class of the object - which in this case is BODY */
+        virtual  int AskClass() { return BODY_TYPE; }
+
+};
+
+//! The CFaceModellerObject class represents a FACE type of solid modeller object
+/*!
+The CFaceModellerObject class represents a FACE type of solid modeller object
+*/
+class CFaceModellerObject : public CModellerObject
+{
+
+public:
+        /*! Constructor */
+        CFaceModellerObject()  : CModellerObject() {}
+
+        /*! Returns the class of the object - which in this case is FACE */
+        virtual  int AskClass() { return FACE_TYPE; }
+};
+
+
+//! The CEdgeModellerObject class represents a EDGE type of solid modeller object
+/*!
+The CEdgeModellerObject class represents a EDGE type of solid modeller object
+*/
+class CEdgeModellerObject : public CModellerObject
+{
+public:
+
+        int m_numkeys;		/*!< Number of keys associated with this object */
+        int m_numparents;	/*!< Number of parents associated with this object */
+
+        /*! Constructor */
+        CEdgeModellerObject() : CModellerObject() {m_numparents=0;}
+
+        /*! Returns the class of the object - which in this case is EDGE */
+        virtual  int AskClass() { return EDGE_TYPE; }
+        /*! Associates a key to the object. The key is inserted in the list at the given position */
+        void SetKey(int pos, int key)
+        {
+                m_keys[pos] = key;
+        }
+
+        /*! Sets the associated keys count and allocated memory to store the ids. It erases any previously associated keys */
+        void SetKeyNum(int numkeys)
+        {
+                if (m_keys!=0)
+                        delete m_keys;
+                m_keys = new HC_KEY[numkeys];
+                m_numkeys = numkeys;
+        }
+
+        /*! Adds the given id to the parents array of the object. The parent is ignored if the object has already more
+            than one parent associated
+         */
+        void AddParent(int parent)
+        {
+                if (m_numparents == 0)
+                {
+                        delete m_parents;
+                        m_parents = new long[2];
+                }
+                if (m_numparents<2)
+                        m_parents[m_numparents++] = parent;
+        }
+
+        /*! Returns the number of keys associated */
+        long GetKeyNum() { return m_numkeys; }
+
+};
+
+//! The CModellerInfo class manages the associativity information
+/*!
+The CModellerInfo uses a hash map to store the associativity information between the solid modeller and HOOPS
+*/
+class CModellerInfo
+{
+public:
+        int m_objectnum;						/*!< Number of objects */
+        bool m_bIsValid;						/*!< Is the object valid for use */
+        CModellerObject **m_objects;			/*!< Solid modeler object information */
+        CMap <long,long&,long,long&> m_map;		/*!< Hash map storing the associativity information */
+        bool m_bTesselatedFaces;				/*!< true if the body is tessleated at face level */
+        bool m_bPSF;							/*!< true if the modeler file is embedded into the hsf file */
+
+        /*! Constructor */
+        CModellerInfo()
+        {
+                m_objects=0;
+                m_objectnum = 0;
+                m_map.InitHashTable(1201);
+                m_bIsValid = false;
+                m_bTesselatedFaces = false;
+                m_bPSF = false;
+        }
+
+        /*! Destroys the CModellerInfo object and frees up memory associated with it */
+        ~CModellerInfo()
+        {
+                if( m_objects )
+                {
+                        for (int i=0;i<m_objectnum;i++)
+                                delete m_objects[i];
+                        delete [] m_objects;
+                }
+        }
+
+        /*! Initializes the CModellerInfo. Allocates memory to store information about given number of objects */
+        bool Init(int number_of_objects)
+        {
+                if (m_objects!=0)
+                        delete [] m_objects;
+                m_objects = new  CModellerObject *[number_of_objects];
+                for (int i=0;i<number_of_objects;i++)
+                        m_objects[i]=0;
+                m_objectnum = number_of_objects;
+                return 1;
+        }
+
+        /*! Returns the number of bodies and their ids this modeller info has stored */
+        bool ask_bodies(int * const nbodies, long** const body_indices);
+
+        /*! Returns the number of faces and their ids for the given body */
+        bool BODY_ask_faces(long body_index, int * const nfaces, long** const face_indices);
+
+        /*! Returns the number of edges and their ids for the given face */
+        bool FACE_ask_edges(long face_index, int * const nedges, long** const edge_indices);
+
+        /*! Returns the number of owner faces and their ids for the given edge */
+        bool EDGE_ask_faces(long edge_index, int * const nfaces, long** const face_indices);
+
+        /*! Returns the id of the owner body for the given face */
+        bool FACE_ask_body(long face_index, long* const body_index);
+
+        /*! Returns the type (body, face, edge) for the given entity */
+        bool ENTITY_ask_class(long entity_index, int   & eclass);
+
+        /*! Returns the id of the given entity */
+        bool ENTITY_ask_identifier(long entity_index, int *ident);
+
+        /*! Adds the modeler object information at the given position */
+        void SetModellerObject (int pos, CModellerObject * object);
+
+        /*! Returns the modeller object at the given position */
+        CModellerObject * GetModellerObject (int pos);
+
+        /*! Returns the id of the given HOOPS key */
+        long Compute_Entity_Index(HC_KEY key, int    eclass);
+
+        /*! Returns the HOOPS keys for the given modeler object */
+        long  Compute_Geometry_Keys(long index, long max_count, HC_KEY* keys);
+
+};
+
+
+//! The TK_PSLine is a custom object handler
+/*!
+This class helps to tag the line objects which are not tagged by the HOOPS StreamToolkit by default.
+*/
+class TK_PSLine : public HTK_Line {
+  private:
+        int m_mystage;
+  public:
+        TK_PSLine() : HTK_Line() { m_mystage = 0; }
+        TK_Status   Write (BStreamFileToolkit & tk) alter;
+};
+
+//! The TK_PSPolypoint is a custom object handler
+/*!
+This class helps to tag the TK_PSPolypoint objects which are not tagged by the HOOPS StreamToolkit by default.
+*/
+class TK_PSPolypoint : public HTK_Polypoint {
+  private:
+        int m_mystage;
+  public:
+        TK_PSPolypoint(unsigned char opcode) : HTK_Polypoint(opcode) { m_mystage = 0; }
+        TK_Status   Write (BStreamFileToolkit & tk) alter;
+};
+
+//! The TK_PSPolyPolypoint is a custom object handler
+/*!
+This class helps to tag the TK_PSPolyPolypoint objects which are not tagged by the HOOPS StreamToolkit by default.
+*/
+class TK_PSPolyPolypoint : public HTK_PolyPolypoint {
+  private:
+        int m_mystage;
+  public:
+        TK_PSPolyPolypoint(unsigned char opcode) : HTK_PolyPolypoint(opcode) { m_mystage = 0; }
+        TK_Status   Write (BStreamFileToolkit & tk) alter;
+};
+
+//! The TK_PSEllipse is a custom object handler
+/*!
+This class helps to tag the TK_PSEllipse objects which are not tagged by the HOOPS StreamToolkit by default.
+*/
+class TK_PSEllipse : public HTK_Ellipse {
+  private:
+        int m_mystage;
+  public:
+        TK_PSEllipse(unsigned char opcode) : HTK_Ellipse(opcode) { m_mystage = 0; }
+        TK_Status   Write (BStreamFileToolkit & tk) alter;
+};
+
+//! The TK_PSCircle is a custom object handler
+/*!
+This class helps to tag the TK_PSCircle objects which are not tagged by the HOOPS StreamToolkit by default.
+*/
+class TK_PSCircle : public HTK_Circle {
+  private:
+        int m_mystage;
+  public:
+        TK_PSCircle(unsigned char opcode) : HTK_Circle(opcode) { m_mystage = 0; }
+        TK_Status   Write (BStreamFileToolkit & tk) alter;
+
+};
+
+//! The TK_PSClose_Segment is a custom object handler
+/*!
+This class helps to tag the TK_PSClose_Segment objects which are not tagged by the HOOPS StreamToolkit by default.
+*/
+class TK_PSClose_Segment : public HTK_Close_Segment {
+  private:
+        int m_mystage;
+  public:
+        TK_PSClose_Segment() : HTK_Close_Segment() { m_mystage = 0; }
+        TK_Status Write(BStreamFileToolkit &tk);
+
+};
+
+//! The TK_PSUser_Data is a custom object handler
+/*!
+This is the main class which handler storing and restoring of solid modeler information in an hsf file as a user data.
+*/
+class  TK_PSUser_Data : public TK_User_Data {
+    private:
+
+                int				m_pos;				/*!< Variable which keeps track of current position in the data */
+                CModellerInfo	*m_mi;				/*!< Solid modeler objects information */
+                int				m_mystage;			/*!< Internal variable to track the current stage in reading/writing */
+                CString			m_psf_tempfilename;	/*!< Filename of temporary solid modeler file */
+                long			m_psf_filesize;		/*!< Size of solid modeler file */
+                FILE			*m_psf_filehandle;	/*!< File handle of solid modeler file */
+                char			*m_psf_file_buff;	/*!< Buffer to read solid modeler file into */
+                int				m_psf_buff_count;	/*!< Size of the buffer */
+
+
+                ENTITY_LIST&		m_entityList;	/*!< List of ACIS entities to be embedded as .sat file */
+
+    public:
+                /*!
+                Constructor
+                \param mi Solid modeler information
+                \param ENTITY_LIST ACIS entitylist to export/receive ACIS entities
+                \param psf Is the solid modeler file embedded
+                */
+        TK_PSUser_Data (CModellerInfo **mi, ENTITY_LIST& ent_list, bool psf = false);
+
+
+                /*! Physically reads the topology information and the modeler file (if m_bPSF is true).
+                The topology information is read into the member (m_data).
+                The modeler file may be too large to hold into the memory, hence
+                it is read and stored as a temporary disk file.
+                */
+                TK_Status	Read (BStreamFileToolkit & tk) alter;
+
+                /*! Converts the raw topology information into CModellerInfo.
+                    Calls geometry kernel api to read the solid modeler file (by calling ExecutePS function)
+                        Restores the associativity information by converting the streamtoolkit indices to actual HOOPS keys.
+                */
+        TK_Status	Execute (BStreamFileToolkit & tk) alter;
+
+                /*! Generates and topology information from the solid modeler entities the kernel apis.
+                */
+        TK_Status	Interpret (BStreamFileToolkit & tk, long key, int lod=0) alter;
+
+                /*! Physically writes the topology information and the modeler file (if m_bPSF is true).
+                The modeler file may be too large to hold into the memory, hence
+                it is written to a temporary disk file (by calling InterpretPS).
+                Note: Special code is required to handle large modeler files since they can't be read all
+                at once into a memory buffer and provided to the streamtoolkit.
+                */
+        TK_Status	Write (BStreamFileToolkit & tk) alter;
+
+                /*! Creates a temporary physical solid modeler file from the entity list which is later
+                    embedded into the stream file.
+                */
+                TK_Status	InterpretPS(BStreamFileToolkit & tk, long key = -1, int lod=0) alter;
+
+                /*! Uses geometry kernel api to read the solid modeler file which was embedded in the modeler
+                stream file.
+                */
+                TK_Status	ExecutePS(BStreamFileToolkit & tk);
+
+                /*! Accumulates the data in the member variable */
+                void	putdata(void *data, int size);
+
+                /*! returns the data (long) at the current position */
+                void	getdata(long &data);
+
+                /*! returns the data (char) at the current position */
+                void	getdata(char &data);
+
+                /*! Returns the given amount (len) of data into the variable (data) */
+                void	getdata(void *data,int len);
+
+                void	Reset();
+
+};
+
+// Add an identifier to hsf files written out by modeler based partviewer as a comment.
+// This will help us distinguish files which have our TK_User_Data from other applications.
+#define FILE_COMMENT_ID "Exported by TSA Partviewer"
+
+class TK_PSComment : public TK_Comment
+{
+  private:
+        int m_mystage;
+        HBaseModel * m_pHModel;
+  public:
+
+        /*! Constructor */
+        TK_PSComment(HBaseModel * pHModel) : TK_Comment()
+        {
+                m_mystage = 0;
+                m_pHModel = pHModel;
+        }
+
+        /*! Inserts a comment into the file so that it can be identified as a modeler stream file while reading
+         */
+        TK_Status Write(BStreamFileToolkit &tk)
+        {
+                // stamp our id
+                SetComment(FILE_COMMENT_ID);
+                return TK_Comment::Write(tk);
+        };
+
+        /*! Checks if the comment in the file contains FILE_COMMENT_ID string.
+            If it does, it means this is modeler stream file and sets the custom user data (TK_PSUser_Data)
+                opcode handler to handle it.
+                This is required during the reading of modeler stream file.
+         */
+        TK_Status Execute (BStreamFileToolkit & tk);
+
+        // need to have this overridden for prewalk handlers.
+        TK_Status Interpret (BStreamFileToolkit & tk, ID_Key key, int variant = 0) alter{ return TK_Normal; };
+
+};
+
+
+#endif //_HMSFILETOOLKIT_H_
+

+ 36 - 14
websocketserver.cpp

@@ -3,6 +3,7 @@
 #include "QtWebSockets/QWebSocket"
 #include <QtCore/QDebug>
 #include "cstrapi.hxx"
+#include "appdoc.h"
 //! constructor
 WebsocketServer::WebsocketServer(quint16 port, QObject *parent) :
     QObject(parent),
@@ -22,8 +23,8 @@ WebsocketServer::WebsocketServer(quint16 port, QObject *parent) :
 WebsocketServer::~WebsocketServer()
 {
     m_pWebSocketServer->close();
-    delete model;
-    model =0;
+   // delete model;
+   // model =0;
     qDeleteAll(m_clientMap);
 }
 //! 创建连接
@@ -35,22 +36,22 @@ void WebsocketServer::onNewConnection()
     connect(pSocket, &QWebSocket:: textFrameReceived, this, &WebsocketServer::textFrameReceived);
     connect(pSocket, &QWebSocket::disconnected, this, &WebsocketServer::socketDisconnected);
     connect(pSocket, &QWebSocket::binaryMessageReceived, this, &WebsocketServer::binaryMessageReceived);
-    if(model == NULL){
-        model =new AppModel();
-        model->Init();
-    }
-    AppView  *view = new AppView(model,NULL,"opengl");
+
+
+    AppDoc*  doc =new AppDoc();
+    doc->OnNewDocument();
+    m_clientDocMap.insert(1,doc);
+    AppView  *view = new AppView(doc->GetHoopsModel(),NULL,"opengl");
     view->Init();
     view->Update();
+    m_clientMap.insert(1,view);
 
-    if(model2 == NULL){
-        model2 =new AppModel();
-        model2->Init();
-    }
-    AppView  *view2 = new AppView(model2,NULL,"opengl");
+    AppDoc*  doc2 =new AppDoc();
+    doc2->OnNewDocument();
+    m_clientDocMap.insert(2,doc2);
+    AppView  *view2 = new AppView(doc2->GetHoopsModel(),NULL,"opengl");
     view2->Init();
     view2->Update();
-    m_clientMap.insert(1,view);
     m_clientMap.insert(2,view2);
 }
 //! textFrameReceived
@@ -80,7 +81,7 @@ void WebsocketServer::textFrameReceived(const QString &frame)
     AppModel* model2= ((AppModel*)(view2->GetModel()));
     HC_KEY model_key2 = view2->GetModel()->GetModelKey();
     HC_Open_Segment_By_Key(model_key2);
-        HC_Open_Segment("");
+        HC_Open_Segment("2");
             ENTITY_LIST entityList2;
             BODY* sphere2 = NULL;
             api_solid_sphere(SPAposition(1, 0, 0), 1, sphere2, NULL);
@@ -120,7 +121,28 @@ void WebsocketServer::socketDisconnected()
         delete view;
         view = 0;
         m_clientMap.remove(1);
+
+        AppDoc * doc = m_clientDocMap.value(1);
+        delete doc;
+        doc =0;
+         m_clientDocMap.remove(1);
+
+
+         AppView *view2 = m_clientMap.value(2);
+        // AppModel* model= ((AppModel*)(view->GetModel()));
+       //  delete model;
+      //   model =0;
+         delete view2;
+         view2 = 0;
+         m_clientMap.remove(2);
+
+         AppDoc * doc2 = m_clientDocMap.value(2);
+         delete doc2;
+         doc2 =0;
+          m_clientDocMap.remove(2);
+
         pClient->deleteLater();
+
     }
 }