Example #1
0
/**
 * Handle eraser event: "Delete Stroke" and "Standard", Whiteout is not handled here
 */
void EraseHandler::erase(double x, double y) {
	XOJ_CHECK_TYPE(EraseHandler);

	ListIterator<Layer*> it = this->page.layerIterator();

	int selected = page.getSelectedLayerId();

	this->halfEraserSize = this->handler->getThickness();
	GdkRectangle eraserRect = { x - halfEraserSize, y - halfEraserSize, halfEraserSize * 2, halfEraserSize * 2 };

	Range * range = new Range(x, y);

	while (it.hasNext() && selected) {
		Layer * l = it.next();

		ListIterator<Element *> eit = l->elementIterator();
		eit.freeze();
		while (eit.hasNext()) {
			Element * e = eit.next();
			if (e->getType() == ELEMENT_STROKE && e->intersectsArea(&eraserRect)) {
				Stroke * s = (Stroke *) e;

				eraseStroke(l, s, x, y, range);
			}
		}

		selected--;
	}

	this->view->rerenderRange(*range);
	delete range;
}
Example #2
0
bool SearchControl::search(const char * text, int * occures, double * top) {
	XOJ_CHECK_TYPE(SearchControl);

	freeSearchResults();

	if (text == NULL) {
		return true;
	}

	if (this->pdf) {
		this->results = this->pdf->findText(text);
	}

	int selected = this->page.getSelectedLayerId();
	ListIterator<Layer*> it = this->page.layerIterator();

	while (it.hasNext() && selected) {
		Layer * l = it.next();

		ListIterator<Element *> eit = l->elementIterator();
		while (eit.hasNext()) {
			Element * e = eit.next();

			if (e->getType() == ELEMENT_TEXT) {
				Text * t = (Text *) e;

				GList * textResult = TextView::findText(t, text);
				this->results = g_list_concat(this->results, textResult);
			}
		}

		selected--;
	}

	if (occures) {
		*occures = g_list_length(this->results);
	}
	if (top) {
		if (this->results == NULL) {
			*top = 0;
		} else {

			double min = ((XojPopplerRectangle *) this->results->data)->y1;
			for (GList * l = this->results->next; l != NULL; l = l->next) {
				XojPopplerRectangle * rect = (XojPopplerRectangle *) l->data;
				min = MIN(min, rect->y1);
			}

			*top = min;
		}
	}

	return this->results != NULL;
}
Example #3
0
void PageView::selectObjectAt(double x, double y) {
	XOJ_CHECK_TYPE(PageView);

	int selected = this->page.getSelectedLayerId();
	GdkRectangle matchRect = { x - 10, y - 10, 20, 20 };

	Stroke * strokeMatch = NULL;
	double gap = 1000000000;

	Element * elementMatch = NULL;

	// clear old selection anyway
	this->xournal->getControl()->clearSelection();

	ListIterator<Layer*> it = this->page.layerIterator();
	while (it.hasNext() && selected) {
		Layer * l = it.next();

		ListIterator<Element *> eit = l->elementIterator();
		while (eit.hasNext()) {
			Element * e = eit.next();
			if (e->intersectsArea(&matchRect)) {
				if (e->getType() == ELEMENT_STROKE) {
					Stroke * s = (Stroke *) e;
					double tmpGap = 0;
					if (s->intersects(x, y, 5, &tmpGap)) {
						if (gap > tmpGap) {
							gap = tmpGap;
							strokeMatch = s;
						}
					}
				} else {
					elementMatch = e;
				}
			}
		}

		selected--;
	}

	if (strokeMatch) {
		elementMatch = strokeMatch;
	}

	if (elementMatch) {
		xournal->setSelection(new EditSelection(xournal->getControl()->getUndoRedoHandler(), elementMatch, this, page));

		repaintPage();
	}
}
Example #4
0
void Scene::render(Pixel* px, Vertex *eyePoint, double attenuation)
{
   //create the zbuffer matrix
   int width = px->getWidth();
   int height = px->getHeight();
   Matrix* zbuffer = new Matrix(height, width);    //rows come first

   //populate zbuffer with -1
   for (int i = 1; i <= height; i++)
   {
      for (int j = 1; j <= width; j++)
      {
         zbuffer->setElement(i, j, -1.0);
      }
   }
   
   //loop over all the Instance instances in the Scene and render them
   ListIterator<TransformNode>* ioIter = transformNodes->iterator();
   while (ioIter->hasNext())
   {
      TransformNode* tn = ioIter->next();
      tn->render(px, sceneTransform, zbuffer, ambientLight, pointLight, eyePoint, attenuation);
   }

   delete ioIter;
   delete zbuffer;
}
Example #5
0
void ToolbarData::saveToKeyFile(GKeyFile* config)
{
	XOJ_CHECK_TYPE(ToolbarData);

	const char* group = getId().c_str();

	std::vector<ToolbarEntry>::iterator it;
	for (it = this->contents.begin(); it != this->contents.end(); it++)
	{
		ToolbarEntry& e = *it;

		String line = "";

		ListIterator<ToolbarItem*> it = e.iterator();
		while (it.hasNext())
		{
			line += ",";
			line += *it.next();
		}

		if (line.length() > 2)
		{
			g_key_file_set_string(config, group, e.getName().c_str(),
			                      line.substring(1).c_str());
		}
	}

	g_key_file_set_string(config, group, "name", this->name.c_str());
}
Example #6
0
void SystemTimer::start(void)
{
    updateHiddenDelays();

    ListIterator<TickListener*> iter = tlList.getListIterator();
    iter.reset();
    while (iter.hasNext())
    {
        TickListener *tl = iter.next();
        if (tl != NULL)
            tl->onTick();
    }

    while (time < stoptime)
    {
        time++;

        ListIterator< List<Line*>* > refIter = refLists.getListIterator();
        refIter.reset();
        while (refIter.hasNext())
        {
            List<Line*> *list = refIter.next();

            Line *line = list->first();
            if (line != NULL)
                line->update();
        }

        updateHiddenDelays();

        if (clock != NULL)
            clock->tick();

        updateHiddenDelays();

        ListIterator<TickListener*> iter = tlList.getListIterator();
        iter.reset();

        while (iter.hasNext())
        {
            TickListener *tl = iter.next();
            if (tl != NULL)
                tl->onTick();
        }
    }
}
Example #7
0
/**
*    render
*    Renders the scene.
*    Preconditions:
*        The pixel object.
*    Postconditions:
*        The scene is rendered when the final render method is reached.
*/
void Scene::render( Pixel* pix )
{
    ListIterator<Node>* iter = scene->iterator();
    while( iter->hasNext() ) {
        iter->next()->render( pix, wnd );
    }
    delete iter;
}
Example #8
0
/**
*    render
*    Renders the basic object.
*    Preconditions:
*        The windowing transform matrix, the pixel object.
*    Postconditions:
*        Calls the next render method within the hierarchy.
*/
void BasicObject::render( Matrix* wnd, Pixel* pix, Color* material,
    Matrix* zbuffer )
{
    ListIterator<Face>* iter = faces->iterator();
    while( iter->hasNext() ) {
            iter->next()->render( wnd, pix, material, zbuffer );
    }
    delete iter;
}
Example #9
0
/**
*    addFace
*    Adds a new face to the object.
*    Preconditions:
*        The face to add to the object.
*    Postconditions:
*        A new face is added to the faces list.
*        The vertices from the new face is added to the vertices list.
*/
void BasicObject::addFace( Face* face )
{
    faces->add( face );

    ListIterator<Vertex>* iter = face->getVertices()->iterator();
    while ( iter->hasNext() ) {
        vertices->add( iter->next() );
    }
    delete iter;
}
/*---------------------------------------------------------------------*//**
	自動開始イベントの開始
**//*---------------------------------------------------------------------*/
bool StoryManager::beginAutoBeginEvent(s32 kind)
{
	bool isBegin = false;

	for(ListIterator<AutoBeginEventInfo*> it = _listAutoBeginEvi->iterator(); it.has(); it.next())
	{
		AutoBeginEventInfo* abevi = it.object();
		if(abevi->getKind() == kind)	// 同じ種別
		{
			// イベント起動原因と起動判定
			short cid = EventCause::CID_NULL;
			bool isCall = true;
			switch(kind)
			{
			case AutoBeginEventInfo::KIND_STORY_START:
				cid = EventCause::CID_STORYSTART;
				break;
			case AutoBeginEventInfo::KIND_LOAD_INTVEV_START:
				cid = EventCause::CID_INTVLEVSTART;
				break;
			case AutoBeginEventInfo::KIND_MAP_START:
				cid = EventCause::CID_MAPSTART;
				if(Game::getGame()->getMoveMap()->getCurMapId() != abevi->getMapId())
				{
					isCall = false;
				}
				break;
			}

			// イベント起動
			if(isCall)
			{
				u16 evid = abevi->getCallEvi()->getInfo(abevi->getActiveCallEviIndex())->getEvid();
				if(evid != 0)	// わざわざ起動しない設定で上書きすることもありうる
				{
					EvCause evcause(cid);
					EventMatter* matter = (EventMatter*)_evsysRef->begin(evid, 0, &evcause);
					if(matter != 0L)
					{
						isBegin = true;

						// イベントが複数定義されている場合は、次に送る
						if(abevi->getCallEvi()->getInfoNum() >= 2)
						{
							abevi->nextCallEvi(false);
						}
					}
				}
			}
		}
	}

	return isBegin;
}
Example #11
0
void TransformNode::render(Pixel* pix, Matrix* mat)
{
	ListIterator<Node>* iter = nodes->iterator();

	while(iter->hasNext())
	{
		iter->next()->render(pix, mat->multiply(transform));
	}

	delete iter;
}
/*---------------------------------------------------------------------*//**
	シリアライズ
**//*---------------------------------------------------------------------*/
bool StoryManager::serialize(Serializer* ser) const
{
	// 実行中の Act イベント ID を得る
	u16 evidActing = 0;
	EventData* evdat = Game::getGame()->getEventSys()->getEventData();	ASSERT(evdat != 0L);
	for(int imat = 0; imat < evdat->getEventMatterNum(); imat++)
	{
		EventMatter* matterWk = evdat->getEventMatter(imat);
		if((matterWk->getMatterType() == EMTYPE_ACT) && matterWk->isBegin())	// 開始済み ActMatter 判定
		{
			evidActing = matterWk->getEvId();
		}
	}

	// ストーリーの保存
	if(ser->isStructureMode())	// ストラクチャモード
	{
		SaveStructure* svst = (SaveStructure*)ser->getStructure();
		svst->_gamesvst._storyid = _storyid;										// ストーリー ID の書き込み
		svst->_gamesvst._isPlayedStoryStartupEvent = _isPlayedStoryStartupEvent;	// ストーリー開始イベント起動フラグの書き込み
		svst->_gamesvst._evidActing = evidActing;									// 実行中の Act イベント ID の書き込み
	}
	else						// ダイレクトモード
	{
		ser->store(&_storyid);						// ストーリー ID の書き込み
		ser->store(&_isPlayedStoryStartupEvent);	// ストーリー開始イベント起動フラグの書き込み
		ser->store(&evidActing);					// 実行中の Act イベント ID の書き込み
	}

	// 配置オブジェクトの状態を保存する
	if(ser->isStructureMode())	// ストラクチャモード
	{
		SaveStructure* svst = (SaveStructure*)ser->getStructure();
		if(!svst->storePlacementObjData(_listPlaceObj))
		{
			return false;
		}
	}
	else						// ダイレクトモード
	{
		s32 numPobj = _listPlaceObj->getCount();
		ser->store(&numPobj);
		for(ListIterator<PlacementObj*> it = _listPlaceObj->iterator(); it.has(); it.next())
		{
			const PlacementObj* pobj = it.object();
			pobj->serialize(ser);
		}
	}

	// ワールドマップのシリアライズ
	_wmap->serialize(ser);

	return true;
}
Example #13
0
Scene::~Scene()
{
    ListIterator<Node>* iter = scene->iterator();
    while ( iter->hasNext() ) {
        iter->next()->removeRef();
    }
    delete iter;

    delete scene;
    delete wnd;
}
void HiddenModuleManager::destroyModules(void)
{
    ListIterator<Module*> li = modList.getListIterator();

    li.reset();
    while (li.hasNext())
    {
        Module *mod = li.next();
        if (mod != NULL)
            delete mod;
    }
}
/*---------------------------------------------------------------------*//**
	ストーリーの解放
**//*---------------------------------------------------------------------*/
void StoryManager::releaseStory()
{
	// ストーリーを削除
	if(_stmod != 0L)
	{
		_stmod->destroy();
		delete _stmod;
		_stmod = 0L;
	}

	// マップ置換イベントを戻す
	EventData* evdat = _evsysRef->getEventData();
	for(ListIterator<OverrideEventMatter*> it = _listOvrdEvm->iterator(); it.has(); it.next())
	{
		const OverrideEventMatter* oem = it.object();
		if(oem->getKind() == OverrideEventMatter::KIND_MAP)	// タイプがマップのもののみ
		{
			evdat->unoverrideMatter(oem);
		}
	}
	_listOvrdEvm->removeAll();	// 置換イベント情報クリア

	// 配置オブジェクト情報クリア
	for(ListIterator<PlacementObj*> it = _listPlaceObj->iterator(); it.has(); it.next())
	{
		PlacementObj* pobj = it.object();
		if(pobj->getMapId() == Game::getGame()->getMoveMap()->getCurMapId())
		{
			Game::getGame()->getMap()->unplacePlacementObj(pobj);	// 配置解除
		}
	}
	_listPlaceObj->removeAll();

	// 自動起動イベントリストをクリア
	_listAutoBeginEvi->removeAll();

	// その他の値をクリア
	_storyid = 0L;
	_isPlayedStoryStartupEvent = false;
}
Example #16
0
TransformNode::~TransformNode()
{
   ListIterator<Node>* iter = children->iterator();

   while (iter->hasNext())
   {
      Node* node = iter->next();
      node->removeRef();
   }

   delete children;
   delete iter;
}
SRCR_BEGIN_NS

