public void select(AttractorWeight weight, List <DflipPhoto> photos, List <Stroke> strokes)
    {
        int key = GetComponent <PhotoManager>().sSortKey;

        if (key > 0)
        {
            //参照するパラメータの最大値、最小値を持ってくる
            if (lastKey != key)
            {
                min     = PhotoManager.minValue[key];
                max     = PhotoManager.maxValue[key];
                lastKey = key;
            }

            foreach (DflipPhoto a in photos)
            {
                //スケール変更用速度
                float ds = 0;
                if (a.metadata.ContainsKey(key) == true && min != max)
                {
                    //目標スケール
                    float target = PhotoManager.Instance.AdjustScaleMax;
                    target = target * Mathf.Pow((a.metadata[key] - min) / (max - min), 1) + 0.5f;
                    ds     = (target - a.Size) * 0.005f * weight_;
                }
                a.AddScale(ds);
            }
        }
    }
    public void select(AttractorWeight weight, List <DflipPhoto> photos, List <Stroke> strokes)
    {
        float MaxPhotoSize = PhotoManager.Instance.Max;
        float MinPhotoSize = PhotoManager.Instance.Min;

        // アトラクター選択
        foreach (DflipPhoto a in photos)
        {
            // スケール変更速度
            float ds = 0;

            // 隣接している写真が存在する場合
            if (a.Adjacency.Count > 0)
            {
                //weight_ /= (1f + 0.03f * a.Adjacency.Count);
                foreach (PhotoAdjacency b in a.Adjacency)
                {
                    // 隣接している写真のほうが自身より小さい場合
                    if (b.photo.Size < a.Size)
                    {
                        if (a.isClicked == true)
                        {
                            ds -= (a.Size - MinPhotoSize) * 0.0001f * weight_;
                        }
                        else
                        {
                            ds -= (a.Size - MinPhotoSize) * 0.001f * weight_;
                        }
                    }
                }
            }

            // 写真が最大・最小を超えないようする制約
            if (a.Size < MinPhotoSize)
            {
                ds += (MinPhotoSize - a.Size) * 0.002f * weight_;
            }
            else if (a.Size > MaxPhotoSize)
            {
                ds -= (a.Size - MaxPhotoSize) * 0.002f * weight_;
            }

            //// ノイズ付加
            //if (true)
            //{
            //    //float variance = weight.NoiseWeight * 0.2f;
            //    //float noise = (float)randbm.NextDouble(variance);
            //    //ds += noise;

            //    float noise = UnityEngine.Random.value * 0.00001f;
            //    ds += noise;
            //}
            a.AddScale(ds);
        }
    }
 public void select(AttractorWeight weight, List <DflipPhoto> photos, List <Stroke> strokes)
 {
     key = GetComponent <PhotoManager>().mouseAttractorKey2;
     foreach (DflipPhoto a in photos)
     {
         if (a.metaword[key].Contains("0"))
         {
             a.transform.localScale = new Vector3(0, 0, 0);
         }
     }
 }
Exemple #4
0
    // Use this for initialization
    void Start()
    {
        Instance = this;
        weight   = new AttractorWeight(3.5f, 0, 0, 0, 0, 0, 0, 100, 0);

        systemState |= SystemState.LOAD;

        #region システム
        if ((systemState & SystemState.LOAD) == SystemState.LOAD)
        {
            //カメラ状態設定
            cameraState       |= CameraState.ORTHOGRAPHIC | CameraState.ZOOM_OUT;
            zoomEnabled        = false;
            interactiveEnabled = false;

            //初期設定読み込み
            LoadSettingFlies lsf = GetComponent <LoadSettingFlies>();
            lsf.Load();

            //Wall設定
            AutoDisplayAdjuster wall = GetComponent <AutoDisplayAdjuster>();
            wall.Load();

            //GUI処理
            GUIManager gui = GetComponent <GUIManager>();
            gui.Initialize();
        }
        #endregion

        #region ポインティング
        pointingState |= PointingState.POINTING;
        #endregion

        #region アトラクター
        attractorState = attractorState | AttractorState.AVOID | AttractorState.AVOID_SCALE | AttractorState.SCALE_UP | AttractorState.FRAME;
        if ((pointingState & PointingState.POINTING) == PointingState.POINTING)
        {
            attractorState |= AttractorState.SCALE_UP_MOUSE;
        }
        else if ((pointingState & PointingState.VENN) == PointingState.VENN)
        {
            //attractorState |= AttractorState.FRAME;
        }
        zAxisDirection = true;
        #endregion

        systemState  = ~SystemState.LOAD & systemState;
        systemState |= SystemState.MAIN;
    }
