summaryrefslogtreecommitdiffstats
path: root/src/documentiface.cpp
blob: 294ff32bad05e4d19655dca76a10788f5dbe693b (plain)
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
/***************************************************************************
 *   Copyright (C) 2005 by David Saxton                                    *
 *   david@bluehaze.org                                                    *
 *                                                                         *
 *   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 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#include "circuitdocument.h"
#include "connector.h"
#include "cnitem.h"
#include "documentiface.h"
#include "flowcodedocument.h"
#include "itemlibrary.h"
#include "libraryitem.h"
#include "mechanicsdocument.h"
#include "textdocument.h"
#include "view.h"


//BEGIN class DocumentIface
DocumentIface::DocumentIface( Document * document )
	: DCOPObject("Document")
{
	m_pDocument = document;
}


DocumentIface::~DocumentIface()
{
}

void DocumentIface::selectAll( )
{
	m_pDocument->selectAll();
}

void DocumentIface::redo( )
{
	m_pDocument->redo();
}

void DocumentIface::undo( )
{
	m_pDocument->undo();
}

void DocumentIface::paste( )
{
	m_pDocument->paste();
}

void DocumentIface::copy( )
{
	m_pDocument->copy();
}

void DocumentIface::cut( )
{
	m_pDocument->cut();
}

void DocumentIface::print( )
{
	m_pDocument->print();
}


bool DocumentIface::close( )
{
	return m_pDocument->fileClose();
}

void DocumentIface::saveAs( )
{
	m_pDocument->fileSaveAs();
}

void DocumentIface::save( )
{
	m_pDocument->fileSave();
}

bool DocumentIface::isRedoAvailable( )
{
	return m_pDocument->isRedoAvailable();
}

bool DocumentIface::isUndoAvailable( )
{
	return m_pDocument->isUndoAvailable();
}

bool DocumentIface::isModified( )
{
	return m_pDocument->isModified();
}

bool DocumentIface::openURL( const TQString & url )
{
	return m_pDocument->openURL(url);
}

TQString DocumentIface::url( )
{
	return m_pDocument->url().url();
}

uint DocumentIface::numberOfViews( )
{
	return m_pDocument->numberOfViews();
}

DCOPRef DocumentIface::activeView( )
{
	return viewToRef( m_pDocument->activeView() );
}

TQString DocumentIface::caption( ) const
{
	return m_pDocument->caption();
}

DCOPRef DocumentIface::viewToRef( View * view )
{
	return DCOPRef( view->dcopObject() );
}
//END class DocumentIface



//BEGIN class FlowCodeDocumentIface
FlowCodeDocumentIface::FlowCodeDocumentIface( FlowCodeDocument * document )
	: ICNDocumentIface(document)
{
	m_pFlowCodeDocument = document;
}

void FlowCodeDocumentIface::setPicType( const TQString & id )
{
	m_pFlowCodeDocument->setPicType(id);
}

void FlowCodeDocumentIface::convertToMicrobe()		
{
	m_pFlowCodeDocument->convertToMicrobe();
}

void FlowCodeDocumentIface::convertToHex()		
{
	m_pFlowCodeDocument->convertToHex();
}

void FlowCodeDocumentIface::convertToPIC()
{
	m_pFlowCodeDocument->convertToPIC();
}

void FlowCodeDocumentIface::convertToAssembly()
{
	m_pFlowCodeDocument->convertToAssembly();
}
//END class FlowCodeDocumentIface



//BEGIN class CircuitDocumentIface
CircuitDocumentIface::CircuitDocumentIface( CircuitDocument * document )
	: ICNDocumentIface(document)
{
	m_pCircuitDocument = document;
}

void CircuitDocumentIface::setOrientation0( )
{
	m_pCircuitDocument->setOrientation0();
}

void CircuitDocumentIface::setOrientation90( )
{
	m_pCircuitDocument->setOrientation90();
}

void CircuitDocumentIface::setOrientation180( )
{
	m_pCircuitDocument->setOrientation180();
}

void CircuitDocumentIface::setOrientation270( )
{
	m_pCircuitDocument->setOrientation270();
}

void CircuitDocumentIface::rotateCounterClockwise( )
{
	m_pCircuitDocument->rotateCounterClockwise();
}

void CircuitDocumentIface::rotateClockwise( )
{
	m_pCircuitDocument->rotateClockwise();
}

void CircuitDocumentIface::flip( )
{
	m_pCircuitDocument->itemFlip();
}

void CircuitDocumentIface::displayEquations( )
{
	m_pCircuitDocument->displayEquations();
}

void CircuitDocumentIface::createSubcircuit( )
{
	m_pCircuitDocument->createSubcircuit();
}
//END class CircuitDocumentIface



//BEGIN class ICNDocumentIface
ICNDocumentIface::ICNDocumentIface( ICNDocument * document )
	: ItemDocumentIface(document)
{
	m_pICNDocument = document;
}

void ICNDocumentIface::exportToImage( )
{
	m_pICNDocument->exportToImage();
}

QCStringList ICNDocumentIface::nodeIDs( const TQString & id )
{
	CNItem * item = m_pICNDocument->cnItemWithID(id);
	
	QCStringList ids;
	if ( !item )
		return ids;
	
	const NodeMap nm = item->nodeMap();
	const NodeMap::const_iterator end = nm.end();
	for ( NodeMap::const_iterator it = nm.begin(); it != end; ++it )
		ids.append( it.key().ascii() );
	
	return ids;
}

TQString ICNDocumentIface::makeConnection( const TQString & item1, const TQString & node1, const TQString & item2, const TQString & node2 )
{
	CNItem * i1 = m_pICNDocument->cnItemWithID(item1);
	CNItem * i2 = m_pICNDocument->cnItemWithID(item2);
	
	if ( !i1 || !i2 )
		return TQString();
	
	Node * n1 = m_pICNDocument->nodeWithID( i1->nodeId(node1) );
	Node * n2 = m_pICNDocument->nodeWithID( i2->nodeId(node2) );
	
	if ( !n1 || !n2 )
		return TQString();
	
	Connector * connector = m_pICNDocument->createConnector( n1, n2 );
	return connector ? connector->id() : TQString();
}

void ICNDocumentIface::selectConnector( const TQString & id )
{
	m_pICNDocument->select( m_pICNDocument->connectorWithID(id) );
}

void ICNDocumentIface::unselectConnector( const TQString & id )
{
	m_pItemDocument->unselect( m_pICNDocument->connectorWithID(id) );
}
//END class ICNDocumentIface



//BEGIN class ItemDocumentIface
ItemDocumentIface::ItemDocumentIface( ItemDocument * document )
	: DocumentIface(document)
{
	m_pItemDocument = document;
}

QCStringList ItemDocumentIface::validItemIDs( )
{
	QCStringList validIDs;
	
	LibraryItemList * allItems = itemLibrary()->items();
	const LibraryItemList::iterator end = allItems->end();
	for ( LibraryItemList::iterator it = allItems->begin(); it != end; ++it )
	{
		TQString id = (*it)->activeID();
		if ( m_pItemDocument->isValidItem(id) )
			validIDs << id.utf8();
	}
	return validIDs;
}

TQString ItemDocumentIface::addItem( const TQString & id, int x, int y )
{
	Item * item = m_pItemDocument->addItem( id, TQPoint( x, y ), true );
	return item ? item->id() : TQString();
}

void ItemDocumentIface::selectItem( const TQString & id )
{
	m_pItemDocument->select( m_pItemDocument->itemWithID(id) );
}

void ItemDocumentIface::unselectItem( const TQString & id )
{
	m_pItemDocument->unselect( m_pItemDocument->itemWithID(id) );
}

void ItemDocumentIface::deleteSelection( )
{
	m_pItemDocument->deleteSelection();
}

void ItemDocumentIface::clearHistory( )
{
	m_pItemDocument->clearHistory();
}

void ItemDocumentIface::unselectAll( )
{
	m_pItemDocument->unselectAll();
}

void ItemDocumentIface::alignHorizontally( )
{
	m_pItemDocument->alignHorizontally();
}

void ItemDocumentIface::alignVertically( )
{
	m_pItemDocument->alignVertically();
}

void ItemDocumentIface::distributeHorizontally( )
{
	m_pItemDocument->distributeHorizontally();
}

void ItemDocumentIface::distributeVertically( )
{
	m_pItemDocument->distributeVertically();
}
//END class ItemDocumentIface



//BEGIN class TextDocumentIface
TextDocumentIface::TextDocumentIface( TextDocument * document )
	: DocumentIface(document)
{
	m_pTextDocument = document;
}

void TextDocumentIface::debugStepOver( )
{
	m_pTextDocument->debugStepOver();
}

void TextDocumentIface::debugStepOut( )
{
	m_pTextDocument->debugStepOut();
}

void TextDocumentIface::debugStep( )
{
	m_pTextDocument->debugStep();
}

void TextDocumentIface::debugStop( )
{
	m_pTextDocument->debugStop();
}

void TextDocumentIface::debugInterrupt( )
{
	m_pTextDocument->debugInterrupt();
}

void TextDocumentIface::debugRun( )
{
	m_pTextDocument->debugRun();
}

bool TextDocumentIface::isDebugging( )
{
#ifndef NO_GPSIM
	return m_pTextDocument->debuggerIsRunning();
#else
	return false;
#endif
}

void TextDocumentIface::clearBookmarks( )
{
	m_pTextDocument->clearBookmarks();
}

void TextDocumentIface::convertToAssembly( )
{
	m_pTextDocument->convertToAssembly();
}

void TextDocumentIface::convertToPIC( )
{
	m_pTextDocument->convertToPIC();
}

void TextDocumentIface::convertToHex( )
{
	m_pTextDocument->convertToHex();
}

void TextDocumentIface::convertToMicrobe( )
{
	m_pTextDocument->convertToMicrobe();
}

void TextDocumentIface::formatAssembly( )
{
	m_pTextDocument->formatAssembly();
}
//END class TextDocumentIface



//BEGIN class MechanicsDocumentIface
MechanicsDocumentIface::MechanicsDocumentIface( MechanicsDocument * document )
	: ItemDocumentIface(document)
{
	m_pMechanicsDocument = document;
}
//END class MechanicsDocumentIface