////////////////////////////////////////////////////////////////////////////
// クラス

//==========================================================================
// SaveStructure メソッド

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// 外部サービス

/*---------------------------------------------------------------------*//**
	配置オブジェクトリストのセーブデータを保存する

	@param listPlaceObj 配置オブジェクトリスト
	@retval true 成功
	@retval false 失敗
**//*---------------------------------------------------------------------*/
bool SaveStructure::storePlacementObjData(const List<PlacementObj*>* listPlaceObj)
{
    // 末端を得る
    s32 idx = 0;
    while(idx < NUM_POBJ_MAX)
    {
        if(_pobjsvst[idx]._ucase == 0)	// 未記録
        {
            break;
        }
        idx++;
    }

    for(ListIterator<PlacementObj*> it = listPlaceObj->iterator(); it.has(); it.next())
    {
        if(idx >= NUM_POBJ_MAX)
        {
            ASSERT(idx < NUM_POBJ_MAX);
            return false;
        }
        const PlacementObj* pobj = it.object();
        if(!pobj->isNullState())	// 初期状態以外なら
        {
            PlacementObj::SaveStructure* pobjsvst = &_pobjsvst[idx];
            pobj->storeToStructure(pobjsvst);	// 保存
            idx++;
        }
    }
    ASSERT(idx <= NUM_POBJ_MAX);

    return true;
}
Example #18
0
Scene::~Scene()
{
   //clean up all of the basic object heap-allocated memory
   ListIterator<TransformNode>* ioIter = transformNodes->iterator();
   while (ioIter->hasNext())
   {
      TransformNode* tn = ioIter->next();
      tn->removeRef();
   }

   delete ioIter;
   delete transformNodes;
   delete sceneTransform;
}
Example #19
0
void BasicObject::render(Pixel* pix, Matrix* transformMatrix)
{
	int count = 1;
	ListIterator<Face>* iter = faces.iterator();

	while(iter->hasNext())
	{
		//printf("\nPrinting face #%d", count);
		count++;
		iter->next()->render(pix, transformMatrix);
	}

	delete iter;
}
Example #20
0
void BasicObject::printFaces()
{
	int count = 0;
	ListIterator<Face>* iter = faces.iterator();

	while(iter->hasNext())
	{
		count++;
		printf("face %d:\n", count);
		iter->next()->printFace();
	}

	delete iter;
}
Example #21
0
void PageView::startText(double x, double y) {
	XOJ_CHECK_TYPE(PageView);

	this->xournal->endTextAllPages(this);

	if (this->textEditor == NULL) {
		// Is there already a textfield?
		ListIterator<Element *> eit = this->page.getSelectedLayer()->elementIterator();

		Text * text = NULL;

		while (eit.hasNext()) {
			Element * e = eit.next();

			if (e->getType() == ELEMENT_TEXT) {
				GdkRectangle matchRect = { x - 10, y - 10, 20, 20 };
				if (e->intersectsArea(&matchRect)) {
					text = (Text *) e;
					break;
				}
			}
		}

		bool ownText = false;
		if (text == NULL) {
			ToolHandler * h = xournal->getControl()->getToolHandler();
			ownText = true;
			text = new Text();
			text->setX(x);
			text->setY(y);
			text->setColor(h->getColor());
			text->setFont(settings->getFont());
		}

		this->textEditor = new TextEditor(this, xournal->getWidget(), text, ownText);
		if (!ownText) {
			this->textEditor->mousePressed(x - text->getX(), y - text->getY());
		}

		rerenderPage();
	} else {
		Text * text = this->textEditor->getText();
		GdkRectangle matchRect = { x - 10, y - 10, 20, 20 };
		if (!text->intersectsArea(&matchRect)) {
			endText();
		} else {
			this->textEditor->mousePressed(x - text->getX(), y - text->getY());
		}
	}
}
Example #22
0
void Hash::reHashRecords(Bucket* bucket, int bucketNumber, Bucket* newBucket)
{
	List<Record*>* recordList = bucket->getRecordList();
	ListIterator<Record*> it = recordList->getIterator();
	Record* auxRecord = NULL;
	int bucketDestinationNumber = 0;
	while(it.hasNext()){
		auxRecord = it.next();
		bucketDestinationNumber = this->hashTable->getBlock(this->hashKey(auxRecord->getKey()));
		if(bucketDestinationNumber != bucketNumber){
			newBucket->insertRecord(auxRecord->clone());
			bucket->deleteRecord(auxRecord->getKey());
		}
	}
}
Example #23
0
void TransformNode::render(Pixel* px, Matrix* later, Matrix* zbuffer, Color *ambient, Light *pointLight, Vertex *eye, double attenuation)
{
   //transform passed in from higher in the scene graph
   Matrix* updated = later->multiply(transform);

   ListIterator<Node>* iter = children->iterator();
   while (iter->hasNext())
   {
      Node* node = iter->next();
      node->render(px, updated, zbuffer, ambient, pointLight, eye, attenuation);
   }

   delete iter;
   delete updated;
}
Example #24
0
/**
*   ~BasicObject
*   Deconstuctor.
*   Preconditions:
*       None.
*   Postconditions:
*       BasicObject object is destroyed.
*/
BasicObject::~BasicObject()
{


    ListIterator<Face>* iter = faces->iterator();
    while ( iter->hasNext() ) {
            delete iter->next();
    }
    delete iter;
    delete faces;
    
    vertices->removeAll();
    delete vertices;

}
Example #25
0
TransformNode::~TransformNode()
{
	ListIterator<Node>* iter = nodes->iterator();
	printf("\nDeleting transform node - start");
	while(iter->hasNext())
	{		
		printf("\nin loop temp");
		iter->next()->removeRef();
	}

	delete iter;
	delete nodes;

	printf("\nDeleting transform node - end");
}
Example #26
0
/**
*    render
*    Renders the scene.
*    Preconditions:
*        The pixel object.
*    Postconditions:
*        The scene is rendered when the final render method is reached.
*/
void Scene::render( Pixel* pix )
{
    Matrix* zbuffer = new Matrix( pix->getHeight(), pix->getWidth() );
    for ( int i = 0; i < pix->getHeight(); i++ ) {
         for ( int j = 0; j < pix->getWidth(); j++ ) {
             zbuffer->setElement( i, j, -1 );
         }
    }
    
    ListIterator<Node>* iter = scene->iterator();
    while( iter->hasNext() ) {
        iter->next()->render( pix, wnd, zbuffer );
    }
    delete iter;
    delete zbuffer;
}
Example #27
0
BasicObject::~BasicObject()
{
	ListIterator<Face>* iter2 = faces.iterator();
	while(iter2->hasNext())
	{
		delete iter2->next();
	}

	ListIterator<Vertex>* iter = vertices.iterator();
	while(iter->hasNext())
	{
		delete iter->next();
	}	

	delete iter;
	delete iter2;
	printf("\nDeleting\n");
}
/*---------------------------------------------------------------------*//**
	配置オブジェクトリストへセーブデータを復元する

	@param listPlaceObj 配置オブジェクトリスト
	@retval true 成功
	@retval false 失敗
**//*---------------------------------------------------------------------*/
bool SaveStructure::restorePlacementObjData(List<PlacementObj*>* listPlaceObj) const
{
    for(ListIterator<PlacementObj*> it = listPlaceObj->iterator(); it.has(); it.next())
    {
        PlacementObj* pobj = it.object();

        for(int idx = 0; idx < NUM_POBJ_MAX; idx++)
        {
            const PlacementObj::SaveStructure* pobjsvst = &_pobjsvst[idx];
            if(isSamePlacementObj(pobjsvst, pobj))
            {
                pobj->restoreFromStructure(pobjsvst);	// 復元
                break;
            }
        }
    }

    return true;
}
Example #29
0
void Scene::render(Pixel* px)
{
	//Create zbuffer
	Matrix *zBuffer = new Matrix(px->getHeight(), px->getWidth());
	for(int i=0 ; i<px->getHeight() ; i++)
	{
		for(int j=0 ; j<px->getWidth() ; j++)
		{
			zBuffer->setElement(i, j, -1);
		}
	}
   //loop over all the Instance instances in the Scene and render them
   ListIterator<TransformNode>* ioIter = transformNodes->iterator();
   while (ioIter->hasNext())
   {
      TransformNode* tn = ioIter->next();
      tn->render(px, sceneTransform, zBuffer);
   }
   delete ioIter;
}
Example #30
0
void EditSelection::serialize(ObjectOutputStream & out) {
	out.writeObject("EditSelection");

	out.writeDouble(this->x);
	out.writeDouble(this->y);
	out.writeDouble(this->width);
	out.writeDouble(this->height);

	out << this->contents;
	out.endObject();

	ListIterator<Element *> it = this->getElements();
	int count = it.getLength();
	out.writeInt(count);

	while (it.hasNext()) {
		Element * e = it.next();
		out << e;
	}
}