Exemple #5
0
    public void select(AttractorWeight weight, List <DflipPhoto> photos, List <Stroke> strokes)
    {
        //weight_ = weight.FrameWeight;
        foreach (Stroke a in strokes)
        {
            if (a.IsClosed == false)
            {
                continue;
            }

            foreach (DflipPhoto b in photos)
            {
                if (b.isClicked == true)
                {
                    continue;
                }

                bool    inner = a.IsInternalCheck(b.transform.localPosition, camera.ScreenToWorldPoint(new Vector2(Screen.width, Screen.height)));
                Vector2 v     = Vector2.zero;
                Vector2 v2n   = Vector2.one * float.MaxValue;

                if (a.relatedPhotos.Contains(b) == true && inner == false) //関連写真がベン図外にあれば引き寄せる
                {
                    Vector2 dir = a.Center - b.transform.position;
                    v += dir / dir.magnitude;
                    v *= 0.1f * gatherWeight_;
                    b.Adjacency.Clear();
                }
                else if (a.relatedPhotos.Contains(b) == false && inner == true) //非関連写真がベン図内にあれば弾き出す
                {
                    Vector2 dir = b.transform.position - a.Center;
                    v += dir / dir.magnitude;
                    v *= 1f * avoidWeight_;
                }

                //ノイズ付加
                //if (true)
                //{
                //    //float variance = weight.NoiseWeight * 0.5f;
                //    //Vector2 noise = new Vector2((float)randbm.NextDouble(variance), (float)randbm.NextDouble(variance));

                //    Vector2 noise = new Vector2(Random.Range(-0.1f, 0.1f), Random.Range(-0.1f, 0.1f));
                //    v += noise;
                //}

                b.AddPosition(v);
            }
        }
    }
    public void select(AttractorWeight weight, List <DflipPhoto> photos, List <Stroke> strokes)
    {
        //weight_ = weight.ScaleUpMouseWeight;

        foreach (DflipPhoto a in photos)
        {
            float ds = 0;

            if (a.isClicked == true)
            {
                ds += (ClickedPhotoSize - a.Size) * 0.01f * weight_;
            }

            a.AddScale(ds);
        }
    }
Exemple #7
0
    public void select(AttractorWeight weight, List <DflipPhoto> photos, List <Stroke> strokes)
    {
        float MaxPhotoSize = PhotoManager.Instance.Max;
        float MinPhotoSize = PhotoManager.Instance.Min;

        //float eachPhotoSize = Screen.width * Screen.height / photos.Count;

        //weight_ = weight.ScaleUpWeight;

        // アトラクター選択
        foreach (DflipPhoto a in photos)
        {
            //float MaxPhotoSize = PhotoManager.Instance.MinPhotoSize(a, eachPhotoSize);
            //float MinPhotoSize = PhotoManager.Instance.MaxPhotoSize(a, eachPhotoSize);

            // スケール速度
            float ds = 0;

            // 重ならないように制約
            if (a.Adjacency.Count == 0)
            {
                // 周りに画像がなければMaxPhotoSizeまで拡大させる
                ds += (MaxPhotoSize - a.Size) * 0.001f * weight_;
            }

            // サイズがMinPhotoSize以下もしくはMaxPhotoSize以上になるのを防ぐ制約
            if (a.Size < MinPhotoSize)
            {
                ds += (MinPhotoSize - a.Size) * 0.002f * weight_;
            }
            else if (a.Size > MaxPhotoSize)
            {
                ds -= (a.Size - MaxPhotoSize) * 0.002f * weight_;
            }

            ////ノイズを付加する
            //if (true)
            //{
            //    //float variance = weight.NoiseWeight * 0.2f;

            //    float noise = UnityEngine.Random.value * 0.00001f;
            //    ds += noise;
            //}

            a.AddScale(ds);
        }
    }
