-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProtoShopClient.cpp
More file actions
557 lines (472 loc) · 22.4 KB
/
ProtoShopClient.cpp
File metadata and controls
557 lines (472 loc) · 22.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
/***********************************************************************
ProtoShopClient - Class representing a client for a ProtoShop workspace.
Copyright (c) 2003-2023 Oliver Kreylos
This file is part of VR ProtoShop.
VR ProtoShop 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 2 of the License, or (at your
option) any later version.
VR ProtoShop 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 VR ProtoShop; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***********************************************************************/
#include "ProtoShopClient.h"
#include <Collaboration2/MessageReader.h>
#include <Collaboration2/MessageContinuation.h>
#include "Protein.h"
#include "ProteinInteractor.h"
#include "VRProtoShop.h"
namespace Collab {
namespace Plugins {
/********************************
Methods of class ProtoShopClient:
********************************/
void ProtoShopClient::frontendConnectReplyCallback(unsigned int messageId,MessageReader& message)
{
/* Read the message from the backend: */
std::vector<ServerChain>* chains=message.read<std::vector<ServerChain>*>();
/* Replace the current polypeptide chains: */
for(VRProtoShop::ChainList::iterator cIt=application->chains.begin();cIt!=application->chains.end();++cIt)
{
delete cIt->interactor;
delete cIt->proteinRenderer;
delete cIt->protein;
}
application->chains.reserve(chains->size());
unsigned int chainIndex=0;
for(std::vector<ServerChain>::const_iterator cIt=chains->begin();cIt!=chains->end();++cIt,++chainIndex)
{
/* Create a new chain structure: */
VRProtoShop::Chain newChain;
newChain.name=cIt->name;
newChain.protein=cIt->protein;
newChain.proteinRenderer=new MD::ProteinRenderer(application->configFile.getSection("/ProteinRenderer"),newChain.protein);
newChain.interactor=new ProteinInteractor(chainIndex,newChain.protein,newChain.proteinRenderer,0,application->undoBuffer,application->interactorPipe);
newChain.interactor->collaborate(this);
newChain.visible=cIt->renderFlags.visible;
/* Set the new chain's initial rendering flags: */
newChain.proteinRenderer->setDrawAtoms(cIt->renderFlags.drawAtoms);
newChain.proteinRenderer->setDrawBonds(cIt->renderFlags.drawBonds);
newChain.proteinRenderer->setDrawBackbone(cIt->renderFlags.drawBackbone);
newChain.proteinRenderer->setDrawCartoon(cIt->renderFlags.drawCartoon);
newChain.proteinRenderer->setDrawHydrogenBonds(cIt->renderFlags.drawHydrogenBonds);
newChain.proteinRenderer->setDrawHydrogenBondSites(cIt->renderFlags.drawHydrogenBondSites);
newChain.proteinRenderer->setDrawHydrogenCages(cIt->renderFlags.drawHydrogenCages);
newChain.proteinRenderer->setDrawCollisions(cIt->renderFlags.drawAtomCollisions);
/* Store the new chain: */
application->chains.push_back(newChain);
}
/* Update the chain dialog: */
application->activeChain=&application->chains.front();
application->updateChainDialog();
/* Reset the navigation transformation: */
application->resetNavigation();
/* Delete the list of chains: */
delete chains;
}
MessageContinuation* ProtoShopClient::connectReplyCallback(unsigned int messageId,MessageContinuation* continuation)
{
/* Check if this is the start of a new message: */
if(continuation==0)
{
/* Prepare to read the connect reply message: */
continuation=protocolTypes.prepareReading(serverMessageTypes[ConnectReply],new ConnectReplyMsg);
}
/* Continue reading the connect reply message and check whether it's complete: */
if(protocolTypes.continueReading(client->getSocket(),continuation))
{
/* Extract the connect reply message: */
ConnectReplyMsg* msg=protocolTypes.getReadObject<ConnectReplyMsg>(continuation);
/* Parse the connect reply message: */
std::vector<ServerChain>* chains=new std::vector<ServerChain>;
chains->reserve(msg->chains.size());
for(Misc::Vector<Chain>::iterator cIt=msg->chains.begin();cIt!=msg->chains.end();++cIt)
{
/* Parse the polypeptide chain: */
chains->push_back(ServerChain());
ServerChain& chain=chains->back();
chain.name=cIt->name;
chain.transform=cIt->transform;
chain.renderFlags=cIt->renderFlags;
chain.protein=new MD::Protein;
MD::Protein::ResidueCreator residueCreator(chain.protein);
/* Create the chain's secondary structures: */
for(Misc::Vector<SecondaryStructure>::iterator ssIt=cIt->secondaryStructures.begin();ssIt!=cIt->secondaryStructures.end();++ssIt)
{
/* Create the secondary structure: */
residueCreator.newSecondaryStructure(MD::Protein::SecondaryStructure::StructureType(ssIt->type));
/* Create the secondary structure's residues: */
for(Misc::Vector<Residue>::iterator rIt=ssIt->residues.begin();rIt!=ssIt->residues.end();++rIt)
{
/* Create the residue: */
rIt->name[3]='\0';
residueCreator.newResidue(rIt->name,rIt->index);
/* Create the residue's atoms: */
for(Misc::Vector<Atom>::iterator aIt=rIt->atoms.begin();aIt!=rIt->atoms.end();++aIt)
{
/* Add the atom to the protein: */
aIt->placement[3]='\0';
residueCreator.addAtom(MD::Atom::getElementName(MD::Atom::Element(aIt->type)),aIt->index,aIt->position,aIt->placement);
}
}
}
/* Finalize the protein: */
residueCreator.finishProtein();
}
/* Forward the list of polypeptide chains to the frontend: */
{
MessageWriter frontendMessage(MessageBuffer::create(serverMessageBase+ConnectReply,sizeof(std::vector<ServerChain>*)));
frontendMessage.write(chains);
client->queueFrontendMessage(frontendMessage.getBuffer());
}
/* Delete the connect reply message and the continuation object: */
delete msg;
delete continuation;
continuation=0;
}
return continuation;
}
void ProtoShopClient::frontendLockReplyCallback(unsigned int messageId,MessageReader& message)
{
/* Read the message: */
LockReplyMsg lockReply;
protocolTypes.read(message,serverMessageTypes[LockReply],&lockReply);
/* Find the outstanding lock: */
LockRequestMap::Iterator lrIt=lockRequests.findEntry(lockReply.requestId);
if(!lrIt.isFinished())
{
/* Check if this is a chain dragging lock: */
LockRequestState& lr=lrIt->getDest();
if(lr.chainDraggingTool!=0)
{
/* Notify the affected chain dragging tool: */
lr.chainDraggingTool->lockReply(lockReply.lockId);
}
else
{
/* Notify the affected protein interactor: */
application->chains[lr.chainIndex].interactor->lockReply(lr.beginIndex,lr.endIndex-lr.beginIndex,lockReply.lockId);
}
/* Check if the lock request was granted: */
if(lockReply.lockId!=LockID(0))
{
/* Create a lock state for the local client: */
LockState ls;
ls.clientId=0;
ls.chainIndex=lr.chainIndex;
ls.beginIndex=lr.beginIndex;
ls.endIndex=lr.endIndex;
locks.setEntry(LockMap::Entry(lockReply.lockId,ls));
}
/* Remove the outstanding lock request: */
lockRequests.removeEntry(lrIt);
}
else
{
/* Assume the lock request was cancelled, and release a granted lock immediately: */
if(lockReply.lockId!=LockID(0))
{
UnlockMsg unlockRequest;
unlockRequest.lockId=lockReply.lockId;
queueServerMessage(UnlockRequest,&unlockRequest);
}
}
}
void ProtoShopClient::frontendLockNotificationCallback(unsigned int messageId,MessageReader& message)
{
/* Read the message: */
LockNotificationMsg lockNotification;
protocolTypes.read(message,serverMessageTypes[LockNotification],&lockNotification);
/* Enter the new lock into the lock map: */
LockState ls;
ls.clientId=lockNotification.clientId;
ls.chainIndex=lockNotification.lock.chain;
ls.beginIndex=lockNotification.lock.begin;
ls.endIndex=lockNotification.lock.end;
locks.setEntry(LockMap::Entry(lockNotification.lockId,ls));
/* Update the affected chain's visual state: */
application->chains[ls.chainIndex].proteinRenderer->lockResidueRange(ls.beginIndex,ls.endIndex-ls.beginIndex,true);
}
void ProtoShopClient::frontendLockUpdateNotificationCallback(unsigned int messageId,MessageReader& message)
{
/* Read the message: */
LockUpdateNotificationMsg lockUpdateNotification;
protocolTypes.read(message,serverMessageTypes[LockUpdateNotification],&lockUpdateNotification);
/* Find the existing lock in the lock map: */
LockState& ls=locks.getEntry(lockUpdateNotification.lockId).getDest();
/* Update the affected chain's visual state and the lock state: */
application->chains[ls.chainIndex].proteinRenderer->lockResidueRange(ls.beginIndex,ls.endIndex-ls.beginIndex,false);
ls.beginIndex=lockUpdateNotification.lock.begin;
ls.endIndex=lockUpdateNotification.lock.end;
application->chains[ls.chainIndex].proteinRenderer->lockResidueRange(ls.beginIndex,ls.endIndex-ls.beginIndex,true);
}
void ProtoShopClient::frontendIKUpdateNotificationCallback(unsigned int messageId,MessageReader& message)
{
/* Read the message: */
IKUpdateMsg ikUpdateNotification;
protocolTypes.read(message,serverMessageTypes[IKUpdateNotification],&ikUpdateNotification);
/* Find the existing lock in the lock map: */
LockState& ls=locks.getEntry(ikUpdateNotification.lockId).getDest();
/* Update the affected chain: */
VRProtoShop::Chain& chain=application->chains[ls.chainIndex];
{
Threads::Mutex::Lock proteinLock(chain.proteinMutex);
chain.protein->changeDihedralAngles(ls.beginIndex,ls.endIndex-ls.beginIndex,ikUpdateNotification.dihedralAngles.data(),ikUpdateNotification.updateDirection,ikUpdateNotification.limitUpdate);
chain.proteinRenderer->updateProtein();
}
}
MessageContinuation* ProtoShopClient::ikUpdateNotificationCallback(unsigned int messageId,MessageContinuation* continuation)
{
/* Check if this is the start of a new message: */
if(continuation==0)
{
/* Prepare to read the IK update notification message: */
continuation=protocolTypes.prepareReading(serverMessageTypes[IKUpdateNotification],new IKUpdateMsg);
}
/* Continue reading the IK update notification message and check whether it's complete: */
if(protocolTypes.continueReading(client->getSocket(),continuation))
{
/* Extract the IK update notification message: */
IKUpdateMsg* msg=protocolTypes.getReadObject<IKUpdateMsg>(continuation);
/* Forward the IK update notification message to the front end: */
{
MessageWriter frontendMessage(MessageBuffer::create(serverMessageBase+IKUpdateNotification,protocolTypes.calcSize(serverMessageTypes[IKUpdateNotification],msg)));
protocolTypes.write(serverMessageTypes[IKUpdateNotification],msg,frontendMessage);
client->queueFrontendMessage(frontendMessage.getBuffer());
}
/* Delete the IK update notification message and the continuation object: */
delete msg;
delete continuation;
continuation=0;
}
return continuation;
}
void ProtoShopClient::frontendTransformNotificationCallback(unsigned int messageId,MessageReader& message)
{
/* Read the message: */
TransformMsg transformNotification;
protocolTypes.read(message,serverMessageTypes[TransformNotification],&transformNotification);
/* Find the existing lock in the lock map: */
LockState& ls=locks.getEntry(transformNotification.lockId).getDest();
/* Update the affected chain's transformation: */
application->chains[ls.chainIndex].transformation=transformNotification.transformation;
}
void ProtoShopClient::frontendUnlockNotificationCallback(unsigned int messageId,MessageReader& message)
{
/* Read the message: */
UnlockMsg unlockNotification;
protocolTypes.read(message,serverMessageTypes[UnlockNotification],&unlockNotification);
/* Find the existing lock in the lock map: */
LockMap::Iterator lIt=locks.findEntry(unlockNotification.lockId);
/* Update the affected chain's visual state and release the lock: */
LockState& ls=lIt->getDest();
application->chains[ls.chainIndex].proteinRenderer->lockResidueRange(ls.beginIndex,ls.endIndex-ls.beginIndex,false);
locks.removeEntry(lIt);
}
void ProtoShopClient::frontendResetTransformNotificationCallback(unsigned int messageId,MessageReader& message)
{
/* Read the message: */
ResetTransformMsg resetTransformNotification;
protocolTypes.read(message,serverMessageTypes[ResetTransformNotification],&resetTransformNotification);
/* Reset the affected chain's transformation: */
application->chains[resetTransformNotification.chain].transformation=Transformation::identity;
}
void ProtoShopClient::frontendRenderFlagsUpdateNotificationCallback(unsigned int messageId,MessageReader& message)
{
/* Read the message: */
RenderFlagsUpdateMsg renderFlagsUpdateNotification;
protocolTypes.read(message,serverMessageTypes[RenderFlagsUpdateNotification],&renderFlagsUpdateNotification);
/* Update the affected chain's rendering flags: */
VRProtoShop::Chain& chain=application->chains[renderFlagsUpdateNotification.chain];
chain.visible=renderFlagsUpdateNotification.renderFlags.visible;
chain.proteinRenderer->setDrawAtoms(renderFlagsUpdateNotification.renderFlags.drawAtoms);
chain.proteinRenderer->setDrawBonds(renderFlagsUpdateNotification.renderFlags.drawBonds);
chain.proteinRenderer->setDrawBackbone(renderFlagsUpdateNotification.renderFlags.drawBackbone);
chain.proteinRenderer->setDrawCartoon(renderFlagsUpdateNotification.renderFlags.drawCartoon);
chain.proteinRenderer->setDrawHydrogenBonds(renderFlagsUpdateNotification.renderFlags.drawHydrogenBonds);
chain.proteinRenderer->setDrawHydrogenBondSites(renderFlagsUpdateNotification.renderFlags.drawHydrogenBondSites);
chain.proteinRenderer->setDrawHydrogenCages(renderFlagsUpdateNotification.renderFlags.drawHydrogenCages);
chain.proteinRenderer->setDrawCollisions(renderFlagsUpdateNotification.renderFlags.drawAtomCollisions);
/* Update the GUI: */
if(application->activeChain==&chain)
application->updateChainDialogToggles();
}
ProtoShopClient::ProtoShopClient(Client* sClient,VRProtoShop* sApplication)
:PluginClient(sClient),
application(sApplication),
lastLockRequestId(0),lockRequests(5),
locks(17)
{
}
ProtoShopClient::~ProtoShopClient(void)
{
}
const char* ProtoShopClient::getName(void) const
{
return protocolName;
}
unsigned int ProtoShopClient::getVersion(void) const
{
return protocolVersion;
}
unsigned int ProtoShopClient::getNumClientMessages(void) const
{
return NumClientMessages;
}
unsigned int ProtoShopClient::getNumServerMessages(void) const
{
return NumServerMessages;
}
void ProtoShopClient::setMessageBases(unsigned int newClientMessageBase,unsigned int newServerMessageBase)
{
/* Call the base class method: */
PluginClient::setMessageBases(newClientMessageBase,newServerMessageBase);
/* Register message handlers: */
client->setTCPMessageHandler(serverMessageBase+ConnectReply,Client::wrapMethod<ProtoShopClient,&ProtoShopClient::connectReplyCallback>,this,getServerMsgSize(ConnectReply));
client->setFrontendMessageHandler(serverMessageBase+ConnectReply,Client::wrapMethod<ProtoShopClient,&ProtoShopClient::frontendConnectReplyCallback>,this);
client->setMessageForwarder(serverMessageBase+LockReply,Client::wrapMethod<ProtoShopClient,&ProtoShopClient::frontendLockReplyCallback>,this,getServerMsgSize(LockReply));
client->setMessageForwarder(serverMessageBase+LockNotification,Client::wrapMethod<ProtoShopClient,&ProtoShopClient::frontendLockNotificationCallback>,this,getServerMsgSize(LockNotification));
client->setMessageForwarder(serverMessageBase+LockUpdateNotification,Client::wrapMethod<ProtoShopClient,&ProtoShopClient::frontendLockUpdateNotificationCallback>,this,getServerMsgSize(LockUpdateNotification));
client->setTCPMessageHandler(serverMessageBase+IKUpdateNotification,Client::wrapMethod<ProtoShopClient,&ProtoShopClient::ikUpdateNotificationCallback>,this,getServerMsgSize(IKUpdateNotification));
client->setFrontendMessageHandler(serverMessageBase+IKUpdateNotification,Client::wrapMethod<ProtoShopClient,&ProtoShopClient::frontendIKUpdateNotificationCallback>,this);
client->setMessageForwarder(serverMessageBase+TransformNotification,Client::wrapMethod<ProtoShopClient,&ProtoShopClient::frontendTransformNotificationCallback>,this,getServerMsgSize(TransformNotification));
client->setMessageForwarder(serverMessageBase+UnlockNotification,Client::wrapMethod<ProtoShopClient,&ProtoShopClient::frontendUnlockNotificationCallback>,this,getServerMsgSize(UnlockNotification));
client->setMessageForwarder(serverMessageBase+ResetTransformNotification,Client::wrapMethod<ProtoShopClient,&ProtoShopClient::frontendResetTransformNotificationCallback>,this,getServerMsgSize(ResetTransformNotification));
client->setMessageForwarder(serverMessageBase+RenderFlagsUpdateNotification,Client::wrapMethod<ProtoShopClient,&ProtoShopClient::frontendRenderFlagsUpdateNotificationCallback>,this,getServerMsgSize(RenderFlagsUpdateNotification));
}
void ProtoShopClient::start(void)
{
}
ProtoShopProtocol::LockID ProtoShopClient::requestLock(unsigned int chainIndex,unsigned int firstResidueIndex,unsigned int numResidues)
{
/* Enter a new lock request into the outstanding lock map: */
do
{
++lastLockRequestId;
}
while(lastLockRequestId==0||lockRequests.isEntry(lastLockRequestId));
lockRequests.setEntry(LockRequestMap::Entry(lastLockRequestId,LockRequestState(chainIndex,firstResidueIndex,firstResidueIndex+numResidues)));
/* Send a lock request message to the server: */
LockRequestMsg lockRequest;
lockRequest.requestId=lastLockRequestId;
lockRequest.lock.chain=chainIndex;
lockRequest.lock.begin=firstResidueIndex;
lockRequest.lock.end=firstResidueIndex+numResidues;
queueServerMessage(LockRequest,&lockRequest);
return lastLockRequestId;
}
ProtoShopProtocol::LockID ProtoShopClient::requestLock(unsigned int chainIndex,VRProtoShop::ChainDraggingTool* chainDraggingTool)
{
/* Enter a new lock request into the outstanding lock map: */
do
{
++lastLockRequestId;
}
while(lastLockRequestId==0||lockRequests.isEntry(lastLockRequestId));
unsigned int numResidues=application->chains[chainIndex].protein->getNumResidues();
lockRequests.setEntry(LockRequestMap::Entry(lastLockRequestId,LockRequestState(chainIndex,0,numResidues,chainDraggingTool)));
/* Send a lock request message to the server: */
LockRequestMsg lockRequest;
lockRequest.requestId=lastLockRequestId;
lockRequest.lock.chain=chainIndex;
lockRequest.lock.begin=0;
lockRequest.lock.end=numResidues;
queueServerMessage(LockRequest,&lockRequest);
return lastLockRequestId;
}
ProtoShopProtocol::LockID ProtoShopClient::updateLock(ProtoShopProtocol::LockID lockId,unsigned int firstResidueIndex,unsigned int numResidues)
{
/* Access the existing lock: */
LockState& ls=locks.getEntry(lockId).getDest();
/* Enter a new lock request into the outstanding lock map: */
do
{
++lastLockRequestId;
}
while(lastLockRequestId==0||lockRequests.isEntry(lastLockRequestId));
lockRequests.setEntry(LockRequestMap::Entry(lastLockRequestId,LockRequestState(ls.chainIndex,firstResidueIndex,firstResidueIndex+numResidues)));
/* Send a lock update request message to the server: */
LockUpdateRequestMsg lockUpdateRequest;
lockUpdateRequest.requestId=lastLockRequestId;
lockUpdateRequest.lockId=lockId;
lockUpdateRequest.lock.chain=ls.chainIndex;
lockUpdateRequest.lock.begin=firstResidueIndex;
lockUpdateRequest.lock.end=firstResidueIndex+numResidues;
queueServerMessage(LockUpdateRequest,&lockUpdateRequest);
return lastLockRequestId;
}
void ProtoShopClient::cancelLockRequest(ProtoShopProtocol::LockID lockRequestId)
{
/* Remove the lock request from the map; ignore if it's not in there: */
lockRequests.removeEntry(lockRequestId);
}
void ProtoShopClient::dragChain(ProtoShopProtocol::LockID lockId,const ProtoShopProtocol::Transformation& newTransform)
{
/* Check if the lock is valid: */
if(lockId!=0)
{
/* Send a transform request message to the server: */
TransformMsg transformRequest;
transformRequest.lockId=lockId;
transformRequest.transformation=newTransform;
queueServerMessage(TransformRequest,&transformRequest);
}
}
void ProtoShopClient::ikUpdate(ProtoShopProtocol::LockID lockId,const MD::Protein::DihedralAnglePair deltaAngles[],int updateDirection,bool limitUpdate)
{
/* Access the lock: */
LockState& ls=locks.getEntry(lockId).getDest();
/* Send an IK update request to the server: */
IKUpdateMsg ikUpdateRequest;
ikUpdateRequest.lockId=lockId;
ikUpdateRequest.updateDirection=updateDirection;
ikUpdateRequest.limitUpdate=limitUpdate;
unsigned int numResidues=ls.endIndex-ls.beginIndex;
ikUpdateRequest.dihedralAngles.reserve(numResidues);
for(unsigned int i=0;i<numResidues;++i)
ikUpdateRequest.dihedralAngles.push_back(deltaAngles[i]);
queueServerMessage(IKUpdateRequest,&ikUpdateRequest);
}
void ProtoShopClient::releaseLock(ProtoShopProtocol::LockID lockId)
{
/* Check if the lock is valid: */
if(lockId!=0)
{
/* Remove the lock from the lock map: */
locks.removeEntry(lockId);
/* Send an unlock request message to the server: */
UnlockMsg unlockRequest;
unlockRequest.lockId=lockId;
queueServerMessage(UnlockRequest,&unlockRequest);
}
}
void ProtoShopClient::resetChainTransform(unsigned int chainIndex)
{
/* Send a reset transform request to the server: */
ResetTransformMsg resetTransformRequest;
resetTransformRequest.chain=chainIndex;
queueServerMessage(ResetTransformRequest,&resetTransformRequest);
}
void ProtoShopClient::updateRenderFlags(void)
{
/* Send a render flags update request message to the server: */
RenderFlagsUpdateMsg renderFlagsUpdateRequest;
renderFlagsUpdateRequest.chain=application->chainListBox->getSelectedItem();
renderFlagsUpdateRequest.renderFlags.visible=application->activeChain->visible;
MD::ProteinRenderer* renderer=application->activeChain->proteinRenderer;
renderFlagsUpdateRequest.renderFlags.drawAtoms=renderer->getDrawAtoms();
renderFlagsUpdateRequest.renderFlags.drawBonds=renderer->getDrawBonds();
renderFlagsUpdateRequest.renderFlags.drawBackbone=renderer->getDrawBackbone();
renderFlagsUpdateRequest.renderFlags.drawCartoon=renderer->getDrawCartoon();
renderFlagsUpdateRequest.renderFlags.drawHydrogenBonds=renderer->getDrawHydrogenBonds();
renderFlagsUpdateRequest.renderFlags.drawHydrogenBondSites=renderer->getDrawHydrogenBondSites();
renderFlagsUpdateRequest.renderFlags.drawHydrogenCages=renderer->getDrawHydrogenCages();
renderFlagsUpdateRequest.renderFlags.drawAtomCollisions=renderer->getDrawCollisions();
queueServerMessage(RenderFlagsUpdateRequest,&renderFlagsUpdateRequest);
}
}
}