int main(){

	int i = 0, j = 0;
	Matrix* m1 = read_arquive("..//in1.txt");	

	printf("**Arquivo in1.txt\n");

	for(i = 0; i < m1->row; i++){
		for(j = 0; j < m1->column; j++){
			printf("\t%d ",m1->value[i][j]);
		}
		printf("\n");	
	}

	printf("**Arquivo in2.txt\n");

	Matrix* m2 = read_arquive("..//in2.txt");	

	for(i = 0; i < m2->row; i++){
		for(j = 0; j < m2->column; j++){
			printf("\t%d ",m2->value[i][j]);
		}
		printf("\n");	
	}

	printf("Matrix1 line2\n ");
	int* line = getRowMatrix(m1, 1);
	for(i = 0; i < m1->column; i++)
		printf("%d ",line[i]);	
	
	printf("\n");

	printf("Matrix2 column3\n ");
	int* col = getColumnMatrix(m2, 2);
	for(i = 0; i < m2->row; i++)
		printf("%d ",col[i]);	
	
	printf("\n");

	printf("----------------- \n");
	printf("File writing tests \n");

	write_arquive("saida.txt", m1);
	free(m1);
	free(m2);

	return 0;
}
Ejemplo n.º 2
0
void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e) {
  // Area = 0, Line = 1, All = 2
  int modeValue = m_colorType.getIndex();

  //------------------------------------
  // MultiLayerStylePicker
  /*---
                  PickしたStyleId = 0、かつ
                  Preference で MultiLayerStylePickerが有効、かつ
                  Scene編集モード、かつ
                  下のカラムから拾った色がTransparentでない場合、
                  → カレントLevelを移動する。
  ---*/
  if (Preferences::instance()->isMultiLayerStylePickerEnabled() &&
      getApplication()->getCurrentFrame()->isEditingScene()) {
    int superPickedColumnId = getViewer()->posToColumnIndex(
        e.m_pos, getPixelSize() * getPixelSize(), false);

    if (superPickedColumnId >= 0 /*-- 何かColumnに当たった場合 --*/
        &&
        getApplication()->getCurrentColumn()->getColumnIndex() !=
            superPickedColumnId) /*-- かつ、Current Columnでない場合 --*/
    {
      /*-- そのColumnからPickを試みる --*/
      int currentFrame = getApplication()->getCurrentFrame()->getFrame();
      TXshCell pickedCell =
          getApplication()->getCurrentXsheet()->getXsheet()->getCell(
              currentFrame, superPickedColumnId);
      TImageP pickedImage           = pickedCell.getImage(false).getPointer();
      TToonzImageP picked_ti        = pickedImage;
      TVectorImageP picked_vi       = pickedImage;
      TXshSimpleLevel *picked_level = pickedCell.getSimpleLevel();
      if ((picked_ti || picked_vi) && picked_level) {
        TPointD tmpMousePosition = getColumnMatrix(superPickedColumnId).inv() *
                                   getViewer()->winToWorld(e.m_pos);

        TPointD tmpDpiScale = getCurrentDpiScale(picked_level, getCurrentFid());

        tmpMousePosition.x /= tmpDpiScale.x;
        tmpMousePosition.y /= tmpDpiScale.y;

        StylePicker superPicker(pickedImage);
        int picked_subsampling =
            picked_level->getImageSubsampling(pickedCell.getFrameId());
        int superPicked_StyleId = superPicker.pickStyleId(
            TScale(1.0 / picked_subsampling) * tmpMousePosition +
                TPointD(-0.5, -0.5),
            getPixelSize() * getPixelSize(), modeValue);
        /*-- 何かStyleが拾えて、Transparentでない場合 --*/
        if (superPicked_StyleId > 0) {
          /*-- Levelの移動 --*/
          getApplication()->getCurrentLevel()->setLevel(picked_level);
          /*-- Columnの移動 --*/
          getApplication()->getCurrentColumn()->setColumnIndex(
              superPickedColumnId);
          /*-- 選択の解除 --*/
          if (getApplication()->getCurrentSelection()->getSelection())
            getApplication()
                ->getCurrentSelection()
                ->getSelection()
                ->selectNone();
          /*-- StyleIdの移動 --*/
          getApplication()->setCurrentLevelStyleIndex(superPicked_StyleId);
          return;
        }
      }
    }
  }
  /*-- MultiLayerStylePicker ここまで --*/
  //------------------------------------
  TImageP image    = getImage(false);
  TToonzImageP ti  = image;
  TVectorImageP vi = image;
  TXshSimpleLevel *level =
      getApplication()->getCurrentLevel()->getSimpleLevel();
  if ((!ti && !vi) || !level) return;

  /*-- 画面外をpickしても拾えないようにする --*/
  if (!m_viewer->getGeometry().contains(pos)) return;

  int subsampling = level->getImageSubsampling(getCurrentFid());
  StylePicker picker(image);
  int styleId =
      picker.pickStyleId(TScale(1.0 / subsampling) * pos + TPointD(-0.5, -0.5),
                         getPixelSize() * getPixelSize(), modeValue);

  if (styleId < 0) return;

  if (modeValue == 1)  // LINES
  {
    /*-- pickLineモードのとき、取得Styleが0の場合はカレントStyleを変えない。
      * --*/
    if (styleId == 0) return;
    /*--
      * pickLineモードのとき、PurePaintの部分をクリックしてもカレントStyleを変えない
      * --*/
    if (ti &&
        picker.pickTone(TScale(1.0 / subsampling) * pos +
                        TPointD(-0.5, -0.5)) == 255)
      return;
  }

  /*--- Styleを選択している場合は選択を解除する ---*/
  TSelection *selection =
      TTool::getApplication()->getCurrentSelection()->getSelection();
  if (selection) {
    TStyleSelection *styleSelection =
        dynamic_cast<TStyleSelection *>(selection);
    if (styleSelection) styleSelection->selectNone();
  }

  getApplication()->setCurrentLevelStyleIndex(styleId);
}
Ejemplo n.º 3
0
TAffine TTool::getCurrentColumnMatrix() const {
  return getColumnMatrix(m_application->getCurrentColumn()->getColumnIndex());
}