Exemple #8
0
    public void select(AttractorWeight weight, List <DflipPhoto> photos, List <Stroke> strokes)
    {
        weight_ = weight.AvoidWeight;

        foreach (DflipPhoto a in photos)
        {
            // ポジション変更速度
            Vector2 v = Vector2.zero;


            // 重なっている写真から離れるように移動する
            foreach (PhotoAdjacency b in a.Adjacency)
            {
                if (a.isClicked == true)
                {
                    v += b.direction * 0.1f * weight_;
                }
                else if ((a.target - (Vector2)a.transform.localPosition).magnitude > threshold)
                {
                    v += b.direction * 0.3f * weight_;
                }
                else
                {
                    v += b.direction * 1f * weight_;
                }
            }

            // ノイズ付加
            if (true)
            {
                Vector2 noise = noiseWeight * new Vector2(Random.Range(-0.1f, 0.1f), Random.Range(-0.1f, 0.1f));
                v += noise;
            }


            a.AddPosition(v);
            a.AvoidWall();
        }
    }
    void Update()
    {
        weight = GetComponent <SystemManager>().weight;

        if ((SystemManager.systemState & SystemManager.SystemState.MAIN) == SystemManager.SystemState.MAIN)
        {
            if (attractorEnable)
            {
                #region selectの更新
                if ((SystemManager.attractorState & SystemManager.AttractorState.AVOID) == SystemManager.AttractorState.AVOID)
                {
                    avoid.select(weight, photos, stroke.strokes);
                }
                if ((SystemManager.attractorState & SystemManager.AttractorState.AVOID_SCALE) == SystemManager.AttractorState.AVOID_SCALE)
                {
                    avoidScale.select(weight, photos, stroke.strokes);
                }
                if ((SystemManager.attractorState & SystemManager.AttractorState.SCALE_UP) == SystemManager.AttractorState.SCALE_UP)
                {
                    scaleUp.select(weight, photos, stroke.strokes);
                }
                if ((SystemManager.attractorState & SystemManager.AttractorState.HORIZONTAL_SORT) == SystemManager.AttractorState.HORIZONTAL_SORT)
                {
                    hSort.select(weight, photos, stroke.strokes);
                }
                if ((SystemManager.attractorState & SystemManager.AttractorState.VERTICAL_SORT) == SystemManager.AttractorState.VERTICAL_SORT)
                {
                    vSort.select(weight, photos, stroke.strokes);
                }
                if ((SystemManager.attractorState & SystemManager.AttractorState.FRAME) == SystemManager.AttractorState.FRAME)
                {
                    frame.select(weight, photos, stroke.strokes);
                }
                if ((SystemManager.attractorState & SystemManager.AttractorState.ADJUST_SCALE) == SystemManager.AttractorState.ADJUST_SCALE)
                {
                    adjustScale.select(weight, photos, stroke.strokes);
                }
                if ((SystemManager.attractorState & SystemManager.AttractorState.COLOR) == SystemManager.AttractorState.COLOR)
                {
                    color.select(weight, photos, stroke.strokes);
                }
                if ((SystemManager.attractorState & SystemManager.AttractorState.KEYWORD) == SystemManager.AttractorState.KEYWORD)
                {
                    keyword.select(weight, photos, stroke.strokes);
                }
                if ((SystemManager.attractorState & SystemManager.AttractorState.LANGUAGE) == SystemManager.AttractorState.LANGUAGE)
                {
                    language.select(weight, photos, stroke.strokes);
                }


                if ((SystemManager.pointingState & SystemManager.PointingState.POINTING) == SystemManager.PointingState.POINTING)
                {
                    if ((SystemManager.attractorState & SystemManager.AttractorState.SCALE_UP_MOUSE) == SystemManager.AttractorState.SCALE_UP_MOUSE)
                    {
                        scaleUpMouse.select(weight, photos, stroke.strokes);
                    }
                    if (ShowWallLabel)
                    {
                        CWL.Create(photos);
                    }
                }
                #endregion
            }

            foreach (var a in photos)
            {
                a.UpdatePhoto();
            }
        }
    }
Exemple #10
0
    public void select(AttractorWeight weight, List <DflipPhoto> photos, List <Stroke> strokes)
    {
        key = GetComponent <PhotoManager>().keywordCode["カラー"];

        List <ActivePhoto> active = InputManager.Instance.activePhoto;

        if (active.Count > 0)
        {
            foreach (ActivePhoto a in active)
            {
                List <DflipPhoto> relativePhotos             = new List <DflipPhoto>();
                SortedDictionary <double, DflipPhoto> dists_ = new SortedDictionary <double, DflipPhoto>();//小さい順に並べ替えて格納

                #region 閾値設定
                foreach (DflipPhoto b in photos)
                {
                    double dist = 0;
                    if (a.photo != b)
                    {
                        for (int i = 0; i < 25; ++i)
                        {
                            dist += HsvDistance(b.sprite.hsvFeature[i], a.photo.sprite.hsvFeature[i]);
                        }
                        //距離正規化
                        dist /= 25 * 2;
                        dist += (b.sprite.variance - a.photo.sprite.variance) * (b.sprite.variance - a.photo.sprite.variance);
                        dist /= 2;
                    }
                    if (dists_.ContainsKey(dist) == false) //要修正
                    {
                        dists_.Add(dist, b);
                    }
                }
                #endregion

                #region 寄ってくる写真を決定
                int count = 0;
                foreach (KeyValuePair <double, DflipPhoto> kvp in dists_)
                {
                    if (count > photoNum)
                    {
                        count = 0;
                        dists_.Clear();
                        break;
                    }
                    relativePhotos.Add(dists_[kvp.Key]);
                    count++;
                }
                #endregion

                foreach (DflipPhoto c in relativePhotos)
                {
                    Debug.Log(c.fileName);
                    // ポジション変更速度
                    Vector2 v = Vector2.zero;
                    //目標地点
                    c.target = a.photo.gameObject.transform.localPosition;

                    v = (a.photo.gameObject.transform.localPosition - c.gameObject.transform.localPosition) * 0.1f * weight_;

                    c.AddPosition(v);
                    c.AvoidWall();
                }
            }
        }
    }
Exemple #11
0
    public void select(AttractorWeight weight, List <DflipPhoto> photos, List <Stroke> strokes)
    {
        int key = GetComponent <PhotoManager>().hSortKey;

        if (key > 0)
        {
            //参照するパラメータの最大値、最小値を持ってくる
            if (lastKey != key)
            {
                if ((SystemManager.attractorState & SystemManager.AttractorState.GEOGRAPH) == SystemManager.AttractorState.GEOGRAPH)
                {
                    min = 0;
                    max = bg.BackgroundSprite.texture.width;//pixel数指定
                    print("V: " + max);
                }
                else
                {
                    min = PhotoManager.minValue[key];
                    max = PhotoManager.maxValue[key];
                }
                lastKey = key;
            }
            if ((SystemManager.attractorState & SystemManager.AttractorState.GEOGRAPH) != SystemManager.AttractorState.GEOGRAPH)
            {
                if (SystemManager.keys[0].Contains("年月") || SystemManager.keys[0].Contains("Y:M") || SystemManager.keys[0].Contains("date"))
                {
                    min = xSliderMin.value;
                    max = xSliderMax.value;
                }
                else
                {
                    min = float.Parse(mintext.GetComponent <Text>().text);
                    max = float.Parse(maxtext.GetComponent <Text>().text);
                }
            }
            //if ((SystemManager.attractorState & SystemManager.AttractorState.GEOGRAPH) != SystemManager.AttractorState.GEOGRAPH)
            //{
            //    min = float.Parse(mintext.GetComponent<Text>().text);
            //    max = float.Parse(maxtext.GetComponent<Text>().text);
            //}
            //min = float.Parse(mintext.GetComponent<Text>().text);
            //max = float.Parse(maxtext.GetComponent<Text>().text);
            if (AutoDisplayAdjuster.screenChange == true || AutoDisplayAdjuster.wallChange == true || (centerRight == Vector2.zero && centerLeft == Vector2.zero))
            {
                centerRight = new Vector2(AutoDisplayAdjuster.Instance.TopRight().x, 0);
                centerLeft  = new Vector2(AutoDisplayAdjuster.Instance.BottomLeft().x, 0);
            }

            foreach (DflipPhoto a in photos)
            {
                #region いずれかのベン図の関連写真であればソートの対象外とする
                bool relationCheck = false;
                foreach (Stroke b in strokes)
                {
                    if (b.relatedPhotos.Contains(a))
                    {
                        relationCheck = true;
                    }
                }
                if (relationCheck == true)
                {
                    a.target = a.transform.localPosition;
                    continue;
                }
                #endregion

                if (a.metadata.ContainsKey(key) == true && min != max)
                {
                    //ポジション変更用速度
                    Vector2 v = Vector2.zero;
                    //目標地点
                    Vector2 target = Vector2.zero;

                    target     = centerRight - centerLeft;
                    target     = new Vector2(target.x * (a.metadata[key] - min) / (max - min), a.transform.localPosition.y);
                    target     = target + centerLeft;
                    v          = (target - (Vector2)a.transform.localPosition) * weight_;
                    a.target.x = target.x;
                    a.AddPosition(v);
                }
                a.AvoidWall();
            }
        }
    }
    public void select(AttractorWeight weight, List <DflipPhoto> photos, List <Stroke> strokes)
    {
        key = GetComponent <PhotoManager>().mouseAttractorKey;
        List <ActivePhoto> active = InputManager.Instance.activePhoto;

        if (active.Count > 0)
        {
            foreach (ActivePhoto a in active)
            {
                List <DflipPhoto> relativePhotos = new List <DflipPhoto>();

                //foreach (DflipPhoto b in photos)
                //{
                //    //寄ってくる写真を決定
                //    foreach (string c in b.metaword[key])
                //    {
                //        if (c!= "empty")
                //        {
                //            if (a.photo.metaword[key].Contains(c))
                //            {
                //                relativePhotos.Add(b);
                //                b.Adjacency.Clear();
                //            }
                //        }

                //    }

                //}

                string keyword = a.photo.metaword[key][0];
                //Debug.Log(keyword);
                foreach (DflipPhoto b in photos)
                {
                    //寄ってくる写真を決定
                    if (keyword != "empty")
                    {
                        if (b.metaword[key].Contains(keyword))
                        {
                            relativePhotos.Add(b);
                            b.Adjacency.Clear();
                        }
                    }
                }

                foreach (DflipPhoto c in relativePhotos)
                {
                    // ポジション変更速度
                    Vector2 v = Vector2.zero;
                    //目標地点
                    c.target = a.photo.gameObject.transform.localPosition;

                    v = (a.photo.gameObject.transform.localPosition - c.gameObject.transform.localPosition) * 0.1f * weight_;

                    // enlarge relative photos
                    if (c != a.photo && c.Size < a.photo.Size / 5)
                    {
                        float ds = 0;
                        ds += (a.photo.Size / 5 - c.Size) * 0.01f * 40;
                        c.AddScale(ds);
                    }

                    c.AddPosition(v);
                    c.AvoidWall();
                }
            }
        }
    }
Exemple #13
0
 public void invokeAttractorSelection(Dock dock, ScrollBar sBar, AttractorWeight weight, List<Photo> photos, List<Photo> activePhotos, List<Stroke> strokes, SystemState systemState)
 {
     for (int i = 0, size = Attractors.Length; i < size; ++i)
     {
         if ((attractor_ & (1 << i)) != 0)
         {
             Attractors[i].select(dock, sBar, weight, photos, activePhotos, strokes, systemState);
         }
     }
 }